Run

=RUN=

RUN "projectname", #handle - Run the program in the project named projectname. That program will run until it hits a WAIT statement at which point execution will return to the statement after RUN. The program that is run will be assigned to the object variable #handle. You can then treat it like any other object. You can use RENDER to show the object on the web page, and you can call methods (functions) on that object.

//Examples coming soon to a theatre near you.//

While we eagerly await Carl's examples, here is a very, very simple example.

The syntax for **Run** is as follows: RUN programNameExpr$ //- Run the specified program synchronously// RUN programNameExpr$, #handle //- Run the specified program synchronously and assign it as an object to #handle//

The second version allows more control. It allows you to call functions contained in the program being run. Note that you cannot call subs or gosubs in the running program.

programNameExpr$ must be a program you've saved in the same directory as the main program.


 * 1) handle is an object handle you are assigning to the running program.

After you call a function in the program run with **Run** you must render the #handle.

Here is a very simple example. It creates a CSS style function called **DisplayBanner** which can be called from other programs. This method allows you to create a library of CSS definitions and call them easily from other programs. The CSS code does not clutter the other programs, and it only needs to be written once to be used in multiple programs.

Open a new project in Run BASIC and copy the following code into the editing window. Save it with the name CSSDisplay.

code format="vbnet" gosub [SetCSS] html " " wait

Function DisplayBanner( text$) cls div Banner print text$ end div end function

[SetCSS] CSSID #Banner, "{   Width:600px;    Height:60px;    Background-Color:#FFFFCC;    margin:0px auto;    text-align:center;    padding:15px;    border:1px dashed #333;    Font-Family:Verdana;    font-weight:bold;    Font-Size:24px;    Color:#FF3333;    }" return code

Here is a very simple program that runs the CSSDisplay program and calls the function **DisplayBanner** from within that program.

code format="vbnet" 'run CSSDisplay, assign object handle #d run "CSSDisplay", #d

'call a function in CSSDisplay program
 * 1) d DisplayBanner("Welcome!")

'render object #d onto page render #d code

Here is a more complicated program that runs the CSSDisplay program. It allows the user to type text for the banner, so the banner can be changed many times.

code format="vbnet" cls 'run CSSDisplay, assign object handle #d run "CSSDisplay", #d

'call a function in CSSDisplay program
 * 1) d DisplayBanner("Welcome!")

'render object #d onto page render #d

'link to allow user to add to display link #a, "Change Banner",[changeBanner] wait

[changeBanner] print input "Type banner text here."; bannerText$ cls print "Here's your banner!" print render #d link #a, "Add Banner",[addBanner] wait code
 * 1) d DisplayBanner(bannerText$)