DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

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

Gerome

  • Charter Honorary Member
  • Joined in 2006
  • ***
  • Posts: 154
[FBSL] FARR's Calc tool updated!
« on: September 26, 2006, 09:25 AM »
Hello,

I've improved my FARR's calculator!

Here's the link : http://gedd123.free.fr/Fbsl/DC/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: (fbsl)
#Option Explicit
'#AppType Console

If Not STANDALONE Then
    Fbsl2Exe( Command(1) ): ExitProgram(0)
End If

'// -----------------------------------------------------------------
'// GEG 26 September 2006
'// FBSLCALC.EXE 2.5/56*PI
'// FBSLCALC.EXE /code=msgbox(Null,"Hello","Test",MB_ICONINFORMATION)
'// -----------------------------------------------------------------
Static $code, $resulttext, $result, $cmd = Command(-1), ch34 = Chr(34), ch92 = Chr(92)
If cmd = "" Then
    MsgBox(NULL, "You need to specify an expression to evaluate, like 2+2." & crlf & _
                "If you encounter any problems, tell'em there : " & crlf & _
                "http://www.fbsl.net/phpbb2/index.php", _
                "Freestyle Basic Script Langage (FBSL) Calculator:", MB_OK +MB_ICONINFORMATION)
    ExitProgram(1)
End If

cmd = Replace(cmd, ch34 & ch34, "")
If Left(cmd, 1) = ch34 AndAlso Right(cmd, 1) = ch34 Then
    cmd = Mid(cmd, 2, StrLen(cmd) - 2)
End If

If Instr(cmd,"/code=") Then
    cmd = Remove(Trim(cmd), "/code=")
    code = "result = " & cmd & " : Return result"
    resulttext = cmd & " = " & ExecLine(code)
Else
    cmd = Replace(Trim(cmd), ",", ".")
    code = "result = " & cmd & " : Return result"
    ExecLine(code)
    result = Replace(result, ".", GetLocalSeparator())
    resulttext = cmd & " = " & result
End If

If StrLen(cmd) = 0 Then ExitProgram(-1)

ClipboardSetText(result)'resulttext)
MsgBox(NULL, resulttext, "Freestyle Basic Script Langage (FBSL) Calculator / Executor:", _
       MB_OK+MB_ICONINFORMATION)

Function GetLocalSeparator()
    Dim $Buffer * 4
    ApiCall( "GetNumberFormat", "kernel32", 0, 0, "1.1", 0, @Buffer, Len(Buffer) )
    Return Mid(Buffer,2,1)
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

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: [FBSL] FARR's Calc tool updated!
« Reply #1 on: September 26, 2006, 02:19 PM »
And here's the regex i use: (notice that it only works for the calculator itself)

Code
(.*\+.*|.*\-.*|.*\*.*|.*\/.*)
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)

Original address: https://www.donationcoder.com/forum/index.php?topic=5461.0