Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
GRASS (programming language)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Example== {{sxhl|2=basic|1=<nowiki/> SINCURVE=[PROMPT "WHAT IS THE OFFSET?" INPUT OFFSET x=-160 angle=0 POINT OFFSET+x,SIN(angle)*80,3 angle=angle+2 IF (x=x+1)<159,SKIP -2] }} This text creates a new macro called <code>SINCURVE</code> that can be called simply by typing <code>SINCURVE</code> into the command prompt, or from other macros or programs. SINCURVE uses two local variables, <var>x</var> and <var>angle</var>, as well as a global variable, <var>OFFSET</var>. The <code>PROMPT</code>/<code>INPUT</code> is a modification of the original BASIC <code>INPUT</code> which will not ask for the input if the user types it into the command line when calling the macro. In this case, typing <code>SINCURVE</code> will result in the prompt appearing and the program waiting for input, whereas typing <code>SINCURVE 30</code> will skip the prompt and OFFSET will automatically be assigned 30. This allows a single macro to be used both interactively and within a program as a function. <code>POINT</code> is an example of one of the many graphics commands included in the Zgrass language. <code>POINT</code> requires an X and Y location, as well as a color. In this example, the user supplied <code>OFFSET</code> moves the x position of the curve on the screen, while the Y position is supplied by the [[trigonometry|trig function]], suitably enlarged for display (in this case, 80 times). The color is supplied in the last input, and in this case is 3. The UV-1 used color registers, so 3 did not imply a particular color, but a color selected from the current palette. The <code>IF</code> is likewise notable. It places an increment, <code>(x=x+1)</code>, in front of the test, a feature not normally available in BASIC. In this case the IF is told to call <code>SKIP -2</code> if true, which will move back two lines and can be used in place of a <code>GOTO</code>, as there is no line number target.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)