Hello,
A couple of questions about RBScript/XScript:
1- I am having a problem with RBScript (which I am just exploring for the first time) and would be grateful if anyone could look at my code and tell me what I am doing wrong:
I have an instance of RBScript (RBscript1) on a window (window1), a canvas (canvas1), a property of window1 (myPic as picture) and two pushbuttons. The two pushbuttons just call a method that draws something on a Picture which is then used in the paint event of canvas1. One of the pushbuttons calls the drawing method directly and it works correctly and the other method calls it using RBscript, and it fails to work.
The method that is called by the pushbuttons is:
Sub myDrawRect(PassedPic as Picture)
PassedPic.Graphics.DrawRect (10,10,50,50)
End Sub
The pushbutton that calls the method directly has this in the action event:
Sub Action()
myPic=new Picture(Canvas1.width, Canvas1.height,32)
myDrawRect(myPic)
Canvas1.Invalidate
End Sub
The pushbutton that uses RBScript and fails to do what I expect uses this:
Sub Action()
myPic=new Picture(Canvas1.width, Canvas1.height,32)
RbScript1.Source="myDrawRect(myPic)"
RbScript1.Context=Window1
RbScript1.Run
Canvas1.Invalidate
End Sub
For this second case I am getting (RBScript) compiler error 11 (Undefined identifier) but I don’t know what it means. If myDrawRect is modified like below it works correctly:
Sub myDrawRect()
myPic.Graphics.DrawRect (10,10,50,50)
End Sub
Which makes me think that the problem is related to the scope/context of RBScript1, but I don’t understand what the problem is.
2- I am exploring RBScript/Xscript because of the performance improvement since it uses LLVM, but since in the above example I am using a “regular” method outside the RBScript (myDrawRect), I imagine I will not get any increase in speed at execution, or will I?
Thank you,
Pixe