Sprak syntax: Difference between revisions
From wikinotes
(→Print) |
|||
Line 72: | Line 72: | ||
= Functions = | = Functions = | ||
<blockquote> | <blockquote> | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="bash"> | ||
# Define Function | # Define Function | ||
string MyFunction( string var ) | string MyFunction( string var ) | ||
Line 83: | Line 83: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="bash"> | ||
# Test if function exists on platform | # Test if function exists on platform | ||
if HasFunction("Print") | if HasFunction("Print") | ||
Line 90: | Line 90: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Functions --> | </blockquote><!-- Functions --> | ||
= Sleep = | |||
<blockquote> | |||
<syntaxhighlight lang="bash"> | |||
Sleep(1) # Sleep time in seconds | |||
</syntaxhighlight> | |||
</blockquote><!-- Sleep --> |
Revision as of 03:14, 9 January 2023
I/O
Print("something") # prints text 'something' Say("something") # prints, but out-loud (speech bubble?) var cmd = Input(">") # save user-input to variable
Variables
Assignment
var list = [false, true] # a list var myVar = 1.0 # ? automatically determine type?
Datatypes
number myNum = 1234 string myStr = "test" bool myBol = false array letters = "abcdefg" # define an array number letterCount = Count(letters) # number of items in array Random() # Random number
Object Types
you can determine Item types with the
GetType()
command.GetType(myVar) # type introspectionfloppy # Floppy Diskette key # Keys
Loops
# Iterate over variable loop x from 1 to 8 Print( x ) end # Loop indefinitely (accepting commands) loop var cmd = Input(") ") end
Conditionals
if varA == varB # Unconfirmed Print("Success") else if varA == varC Print("Alternative Success") End()
Functions
# Define Function string MyFunction( string var ) return var End() void MyFunction( string var ) Print("no return value") End()# Test if function exists on platform if HasFunction("Print") Print("Success") End()
Sleep
Sleep(1) # Sleep time in seconds