Sorry. When I inserted the other formats I inserted a litte bug, too.
So you have to download the file again. Then you must copy it to the current directory with the PB-file or in the System-directory.
Before you can use this functions you must insert a "little" Code at the top like in the example.
To calculate use the function "Formel_".
Code: Select all
;========FMLCALC.DLL - Parser Code========
Global fmlcalc_Loaded
Global fmlcalc_RemFunc
Global fmlcalc_SetFunc
Global fmlcalc_ClearFuncs
Global fmlcalc_GetFuncCallID
Global fmlcalc_GetFuncParamCnt
Global fmlcalc_RemVar
Global fmlcalc_SetVarS
Global fmlcalc_SetVarL
Global fmlcalc_ClearVars
Global fmlcalc_GetVarS
Global fmlcalc_Formel
;This command loads the DLL-file
Procedure.l LoadFmlCalc()
If fmlcalc_Loaded=0
If OpenLibrary(0,"fmlcalc.dll")
fmlcalc_RemFunc=IsFunction(0,"RemFunc")
fmlcalc_SetFunc=IsFunction(0,"SetFunc")
fmlcalc_ClearFuncs=IsFunction(0,"ClearFuncs")
fmlcalc_GetFuncCallID=IsFunction(0,"GetFuncCallID")
fmlcalc_GetFuncParamCnt=IsFunction(0,"GetFuncParamCnt")
fmlcalc_RemVar=IsFunction(0,"RemVar")
fmlcalc_SetVarS=IsFunction(0,"SetVarS")
fmlcalc_SetVarL=IsFunction(0,"SetVarL")
fmlcalc_ClearVars=IsFunction(0,"ClearVars")
fmlcalc_GetVarS=IsFunction(0,"GetVarS")
fmlcalc_Formel=IsFunction(0,"Formel")
fmlcalc_Loaded=1
ProcedureReturn 1
EndIf
EndIf
ProcedureReturn 0
EndProcedure
;This command closes the Dll-file after use
Procedure.l UnloadFmlCalc()
If fmlcalc_Loaded=1
If CloseLibrary(0)
fmlcalc_Loaded=0
ProcedureReturn 1
EndIf
EndIf
ProcedureReturn 0
EndProcedure
;This command removes a function from the global list
Procedure.l RemFunc_(FncName.s)
If fmlcalc_Loaded=1
ProcedureReturn CallFunctionFast(fmlcalc_RemFunc,FncName)
EndIf
ProcedureReturn 0
EndProcedure
;With this command you can insert your own functions like
;Sin or Cos...
;ParamCnt is how many Parameters you want for the Procedure.
;Addresse is the address to the Procedure. You can get it with @Procedure()
Procedure.l SetFunc_(FncName.s,ParamCnt.l,Addresse.l)
If fmlcalc_Loaded=1
ProcedureReturn CallFunctionFast(fmlcalc_SetFunc,FncName,ParamCnt.l,Addresse.l)
EndIf
ProcedureReturn 0
EndProcedure
;Removes all functions from the list
Procedure.l ClearFuncs_()
If fmlcalc_Loaded=1
ProcedureReturn CallFunctionFast(fmlcalc_ClearFuncs)
EndIf
ProcedureReturn 0
EndProcedure
;With this function you can get the address of a procedure, you've already insert
Procedure.l GetFuncCallID_(FncName.s)
If fmlcalc_Loaded=1
ProcedureReturn CallFunctionFast(fmlcalc_GetFuncCallID,FncName)
EndIf
ProcedureReturn 0
EndProcedure
;And with this you can get the number of parameters for a procedure
Procedure.l GetFuncParamCnt_(FncName.s)
If fmlcalc_Loaded=1
ProcedureReturn CallFunctionFast(fmlcalc_GetFuncParamCnt,FncName)
EndIf
ProcedureReturn 0
EndProcedure
;Fmlcalc.dll has a list with values, too. With this command you can delete an value.
Procedure.l RemVar_(VarName.s)
If fmlcalc_Loaded=1
ProcedureReturn CallFunctionFast(fmlcalc_RemVar,VarName)
EndIf
ProcedureReturn 0
EndProcedure
;Use this function to set a value in the list to a string. This string can contain a value or a text.
Procedure.l SetVarS_(VarName.s,strVal.s)
If fmlcalc_Loaded=1
ProcedureReturn CallFunctionFast(fmlcalc_SetVarS,VarName,strVal)
EndIf
ProcedureReturn 0
EndProcedure
;This command is the same as SetVarS_(... , Str(lngVal))
Procedure.l SetVarL_(VarName.s,lngVal.l)
If fmlcalc_Loaded=1
ProcedureReturn CallFunctionFast(fmlcalc_SetVarL,VarName,lngVal)
EndIf
ProcedureReturn 0
EndProcedure
;Remove all items from the value list
Procedure.l ClearVars_()
If fmlcalc_Loaded=1
ProcedureReturn CallFunctionFast(fmlcalc_ClearVars)
EndIf
ProcedureReturn 0
EndProcedure
;Use this function to read the content of a string.
Procedure.s GetVarS_(VarName.s)
If fmlcalc_Loaded=1
ProcedureReturn PeekS(CallFunctionFast(fmlcalc_GetVarS,VarName))
EndIf
ProcedureReturn ""
EndProcedure
;Use this function to calculate.
Procedure.s Formel_(Fnc.s)
If fmlcalc_Loaded=1
ProcedureReturn PeekS(CallFunctionFast(fmlcalc_Formel,Fnc))
EndIf
ProcedureReturn ""
EndProcedure
LoadFmlCalc() ;Load the parser DLL.
;=================================
; BIG Calc
; Copyright (C) Julian Bury, 2003
;=================================
#Window = 0
#Times = 1 ;font ID
;keys
#Up = 100
#Down = 101
#Tab = 108
#Riturn = 113
#Escape = 257
Global maxg ;0 to 48 gadget IDs
Global maxx ;0 to 2 columns
Global maxy ;0 to 15 rows
Global maxl ;0 to 255 calculation lines
Global offs ;0 to 240 offset to displayed section of the data array
Global maxo ;maximum offset to displayed part of the data array
maxg = 48
maxx = 2
maxy = 15
maxl = 255
offs = 0
maxo = maxl-15
Dim valu(maxl+1)
Dim txt$(4,maxl+1)
Dim pos(maxx+1,maxy+1)
; stick some random data in the display gadgets
For t=0 To maxl
txt$(0,t)="n"+Str(t)
txt$(1,t)="0.0"
txt$(2,t)=Str(Random(9))+Mid("+-*/^",1+Random(4),1)+Str(Random(9))
txt$(3,t)=txt$(2,t)
Next
; Create the window and fill it with string gadgets full of data.
; Establish keyboard control for navigation between gadgets.
If OpenWindow(0,165,0,800,25*17,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"BIG Calc")
If CreateGadgetList(WindowID())
FontID.l = LoadFont(#Times, "Times New Roman", 12,#PB_Font_Bold|#PB_Font_HighQuality)
id=0
t=0
For y=0 To maxy
xpos=1
ypos=y*25
StringGadget(id,xpos,ypos,100,24,txt$(0,t+offs))
pos(0,y)=GadgetID(id)
id+1
xpos=101
ypos=y*25
StringGadget(id,xpos,ypos,200,24,txt$(1,t+offs))
pos(1,y)=GadgetID(id)
id+1
xpos=302
ypos=y*25
StringGadget(id,xpos,ypos,497,24,txt$(2,t+offs))
pos(2,y)=GadgetID(id)
id+1
t+1
Next
xpos=1
ypos=25*16+4
TextGadget(id,xpos,ypos,797,24,"The selected calculation, formatted for the parser",#PB_Text_Center)
pos(0,y)=GadgetID(id)
AddKeyboardShortcut(#Window,#PB_Shortcut_Return,#Riturn)
AddKeyboardShortcut(#Window,#PB_Shortcut_Up,#Up)
AddKeyboardShortcut(#Window,#PB_Shortcut_Down,#Down)
AddKeyboardShortcut(#Window,#PB_Shortcut_Tab,#Tab)
AddKeyboardShortcut(#Window,#PB_Shortcut_Escape,#Escape)
EndIf
For id=0 To maxg
SetGadgetFont(id,FontID.l)
Next
xpos=2
ypos=0
EndIf
ActivateGadget(2)
;== Procedures ==============
; perform the calculation - everything depends on this ...
; I need a procedure or a function called Parse() to make his work
Procedure do_the_calculations()
For t=0 To maxl
txt$(1,t)=Formel_(txt$(2,t))
Next
EndProcedure
; update the contents of the display gadgets
Procedure refresh_the_window()
id=0
For t=0 To maxy
;Debug txt$(0,t+offs)
SetGadgetText(id,txt$(0,t+offs)) : id+1
SetGadgetText(id,txt$(1,t+offs)) : id+1 ; #Gadget object not initialised !
SetGadgetText(id,txt$(2,t+offs)) : id+1
Next
EndProcedure
;=======================
Repeat ; Main loop
EventID=WaitWindowEvent()
;discover the string with the focus
If EventID=#PB_Event_Menu
For x=0 To maxx
For y=0 To maxy
If GetFocus_()=pos(x,y)
xpos=x
ypos=y
EndIf
Next
Next
;I would never have thought to lookup "MenuID" for "keydown detection"!
em=EventMenuID()
SetGadgetText(48,Str(em))
Select em
Case #Up
If ypos>0 Or offs>0
If ypos>0
ypos-1
Else
offs-1
refresh_the_window()
EndIf
EndIf
Case #Down
If yposmaxx:xpos=0:EndIf
Case #Riturn
do_the_calculations()
refresh_the_window()
Case #Escape
End
EndSelect
SetFocus_(pos(xpos,ypos))
EndIf
Until EventID=#PB_Event_CloseWindow
End
If you have more questions, just ask me.