We will be undergoing scheduled maintenance on May 20th, 2013 at 02:00 GMT.
Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com�s entire library of video tutorials.
RBScript is a REAL Studio class that gives you direct access to the Realbasic programming language. With it you can run your own Realbasic code dynamically at run time about not something you would use often, it can be pretty handy to do things that otherwise are not possible. For this example we will use RBScript to create a new class that can evaluate expressions. To get started create a new REAL Studio project. In your project add a new class. We will call this class evaluate, set it's super to RBScript. Open the evaluator class and add a new method which we will call eval. Eval will take one parameter which is the expression itself and will return a string. Eval needs to be public so we that we can call it outside of this class. The source variable will contain some Realbasic code within the string itself. This code is fairly simple, all it does is dimension a variable as a variant and assigns to it the expression that was passed into eval as it's parameter. We then call the print method which will evaluate the expression. We set our RBScript source code to be a source code that's in this string. And then we run that code. Finally we can return the result that we will save. When this code runs, the result is printed. In RBScript that means it will call the print event. So let's add a new property called M Result, where we will store the results from the print event. Now when our code runs, M Result will have the result of the expression. Let's test this. We'll go to the window, and we'll add a field to enter an expression. We'll add a field to show the result, and we'll add a button to calculate or evaluate. Let's save the project and add our code to the evaluate button, to evaluate the expression, and display it in the result field. Let's save the application and run it. Let's try a simple expression, five plus five, and it evaluates to ten. Our evaluator appears to be working. It can do basic arithmetic. It can do basic string cancatanation. And more numeric arithmetic. So as you can see RBScript can prove useful.
| Course: | Real Studio |
| Author: | Paul Lefebvre |
| SKU: | 34190 |
| ISBN: | 1-936334-77-1 |
| Release Date: | 2011-02-02 |
| Duration: | 7 hrs / 87 lessons |
| Work Files: |
Yes |
| Captions: | No |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |