MFBasic, Basic Interpeter

For my Dare to Dream Different Contest application I created a Basic compiler. I think it can be usefull on it’s own so I’m releasing the sourcecode on CodePlex.
It’s released with a GPLv2 licence meaning that you may use the code in your projects (also commercial) but you have to release the code of that creation. If you want to use MFBasic in a closed source project you can contact me trough the contact form.
Some of the supported features:
- WHILE -> WEND
- IF, ELSE, ENDIF
- FOR -> NEXT, STEP
- Line numbers of QBasic like labels
- Custom variable names (Variables ending with $ are string variables others are considered floating point)
- Easy to create custom functions
- Basic sourcecode is precompiled to run faster
It’s in alpha state right now.. I’m currently working on a State storage to store and restore current running state. Also I will add more functions and hopefully implement arrays
For more information and downloads visit the MFBasic codeplex website: http://mfbasic.codeplex.com/
Here is a demo MFBasic Application:
‘ This program showcases the use of MFBasic
‘ Sample string variable
text$ = "Hallo world!"
‘ Move to sub
GOSUB SUB
‘ Call routines and print output of numeric function
RANDOMIZE
PRINT INT(RND()*1000*10)
‘ Create new floating point variable from function result
fnumber = CINT(9.8)
‘ For, Next loop
FOR i = 1 TO 10
IF i <= 5 THEN
GOSUB sub2
ELSE
PRINT i*fnumber
ENDIF
NEXT i
‘ Text should be aaaa else a program error occourd
IF (text$="aaaaa") THEN PRINT "Ok!"
‘ End of this demo program
PRINT "End Of Program"
PRINT text$
END
‘ Subroutine 1
‘ Clear text variable
SUB: PRINT "Subroutine"
text$ = ""
RETURN
‘ Subroutine 2
‘ Add a to text variable
sub2: PRINT "Five"
text$ = text$ + "a"
RETURN
Recent Comments