Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun Oct 21, 2018 8:58 pm

All times are UTC - 5 hours

Post new topic Reply to topic  [ 16 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Distinguishing between End, End If, and End Select
PostPosted: Sat Feb 09, 2013 11:03 am 
User avatar

Joined: Mon Feb 05, 2007 5:21 pm
Posts: 600
Location: New York, NY
Everyone participates here to get help, and to give it when they can, so it's no trouble. I'm sure you'll return the favor some day.

First the "extends" keyword. Let's take a built-in function like "InStr". You have two ways to call that: y = InStr( s, t ) and y = s.InStr( t ). Now suppose you could look at the declaration of that function, what might it look like? The first case is easy:
Function InStr( src As String, find As String ) As Integer

But what about the second way? That's where Extends comes in:
Function InStr( Extends src As String, find As String ) As Integer

This is a convenient way to "add" a method call to an existing class. "Extends" can only be applied to the first parameter of a method or function, and used only once in the declaration. When it is present, the first parameter is expected to precede the "." like param1.Func( param2, ... ). When it's not, the "traditional" function or method call is expected, like Func( param1, param2, ... ).

(If you get the M_String module from my web site, you will find within it a whole bunch of methods and functions that use both forms side-by-side to allow either type of call.)

Extends can only be used within a Module in a Real Studio project and it's scope must be global. If you try to use it in a method defined within a class or window, you will get the errors that you got.

Next, the IDE script. Real Studio provides RBScript, a scripting language that can be created and executed on the fly within a running application. (See RBScript in the Language Reference.) It also provides a way to use that scripting language to manipulate the IDE while you're coding. Since that's what we are doing, I created this as an IDE Script using RBScript. (See IDE Script in the Language Reference.)

The rules for RBScript are similar to those of the language when writing an app, but more limited. For example, you can't declare a variable within the For loop like "for i as integer = ...", you must declare it before. It's also more permissive in that you can create functions, methods, classes, and modules all within the script.

To create one, go under the File menu and chose "IDE Scripts -> New IDE Script". Copy and paste my code from above into that, then open a code pane within your project and run the script. (You'll see the "run" button in the IDE Script window.) If you want to access it any time, save the script in the "Scripts" folder next to the Real Studio application and it will appear under the File -> IDE Scripts menu.

Kem Tekinay
MacTechnologies Consulting

Need to develop, test, and refine regular expressions? Try RegExRX.

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page Previous  1, 2

All times are UTC - 5 hours

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group