The context object exposes its properties and methods as global variables and functions to the RBScript.
Only simple types can cross the boundary back into your program. Thus you can have user calculations which return string values or numbers by calling back to your program either by setting properties or calling functions. eg: say your context object has properties InterestRate, YearsMembership, BankBalance as double a user could write an RBScript with the formula if YearsMembership > 10 or BankBalance > 50000 then InterestRate = 0.02 else InterestRate = 0.01 end if After running that script, the Property InterestRate would be set. Now lets' change that example, instead of YearsMembership being a property, it is a function returning a double, that puts up a dialog asking the user to enter that figure. The same script would work but in the middle of it, your program is "called back" to put up the dialog. This is a case where the RB ability to call functions without parens makes the language a lot more flexible! Check out my sample which shows a fairly complicated context object exposing the Graphics 2D functions and many of the PictureEffects plugin functions (compiles without PictureEffects) http://www.oofile.com.au/downloads.html#DownloadREALbasic and grab ScriptPictureEffects - note there is a new version there which has been updated to build with the latest PictureEffects and RB2007r1. http://www.oofile.com.au/files/REALbasic/ ScriptPictureEffectsWithEinhugur.rbp.zip Look in there for example at functions like: Sub SetPixel(x as integer, y as integer, c as Color) mSurface.Pixel(x,y) = c End Sub which allows a user script like ' randomly change hue of dots dim row, col as integer dim h, s, v as double dim c as color copyImage for row=height-1 downto 0 for col=width-1 downto 0 getpixel col, row, h, s, v h = h * random(10,80)/100.0 ' the values in the brackets can be 0 - 100 ' a range like 20-40 gives reddish hues, 40-80 greenish ' leave v for Value as is so don't darken the picture ' if you change s for Saturation will tone down colors towards grey c = HSV(h, s, v) setpixel col, row, c next col next row _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html>
