plainblack.com
Username Password
search
Bookmark and Share

BASIC

This macro brings all the power of the 1980's BASIC programming language to your WebGUI site!

 

Syntax

DATA
  • DATA 1,2,"HI". These will be read sequentially by READ statements. Note that currently all string constants must be quoted.
DEF
  • DEF FNA(X)= INT(X + .5).
DIM
  • DIM A(20), B(10,10). Arrays default to size 10 (or actually 11 since they start at zero.)
END
  • END.
FOR
  • FOR I = 1 TO 10 STEP 3. STEP defaults to 1 if not given, and may be negative. (For loops are always implemented at least once.)
GOTO
  • GOTO 30. Note that GOTO 30+(X*3) is also supported.
GOSUB
  • GOSUB 10+X. Gosub is just like GOTO, except that when the programgets to a RETURN statement, it will come back to the statement justafter the GOSUB.
IF
  • IF X > Y THEN 30 ELSE X = X + 1. ELSE is not required. In a THENor ELSE, a lone number means GOTO that number (also known as an impliedGOTO).
LET
  • LET X=4. The word "LET" isn't required; i.e. X=4 is just like LET X=4.
NEXT
  • NEXT I. Increment I by STEP, test against its limit, go back to theFOR statement if it's not over (or under, for a descending loop) itslimit.
ON
  • ON X-3 GOSUB 10,20. This is equivalent to: IF X-3 = 1 THEN GOSUB 10 IF X-3 = 2 THEN GOSUB 20
  • ON ... GOTO is also allowed.
PRINT
  • PRINT FOO; BAR$, 6*BLAH. semicolon means no space (or one spaceafter printing numbers!), comma is like a 14-character tab (or \n pastcolumn 56). Print \n after the last expression unless there's asemicolon after it.
READ
  • READ A, B(I), C$. Reads data from DATA statements into variables
REM
  • REM WHATEVER. Anything after the REM is ignored (including colons and succeeding statements!)
RETURN
  • RETURN. Return to the statement after the last GOSUB.

 

Example Program

10 FOR J=1 TO 10
20 PRINT "Hello World!<br />"
30 NEXT J
 

Installation

You're going to need the Language::Basic perl module installed on your server. 

perl -MCPAN -e shell
install Language::Basic
exit

Then copy Basic.pm into your lib/WebGUI/Macro folder, add it to your WebGUI config file, and restart your web server. 

 

Usage

To use this module simply create a Snippet asset with your program in it. Then use the URL of the snippet in combination with the Basic macro to execute your program:

^Basic(programs/helloworld.bas);

 

Caveats

Do not do anything that would cause a loop to not exit. The macro currently has no way to detect infinite loops and therefore the only way to kill a program in an infinite loop is to restart your web server. For this reason I recommend testing your program using a command line interpreter first.  And it just so happens that I've included a command line interpreter as an attachment to this post. To use it just type:

perl basic.pl programname.bas

 

Versions

1.0.0 - Initial release

1.0.1 - Bugfix in output redirect thanks to Martin Kamerbeek 

 

System RequirementsPlease be advised: this contribution was tested with something older than WebGUI 7.5. When this contribution was uploaded there was no field for the author to fill out regarding it's requirements.
Comments
3ehab: "
Is this still valid for newer versions of WebGUI.

This could be a real killer if there was a way to pass data from and to WebGUI this could be a full scripting language for WebGUI to fill in all the simple where writing a macro is just too much. 

Ehab Heikal

 www.elmotaheda.com , www.mashy.com

Quote: An eye for an Eye only helps make the whole world blind

Gandhi
"
Downloadbasic_pl.txt basic_pl.txt
Basic.pm Basic.pm
LinksNo Support Offered
Statistics Downloads: 1038
Views: 3153
Rating: 3
Updated: 9/14/2007
Keywords acme
NavigationBack to the Bazaar
© 2018 Plain Black Corporation | All Rights Reserved