What follows is not a mathematically rigorous description of UniVerse Basic syntax, which I was interested to discover cannot be found even in the VMark's documentation. Such descriptions are useful and even necessary in the punctuation-ridden world of C and Pascal, but would be overkill here. This more informal list of rules, though, should get you through most programs.
Your program must end with an END
statement. END
is also used to close blocks of code (more of this later), so if the compiler message Final END statment missing
appears, while it is possible that you have forgotten this, it is much more likely that you've failed to close a block of code within the program, and so the final END
statement is being pressed into service closing a block which should have been closed earlier in the code.
Example: END
UniVerse Basic statements must be written in upper case.
Example:
STOP
The three statements REM
(short for 'remark'), *
and !
, are all comment statements, and anything following them on the same line is ignored by the compiler.
Example:
* This is a comment
Sadly, Basic statements may not span more than one line: not even comments. You can, though, put more than one statement on a line by separating them with semi-colons: though I would only recommend this for 'end of line' comments.
Example:
STOP ; * Stop here
A semi colon appearing after a comment statment is considered part of that comment, not a statement separator.
Example:
* This line doesn't print anything ; PRINT 'Hello'
While variable names may be written in either case, and are not case sensitive, I strongly recommend you follow the almost universal (no pun intended) practice of writing them in upper case, and separating the words they contain with dots. Lower case variable names may even be mistaken for a comment or literal string, these being the only places lower case normally appears in UniVerse Basic.
Example:
PRINT INVOICE.VALUE
You must enclose string constants between a pair of single quotes, double quotes, or (unusually but sometimes usefully) backslashes. My own policy is to use single quotes by default, double quotes where the string to enclose contains single quotes, and backslashes where it contains single and double quotes.
Examples:
PRINT 'The Gazette'
PRINT "The Angler's Gazette"
PRINT \The "Angler's Gazette" magazine\
Numbers may be written without quotes. Positive numbers may have or omit a leading +
(I would recommend you omit it lest someone thinks you omitted an operand in what was meant to be an addition, so odd does it look), but negative numbers must naturally carry a leading -
. Decimal points may be used as usual.
Examples:
PRINT 123.45
PRINT +123.45 ; * (looks odd, huh?)
PRINT -123.45
Very big and very small numbers may be easier to represent in scientific notiation. Write a number greater than or equal to 1 and less than 10, and follow it by an E
followed by the number places to shift the decimal point (negative numbers shift it to the left, making the number smaller than 1).
Examples:
PRINT 2E5 ; * Prints 200000
PRINT 2E-3 ; * Prints 0.003