topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday December 12, 2024, 12:40 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: [FBSL] FARR's Calc tool updated!  (Read 4841 times)

Gerome

  • Charter Honorary Member
  • Joined in 2006
  • ***
  • Posts: 154
    • View Profile
    • Get my Freestyle Basic Script Language + compiler!
    • Donate to Member
[FBSL] FARR's Calc tool updated!
« on: September 26, 2006, 04:25 AM »
Hello,

I've improved my FARR's calculator!

Here's the link : http://gedd123.free....C/FBSLCalc_16-09.zip

How to install Fbslcalc.fbs into FARR ?
-1- Copy FBSLCalc.exe into \FindAndRunRobot\Scripts\
-2- Open FARR and edit Option, select the 'calc'item,and replace its regex config with this one :
calc $$1 | Scripts/FBSLCalc.exe "$$1"
-3- Save

That'all folks!
Now you can play with the newest calc :)

Usage : FBSLCalc.exe expression

Examples :
basic sample :
Calc 2+2
It'll return '4'

graphical sample :
calc /code=FBSL_Control("Button", Me, "Hello", 1000, 10, 10, 75, 23, 0, 0):show(me):begin events:If CBMsg = WM_COMMAND And CBCTL =1000 then msgbox(0, "Button clicked!", "yoo", 0):end events
it'll afx a form with a button, then just click onto the button... :)

sample sample :
calc /code=ExecLine(FileLoad("./PMem.fbs"))

Enjoy!

Here is the source of the newest FARR's calc :
Code: Text [Select]
  1. #Option Explicit
  2. '#AppType Console
  3.  
  4. If Not STANDALONE Then
  5.     Fbsl2Exe( Command(1) ): ExitProgram(0)
  6. End If
  7.  
  8. '// -----------------------------------------------------------------
  9. '// GEG 26 September 2006
  10. '// FBSLCALC.EXE 2.5/56*PI
  11. '// FBSLCALC.EXE /code=msgbox(Null,"Hello","Test",MB_ICONINFORMATION)
  12. '// -----------------------------------------------------------------
  13. Static $code, $resulttext, $result, $cmd = Command(-1), ch34 = Chr(34), ch92 = Chr(92)
  14. If cmd = "" Then
  15.     MsgBox(NULL, "You need to specify an expression to evaluate, like 2+2." & crlf & _
  16.                 "If you encounter any problems, tell'em there : " & crlf & _
  17.                 "http://www.fbsl.net/phpbb2/index.php", _
  18.                 "Freestyle Basic Script Langage (FBSL) Calculator:", MB_OK +MB_ICONINFORMATION)
  19.     ExitProgram(1)
  20. End If
  21.  
  22. cmd = Replace(cmd, ch34 & ch34, "")
  23. If Left(cmd, 1) = ch34 AndAlso Right(cmd, 1) = ch34 Then
  24.     cmd = Mid(cmd, 2, StrLen(cmd) - 2)
  25. End If
  26.  
  27. If Instr(cmd,"/code=") Then
  28.     cmd = Remove(Trim(cmd), "/code=")
  29.     code = "result = " & cmd & " : Return result"
  30.     resulttext = cmd & " = " & ExecLine(code)
  31. Else
  32.     cmd = Replace(Trim(cmd), ",", ".")
  33.     code = "result = " & cmd & " : Return result"
  34.     ExecLine(code)
  35.     result = Replace(result, ".", GetLocalSeparator())
  36.     resulttext = cmd & " = " & result
  37. End If
  38.  
  39. If StrLen(cmd) = 0 Then ExitProgram(-1)
  40.  
  41. ClipboardSetText(result)'resulttext)
  42. MsgBox(NULL, resulttext, "Freestyle Basic Script Langage (FBSL) Calculator / Executor:", _
  43.        MB_OK+MB_ICONINFORMATION)
  44.  
  45. Function GetLocalSeparator()
  46.     Dim $Buffer * 4
  47.     ApiCall( "GetNumberFormat", "kernel32", 0, 0, "1.1", 0, @Buffer, Len(Buffer) )
  48.     Return Mid(Buffer,2,1)
  49. End Function
Yours,
(¯`·._.·[Gerome GUILLEMIN]·._.·´¯)
http://www.fbsl.net [FBSL Author]
http://gedd123.free.fr/FBSLv3.zip [FBSL Help file]
(¯`·._.·[If you need help... just ask]·._.·´¯)

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: [FBSL] FARR's Calc tool updated!
« Reply #1 on: September 26, 2006, 09:19 AM »
And here's the regex i use: (notice that it only works for the calculator itself)

(.*\+.*|.*\-.*|.*\*.*|.*\/.*)
this expression will match anything that includes a *, +, / or -, which means you are able to do maths only by typing it in farr instead of having to prepend "calc".

(i know, it's not a very good expression since it uses the . aka dot)