Content deleted Content added
Line 26:
Programs in Zgrass were referred to as "macros", and stored as strings. Both of these oddities were deliberate, as Zgrass allowed any string to become a program. For instance, <code>MYBOX="BOX 0,0,100,100,2"</code> defines a string (no need for a $ as in BASIC) containing a snippet of Zgrass code. Simply typing <code>MYBOX</code> from that point on would run the command(s) inside. This feature can be used in place of the more traditional <code>[[GOSUB]]</code> command from BASIC, but has the added advantage of having a well defined name as opposed to an opaque line number. In addition the command remains a string, and can be manipulated at runtime with standard string operations.
Most BASIC [[interpreter (computer software)|interpreters]] of the era converted the input text into a ''[[Lexical analysis|tokenized]]'' version in which each of the commands was replaced by a single number (typically one [[byte]] long). This made the program run faster because it didn't have to continually decode the commands from the strings every time. Zgrass's use of string-based macros made this difficult, so they didn't bother with tokenization. Instead they included a [[compiler]] which could be used on any particular macro, speeding it up many times. Programs would often consist of a mix of compiled and uncompiled macros.
Line numbers were optional in Zgrass, and typically only appeared on lines that were the target of a <code>GOTO</code>. Most BASIC interpreters required line numbers for every line of code, but this was due to their use in the "line editor"–if you needed to edit ''that'' line, the only way to refer to it was by number. Zgrass used a more advanced full-screen editor that eliminated this need.<ref group=notes>As was the case for [[True BASIC]] and most dialects after that time.</ref> Zgrass allowed any string to act as a "line number", <code>GOTO 10</code> and <code>GOTO MARKER</code> were both valid. Zgrass also included nameless branches, using the <code>SKIP</code> instruction, which would move forward or back a given number of lines.
|