BRUN (Very Basic Interpreter) written by yours truly.
Here is the entire instruction manual (41 lines but I think it is missing the array instruction).
. 000 BRUN Help B.txt for BRUN (B+=MGA) 2018-02-07
. (all lines here are print lines except the next which wont show on run)
. A word about words, a word is whatever island is isolated by the sea of spaces.
. To avoid punctuation, all lines start with keyword commands:
. =========================================================================================================== VARIABLES
. Number variables are set st n is first letter on line, variable name is next, and variable expression last.
. Use up to 250 "words" for variable and expression including previous number variables, operators: +-*/^%()<=>
. constants: e, pi, rnd trig functions (radians): cos(), sin(), tan(), atan(), conversion: rad(), deg()
. log(), exp(), operators using <, =, >, (and combinations) and, or, not need to be separated by spaces.
. example:
. i = i + 1 becomes >>>>> n i i+1
. angle = deg(atan(1.01) becomes > n angle deg(atan(1.01))
. A couple of calculator programs are in the samples files to try the math evaluator.
. =========================================================================================================== OUTPUT
. For printing text:
. . for print with line feed, , for print and tab, ; for print and stop
. rc row col - for locating next character cell for print or input place
. at x y text - for locating with graphic x, y pixel positions
. cls - to clear clutter
. variables in print text will be replaced by their values, so be careful using variable names in print text.
. When there is more than one parameter be careful not to use a space in a calculated row, col, x, y
. =========================================================================================================== INPUT
. syntax: ? is keyword, variable name, use 250 words for prompt.
. ? var prompt
. =========================================================================================================== EXECUTION FLOW
. mark lineLabel - sets line label in program
. go lineLabel - redirects flow to mark lineLabel
. sub subLabel - marks start of gosub routine
. gosub subLabel - redirects flow to sub routine
. return - signals exit back to call point of sub routine
. ( do not enter or exit a sub with go )
. wait - will pause the given amount of seconds
. end - will end program
. =========================================================================================================== LOOPING
. do - marks start of loop
. loop - marks the end of loop, required with do
. exit - commands exit from loop
. =========================================================================================================== BOOLEAN BLOCKS
. if - starts one and is followed by Boolean expression to evaluate
. else - optional, marks line to goto if Boolean evaluates false
. fi - marks end of Boolean block
You write the code up in your favorite WYSIWYG editor and save it with a name ending in B.txt.
Drag and drop the file onto BRUN.exe to run it, Drag and drop on Brun debug.exe to watch variables as progress through program lines.
Here is example program that solves (using an array, see get and put lines) the coconut problem found at JB forum presented by bluatrigro that does use an array:
' and 1 for the monkey problem B.txt adopted for BRUN v2 to test string new string array functions get and put
' and 1 for the monkey problem.bas for JB 2.0 b 2018-02-11
n start 100
. i (bluatigro) fount this puzle in a book:
. there are 5 person's + 1 monkey
. they shipwrek on a Island
. the fisrst day they colect kokonut's
.
. day 1:"
. I (bplus) am starting with a number of coconuts.
n cc start
dim pile(5) this is why we need string array! for 5 piles
. Say the coconuts collected by the people is start .
.
. in the night happens this:
. (each) person goes to the pile
. divides it in 5 hides 1/5
. and gives 1 to the monkey
.
. I (bplus) am paying the monkey first.
. I (bplus) am not cutting any coconuts into parts of coconuts.
.
. So Coconut inventory after first night:
do
n persn persn + 1
if persn > 5
exit
fi
n cc cc - 1
n monk monk + 1
put piel persn int(cc/5)
n cc cc - int(cc/5)
get p piel persn
. For person persn , their pile is p
loop
. and monkey has monk
.
. day 2"
. the 2e day"
. thay divide the remaining pile in 5"
. and give 1 to the monkey"
. now calc the size of every pile"
.
. Coconuts starting day 2, before final divvy is cc
n cc cc - 1
n monk monk + 1
n divee int(cc/5)
. After monkey gets one more coconut the divvy is divee
.
n persn 1
do
get p piel persn
n p p + divee
put piel persn p
n persn persn +1
if persn > 5
exit
fi
loop
n Remain start
n persn 1
do
get p piel persn
. For person persn , their pile is p
n Remain Remain - p
n persn persn + 1
if persn > 5
exit
fi
loop
. The monkey has monk coconuts.
n Remain Remain - monk
.
. Coconuts remaining are Remain for the monkey who programmed this inventory.
Unlike Nano* written in 100 lines that needed SmallBASIC to Interpret, BRUN is a stand alone exe written in QB64.
PS Oh it looks like I used INT and DIM also, sorry it's been months since I looked at this.
Confirm I do have an INT function, BTW everything command wise is lower case.
Ha! I do not have DIM because IT IS NOT REQUIRED! how nice for beginners, eh?
BRUN ignores everything in a line that does not start with a keyword command, thus no crash for DIM line.
And the ' for comments is completely optional.
I am using a space as the only delimiter between parameters, so no string processing in this baby.
Don't bother formating with multiple spaces either because printed lines are stripped of extra spaces.
Use rc for row, col locating for print = (.,;) or input =(?), also there is cp for center alignment of print job.
Characters are 8x16 for cell.
Nano was contest winner:
http://retrogamecoding.org/board/index.php?topic=584.0before I made it a standalone with arrays and regular variable names instead of 26 letters.