In LCB you would use
Code: Select all
public handler testEval() returns Number
variable tExpression as String
variable tList as List
put "10 * 20" into tExpression
split tExpression by "*" into tList
return (element 1 of tList parsed as number) * (element 2 of tList parsed as number)
end handler
I just picked up your code and modified it to work.
After running the code through "Extension Builder" I made a new stack with one button
Code: Select all
on mouseUp
dispatch function "testEval"
answer the result && it
end mouseUp
It answered 200 handled
The LCB file was a library.
The whole LCB file is
Code: Select all
library community.livecode.xxx.mylibrary
use com.livecode.canvas
use com.livecode.widget
use com.livecode.engine
use com.livecode.library.widgetutils
use com.livecode.math
use com.livecode.string
metadata version is "1.0.0"
metadata author is "yyy"
metadata title is "testlib"
public handler testEval() returns Number
variable tExpression as String
variable tList as List
put "10 * 20" into tExpression
split tExpression by "*" into tList
return (element 1 of tList parsed as number) * (element 2 of tList parsed as number)
end handler
end library
When getting my feet wet with LCB I looked up as many examples as I could. Then starting to write my own code/copy code structures.
It took my quite some time to get it working.
In this case you try to use "value" which does not exist in LCB. Make it a habit to look up your LCB stuff in the dictionary.
LCB is close in sytax to LCS but it is definitely not the same. For one declaring and "typing" of variables needs to get used to.
I make extensive use of the "log" command to see what actually is in the variables.
Use square brackets to log more than one variable e.g.: log [variable1, variable2]
Kind regards
Bernd