Difference between revisions of "The Script Programming Language/Primitive Procedures"

From SCI Wiki
Jump to navigationJump to search
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[The Original SCI Documentation]]<br />
 
[[The Original SCI Documentation]]<br />
 +
 +
<div align="center">
 +
Chapter:
 +
[[The Script Programming Language/Introduction|1]] |
 +
[[The Script Programming Language/Files|2]] |
 +
[[The Script Programming Language/Definitions|3]] |
 +
[[The Script Programming Language/Data Types and Variables|4]] |
 +
[[The Script Programming Language/Primitive Procedures|5]] |
 +
[[The Script Programming Language/Control Flow|6]] |
 +
[[The Script Programming Language/Procedures|7]] |
 +
[[The Script Programming Language/Using SC|8]] |
 +
[[The Script Programming Language/Index|Index]]
 +
</div><br />
  
 
<div align="center"><span style="font-size: 22pt">The Script Programming Language</span><br />
 
<div align="center"><span style="font-size: 22pt">The Script Programming Language</span><br />
Line 28: Line 41:
 
<blockquote>Evaluates to the remainder of e1 when divided by e2.</blockquote>
 
<blockquote>Evaluates to the remainder of e1 when divided by e2.</blockquote>
 
   
 
   
<br /><div id="(<< e1 e2)"></div>'''(<< e1 e2)'''
+
<br /><div id="(<nowiki><<</nowiki> e1 e2)"></div>'''(<nowiki><<</nowiki> e1 e2)'''
<blockquote>Evaluates to  e1 << e2  where the << operation shifts its left hand side left by the number of bits specified by its right hand side. (As in C).</blockquote>
+
<blockquote>Evaluates to  e1 << e2  where the << operation shifts its left hand side left by the number of bits specified by its right hand side. (As in C).</blockquote>
 
   
 
   
<br /><div id="(>> e1 e2)"></div>'''(>> e1 e2)'''
+
<br /><div id="(<nowiki>>></nowiki> e1 e2)"></div>'''(<nowiki>>></nowiki> e1 e2)'''
 
<blockquote>Evaluates to  e1 >> e2  as in << except a right shift.</blockquote>
 
<blockquote>Evaluates to  e1 >> e2  as in << except a right shift.</blockquote>
 
   
 
   
Line 53: Line 66:
 
These procedures are always guaranteed to evaluate their parameters left to right and to terminate the moment the truth value of the expression is determined.  If the truth value of the boolean is determined before an expression is reached, the expression is never evaluated.  
 
These procedures are always guaranteed to evaluate their parameters left to right and to terminate the moment the truth value of the expression is determined.  If the truth value of the boolean is determined before an expression is reached, the expression is never evaluated.  
  
 +
<br /><div id="(<nowiki>></nowiki> e1 e2 [e3...])"></div>'''(> e1 e2 [e3...])'''
 +
<blockquote>Evaluates to TRUE if e1 > e2 [> e3 ...], else FALSE.</blockquote>
  
====<br /> (> e1 e2 [e3...]) ====
+
<br /><div id="(<nowiki>></nowiki>= e1 e2 [e3...])"></div>'''(>= e1 e2 [e3...])'''
<blockquote>Evaluates to TRUE if e1 > e2 [> e3 ...], else FALSE.</blockquote>
 
 
====<br /> (>= e1 e2 [e3...]) ====
 
 
<blockquote>Evaluates to TRUE if e1 >= e2 [>= e3 ...], else FALSE.</blockquote>
 
<blockquote>Evaluates to TRUE if e1 >= e2 [>= e3 ...], else FALSE.</blockquote>
+
 
====<br /> (< e1 e2 [e3...]) ====
+
<br /><div id="(<nowiki><</nowiki> e1 e2 [e3...])"></div>'''(< e1 e2 [e3...])'''
 
<blockquote>Evaluates to TRUE if e1 < e2 [< e3 ...], else FALSE.</blockquote>
 
<blockquote>Evaluates to TRUE if e1 < e2 [< e3 ...], else FALSE.</blockquote>
+
 
====<br /> (<= e1 e2 [e3...]) ====
+
<br /><div id="(<nowiki><</nowiki>= e1 e2 [e3...])"></div>'''(<= e1 e2 [e3...])'''
 
<blockquote>Evaluates to TRUE if e1 <= e2 [<= e3 ...], else FALSE.</blockquote>
 
<blockquote>Evaluates to TRUE if e1 <= e2 [<= e3 ...], else FALSE.</blockquote>
+
 
====<br /> (== e1 e2 [e3...]) ====
+
<br /><div id="(== e1 e2 [e3...])"></div>'''(== e1 e2 [e3...])'''
 
<blockquote>Evaluates to TRUE if e1 == e2 [== e3 ...], else FALSE.</blockquote>
 
<blockquote>Evaluates to TRUE if e1 == e2 [== e3 ...], else FALSE.</blockquote>
+
 
====<br /> (!= e1 e2 [e3...]) ====
+
<br /><div id="(!= e1 e2 [e3...])"></div>'''(!= e1 e2 [e3...])'''
 
<blockquote>Evaluates to TRUE if e1 != e1 [!= e3 ...], else FALSE.</blockquote>
 
<blockquote>Evaluates to TRUE if e1 != e1 [!= e3 ...], else FALSE.</blockquote>
+
 
====<br /> (and e1 e2 [e3...]) ====
+
<br /><div id="(and e1 e2 [e3...])"></div>'''(and e1 e2 [e3...])'''
 
<blockquote>Evaluates to TRUE if all the expressions are non-zero, else FALSE.</blockquote>
 
<blockquote>Evaluates to TRUE if all the expressions are non-zero, else FALSE.</blockquote>
+
 
====<br /> (or e1 e2 [e3...]) ====
+
<br /><div id="(or e1 e2 [e3...])"></div>'''(or e1 e2 [e3...])'''
 
<blockquote>Evaluates to TRUE if any of the expressions are non-zero, else FALSE.</blockquote>
 
<blockquote>Evaluates to TRUE if any of the expressions are non-zero, else FALSE.</blockquote>
+
 
====<br /> (not e) ====
+
<br /><div id="(not e)"></div>'''(not e)'''
 
<blockquote>Evaluates to TRUE if the expression is zero, else FALSE.</blockquote>
 
<blockquote>Evaluates to TRUE if the expression is zero, else FALSE.</blockquote>
  
Line 85: Line 97:
 
All assignment procedures store a value in a variable and return that value as the result of the assignment. In the following, v is a variable and e an expression.  
 
All assignment procedures store a value in a variable and return that value as the result of the assignment. In the following, v is a variable and e an expression.  
  
====<br /> (= v e) ====
+
<br /><div id="(= v e)"></div>'''(= v e)'''
 
<blockquote>v = e</blockquote>
 
<blockquote>v = e</blockquote>
  
====<br /> (+= v e) ====
+
<br /><div id="(+= v e)"></div>'''(+= v e)'''
 
<blockquote>v = v + e</blockquote>
 
<blockquote>v = v + e</blockquote>
  
====<br /> (-= v e) ====
+
<br /><div id="(-= v e)"></div>'''(-= v e)'''
 
<blockquote>v = v - e</blockquote>
 
<blockquote>v = v - e</blockquote>
  
====<br /> (*= v e) ====
+
<br /><div id="(*= v e)"></div>'''(*= v e)'''
 
<blockquote>v = v * e</blockquote>
 
<blockquote>v = v * e</blockquote>
  
====<br /> (/= v e) ====
+
<br /><div id="(/= v e)"></div>'''(/= v e)'''
 
<blockquote>v = v / e</blockquote>
 
<blockquote>v = v / e</blockquote>
  
====<br /> (|= v e) ====
+
<br /><div id="(|= v e)"></div>'''(|= v e)'''
 
<blockquote>v = v | e</blockquote>
 
<blockquote>v = v | e</blockquote>
  
====<br /> (&= v e) ====
+
<br /><div id="(&= v e)"></div>'''(&= v e)'''
 
<blockquote>v = v & e</blockquote>
 
<blockquote>v = v & e</blockquote>
  
====<br /> (^= v e) ====
+
<br /><div id="(^= v e)"></div>'''(^= v e)'''
 
<blockquote>v = v ^ e</blockquote>
 
<blockquote>v = v ^ e</blockquote>
  
====<br /> (>>= v e) ====
+
<br /><div id="(<nowiki>>></nowiki>= v e)"></div>'''(>>= v e)'''
 
<blockquote>v = v >> e</blockquote>
 
<blockquote>v = v >> e</blockquote>
  
====<br /> (<<= v e) ====
+
<br /><div id="(<nowiki><<</nowiki>= v e)"></div>'''(<<= v e)'''
 
<blockquote>v = v << e</blockquote>
 
<blockquote>v = v << e</blockquote>
  
====<br /> (++ v) ====
+
<br /><div id="(++ v)"></div>'''(++ v)'''
 
<blockquote>v = v + 1</blockquote>
 
<blockquote>v = v + 1</blockquote>
  
====<br /> (-- v) ====
+
<br /><div id="(-- v)"></div>'''(-- v)'''
 
<blockquote>v = v - 1</blockquote>
 
<blockquote>v = v - 1</blockquote>
  
Line 129: Line 141:
  
 
[[The Script Programming Language | Table of Contents]]
 
[[The Script Programming Language | Table of Contents]]
 
&nbsp;
 
  
 
<span style="float: left">[[The Script Programming Language/Data Types and Variables | &lt; Previous: Data Types and Variables]]</span><span style="float: right">[[The Script Programming Language/Control Flow | Next: Control Flow &gt;]]</span>
 
<span style="float: left">[[The Script Programming Language/Data Types and Variables | &lt; Previous: Data Types and Variables]]</span><span style="float: right">[[The Script Programming Language/Control Flow | Next: Control Flow &gt;]]</span>
Line 137: Line 147:
  
 
[[Category:SCI Documentation]]
 
[[Category:SCI Documentation]]
 +
[[Category:Scripting]]
 +
[[Category:Procedures]]

Latest revision as of 20:14, 2 December 2015

The Original SCI Documentation

Chapter: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Index


The Script Programming Language

Primitive Procedures

Author: Jeff Stephenson

 


Primitive Procedures


Arithmetic primitives:

In the following, e1, e2, ... are arbitrary expressions.


(+ e1 e2 [e3...])

Evaluates to e1 + e2 [+ e3 ...]


(* e1 e2 [e3...])

Evaluates to e1 * e2 [* e3 ...]


(- e1 e2)

Evaluates to e1 - e2


(/ e1 e2)

Evaluates to e1 / e2


(mod e1 e2)

Evaluates to the remainder of e1 when divided by e2.


(<< e1 e2)

Evaluates to e1 << e2 where the << operation shifts its left hand side left by the number of bits specified by its right hand side. (As in C).


(>> e1 e2)

Evaluates to e1 >> e2 as in << except a right shift.


(^ e1 e2 [e3 ...])

Evaluates to e1 ^ e2 [^ e3 ^ ...] where '^' is the bitwise exclusive-or operator.


(& e1 e2 [e3 ...])

Evaluates to e1 & e2 [& e3 & ...] where '&' is the bitwise and operator.


(| e1 e2 [e3])

Evaluates to e1 | e2 [| e3 | ...] where '|' is the bitwise or operator.


(! e1)

Evaluates to TRUE if e1 == 0, else FALSE.


(~ e1)

Evaluates to the bit-wise not of e1, i.e. all 1 bits are changed to 0 and all 0 bits are changed to 1.


Boolean primitives:

These procedures are always guaranteed to evaluate their parameters left to right and to terminate the moment the truth value of the expression is determined. If the truth value of the boolean is determined before an expression is reached, the expression is never evaluated.


(> e1 e2 [e3...])

Evaluates to TRUE if e1 > e2 [> e3 ...], else FALSE.


(>= e1 e2 [e3...])

Evaluates to TRUE if e1 >= e2 [>= e3 ...], else FALSE.


(< e1 e2 [e3...])

Evaluates to TRUE if e1 < e2 [< e3 ...], else FALSE.


(<= e1 e2 [e3...])

Evaluates to TRUE if e1 <= e2 [<= e3 ...], else FALSE.


(== e1 e2 [e3...])

Evaluates to TRUE if e1 == e2 [== e3 ...], else FALSE.


(!= e1 e2 [e3...])

Evaluates to TRUE if e1 != e1 [!= e3 ...], else FALSE.


(and e1 e2 [e3...])

Evaluates to TRUE if all the expressions are non-zero, else FALSE.


(or e1 e2 [e3...])

Evaluates to TRUE if any of the expressions are non-zero, else FALSE.


(not e)

Evaluates to TRUE if the expression is zero, else FALSE.


Assignment primitives:

All assignment procedures store a value in a variable and return that value as the result of the assignment. In the following, v is a variable and e an expression.


(= v e)

v = e


(+= v e)

v = v + e


(-= v e)

v = v - e


(*= v e)

v = v * e


(/= v e)

v = v / e


(|= v e)

v = v | e


(&= v e)

v = v & e


(^= v e)

v = v ^ e


(>>= v e)

v = v >> e


(<<= v e)

v = v << e


(++ v)

v = v + 1


(-- v)

v = v - 1

 

Notes


 

Table of Contents

< Previous: Data Types and Variables Next: Control Flow >