posted May 16, 2002 08:40 PM
OBFUSCATED BASIC???Here's a little toy to play with...
Here's the code, save as W.BAS and compile...
'WFD Mini Language Interpreter (c)2002 William F. Davis ALL RIGHTS RESERVED
'For non-commercial use only. Use only at your own risk! Blaw Blaw Blaw Etc.
$HUGE'We really need this because of the huge applications that are created!
$STRING 32'After many pages of concatenation code, you really need this too!
DEFINT a-z
IM p$(5000),v$(-1:255):RANDOMIZE TIMER:OPEN"i",1,COMMAND$'OK Go!
DO UNTIL EOF(1):m=m+1:LINE INPUT#1,t$
$(m)=TRIM$(t$):LOOP:close#1'Now Run!!
0:i=i+1:b$=p$(i):x$=MID$(b$,3):y$=MID$(b$,5):z$=MID$(b$,7):IF i>m THEN END'Q
k$=UCASE$(LEFT$(b$,1)):x=ascii(x$):y=ascii(y$):z=ascii(z$):v$(95)=" "'*i,.,i
v$(-1)="":IF"P"=k$THEN IF x=34THEN ?MID$(x$,2);ELSE ?v$(x);v$(y);v$(z);'.,iI
IF"C"=k$THEN CLS ELSE IF"Q"=k$THEN END ELSE IF"I"=k$THEN LINE INPUT;"";v$(x)
IF"D"=k$THEN v$(x)=TRIM$(STR$(INT(RND*6)+1))ELSE IF"B"=k$ THEN BEEP 'Tricks?
IF"J"=k$AND v$(x)=v$(y)THEN i=0
O:i=i+1:LOOP UNTIL p$(i)=z$ OR i>m:GOTO 0'!
IF"L"=k$THEN IF y=34THEN v$(x)=MID$(y$,2)ELSE v$(x)=v$(y)+v$(z) 'Compiles on
IF("I"=k$OR"P"=k$)AND MID$(b$,2,1)<>";"THEN ?:GOTO 0:ELSE 0 ' PowerBASIC 3.5
'Go to full screen DOS box and TYPE W.BAS. The whole thing's in the display!...Compile above on PBDOS 3.5
Here's a little test program for the above interpreter.
Save as DICE.W and run on above interpreter...
'DICE.W
'A DICE ROLL DEMO
'for the WFD Mini Language Interpreter
'Copyright (c)2002 by William F. Davis
'ALL RIGHTS RESERVED
'Provided AS IS, use only at your own risk!
'(...if anyone cares...)
L q="q
L Q="Q
L s=_+_
L s=s+s
L s=s+s
L s=s+_
L [="[
L ]="]
:top
C
P " =======>>>> Roll the Dice ! <<<<=======
D x
D y
L r=s+s
L r=r+[
L r=r+x
L r=r+]
L r=r+s
L r=r+[
L r=r+y
L r=r+]
P r
P " --- Press ENTER to roll, or enter Q to quit! ---
I k
J k=q :quit
J k=Q :quit
J x=x :top
:quit
C
P "Bye!
Q
'end of DICE.W
Here's the Mini Interpreter's User's Manual...
----------------------------------------------------------------
The WFD Mini Language Interpreter Syntax: Page 1 of 1
----------------------------------------------------------------
B (beep sound)
C (clear screen)
D x (random digit 1 to 6, for "games")
I x (keyboard line entry to var)
I;x (input without crlf)
J x=y :label (jump only if both vars match)
J x=x :label (jump without condition)
L x="string (assign string to var)
L x=y (assign var to var)
L x=y+z (assign var concatenation to var)
P "string (print string)
P x y z (print three vars)
P x y (print two vars)
P x (print one var)
P (print crlf only)
P; ... (any print without crlf uses semicolon)
Q (quits program)
A-Z, a-z, 0-9 (variable identifiers of dynamic string type.
alphabet identifiers are case sensitive)
_ (underbar, constant containing a single space)
'Remarks (places comments in code, must be on its own
line)
:label (marks line to jump to, following line is
executed. case sensitive)
"string (any string after the quote mark. Must be last
item on that line. Allowed only where shown
above. trailing spaces are stripped away)
----------------------------------------------------------------
Notes:
* Make sure all spacing, if any, are as shown above.
* Indent at left of code line with spaces only.
* Use a normal text editor to create code.
* Run your program code from DOS as... W yourfile.ext <enter>
* From Windows, drag your program onto the W.EXE file icon to
open a DOS box and execute your program.
----------------------------------------------------------------
Have Fun! 
------------------
William F. Davis
PowerBASIC User
[This message has been edited by William Davis (edited May 18, 2002).]
* UUB [code] Tags added by Adminstrator