GRASS (programming language): Difference between revisions

Content deleted Content added
more specific
Line 36:
Zgrass included three priorities (called ''levels'') that allowed macros to be run normally, or in "foreground" or "background" levels. This added a simple form of [[computer multitasking|multitasking]] which was tremendously useful in an animation-oriented language. Game authors could place joystick-reading routines in a macro set to run in the background, and then the joystick would be read automatically whenever the current drawing macro completed. Functions placed in the foreground ran before either, and was often used for timers and other "low latency" needs. Zgrass included a <code>TIMEOUT</code> function that would call macros on a timed basis, making the implementation of timers very easy.
 
Zgrass also included a series of commands that "covered" CP/M, which allowed the disk to be accessed without exiting to the command prompt. You could easily save out macros to named files, and load them in the same way, allowing you to construct programs by loading up various macros from the disk into one large program. The commands also automatically made a backup copy of every save. Similar features were supported for [[cassetteCompact tapeCassette (data)|Compact Cassette]] storage, but oddly the syntax was not parallel: disk commands were D-something, like <code>DPUT</code>, but tape commands were not T-something, like <code>TPUT</code>, but rather something-TAPE, like <code>PUTTAPE</code>.
 
With programs constructed from randomly selected modules, Zgrass needed to have better control over its variables than BASIC. In BASIC all variables are "global", so if two subroutines both use the variable <code>i</code> (very common) then they could set each other's values, leading to hard-to-debug problems. Under Zgrass a programmer loading up two modules could easily find that both used i as a loop counter, which could cause problems. To address this issue, Zgrass considered variables named with [[lowercase]] letters to be local only to that macro. Oddly, the examples provided with the language do not make widespread use of this feature, potentially confusing new programmers who might not be aware the feature exists.