User Tools

Site Tools


xrpl:full_doc_of_base_commands

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
xrpl:full_doc_of_base_commands [2019/03/07 01:57] Karsten75xrpl:full_doc_of_base_commands [2021/03/24 15:18] (current) – removed Karsten75
Line 1: Line 1:
- 
----- 
- 
-====== abs ====== 
- 
-abs(%%<-%%var) %%->%%absvar 
- 
-===== Description ===== 
- 
-Calculates the absolute value of the item and pushes the result on the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-trace(abs(-1)) #prints '1'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== acos ====== 
- 
-acos(-1) %%->%%PiValue 
- 
-===== Description ===== 
- 
-Calculates the arccosine of the input, returns the result in radians. 
- 
-===== Examples ===== 
- 
-<code> 
-trace(acos(-1)) #prints PI  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== add ====== 
- 
-2 add (3) %%->%%five 
- 
-===== Description ===== 
- 
-Adds two arguments together and pushes the result on the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-trace(add(21 21)) #prints 42  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== and ====== 
- 
-%%<-%%bool1 and (%%<-%%bool2) %%->%%boolResult 
- 
-===== Description ===== 
- 
-Pops two items from the stack and treats them as TRUE/FALSE (0/1 or Boolean) values. If they are both TRUE, 1 is pushed to the stack. Otherwise, 0 is pushed to the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-if (1 and (true))  
-    trace("1 and true are both true" 
-endif  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== AppendStackToList ====== 
- 
-AppendStackToList 
- 
-===== Description ===== 
- 
-Adds all values on the stack to the end of a list. The order of the values will be reversed. 
- 
-Note that the stack will be empty after this call, so think before using it in functions. 
- 
-===== Examples ===== 
- 
-<code> 
-Split("1,2,3,4,5,6" ",") %%->%%list  
-Split("1,2,3,4,5,6" ",") %%<-%%list AppendStackToList  
-Trace(%%<-%%list)  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== AppendToList ====== 
- 
-AppendToList( %%<-%%list %%<-%%var) 
- 
-===== Description ===== 
- 
-Adds a value to the end of a list. 
- 
-===== Examples ===== 
- 
-<code> 
-Split("1,2,3,4,5,6" ",") %%->%%list  
-Split("1,2,3,4,5,6" ",") %%<-%%list AppendStackToList  
-do (GetListCount(%%<-%%list) 0) 
- Trace (%%<-%%list I GetListElement)  
-loop 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== approximately ====== 
- 
-approximately(%%<-%%angle1 %%<-%%angle2) 
- 
-===== Description ===== 
- 
-Takes two floats and returns True if they equal, regardless of floating point jitter. See http:%%//%%docs.unity3d.com/Documentation/ScriptReference/Mathf.Approximately.html 
- 
-===== Examples ===== 
- 
-<code> 
-if (approximately(1.000001 1))  
-    trace("1.000001 is approximately equal to 1" 
-endif  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== asfloat ====== 
- 
-asfloat (%%<-%%integer1) %%->%%float1 
- 
-===== Description ===== 
- 
-Converts an item on the stack to a floating point number and pushes it back onto the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-"1.23" asfloat %%->%%val  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== asin ====== 
- 
-asin(%%<-%%one) %%->%%halfPie 
- 
-===== Description ===== 
- 
-Calculates the arcsine of the input, returns result angle in radiants. 
- 
-===== Examples ===== 
- 
-<code> 
-trace(asin(1)) #prints PI/2  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== asint ====== 
- 
-asint (%%<-%%floatval) %%->%%intval 
- 
-===== Description ===== 
- 
-Converts an item on the stack to an integer, and pushes it back to the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-"42" asint %%->%%val  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== aslist ====== 
- 
-To be supplied 
- 
- 
----- 
- 
- 
----- 
- 
-====== asstring ====== 
- 
-To be supplied 
- 
- 
----- 
- 
- 
----- 
- 
-====== astable ====== 
- 
-To be supplied 
- 
- 
----- 
- 
- 
----- 
- 
-====== atan ====== 
- 
-atan(%%<-%%toTarget)) %%->%%targetRadians 
- 
-===== Description ===== 
- 
-Calculates the arctangent of the input, returns the angle in radians. 
- 
-===== Examples ===== 
- 
-<code> 
-trace(atan(1)) #prints PI/4  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== atan2 ====== 
- 
-atan2(%%<-%%targetZ %%<-%%targetX) %%->%%angleToTarget 
- 
-===== Description ===== 
- 
-Computes and returns the angle of the point y/x in radians. The return value is between positive pi and negative pi. Note that the first parameter to atan2 is always the z coordinate. 
- 
-===== Examples ===== 
- 
-<code> 
-trace(atan2(1 2)) #prints '0.463647609'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== avg2 ====== 
- 
-avg2(%%<-%%high %%<-%%low) %%->%%average 
- 
-===== Description ===== 
- 
-Computes the average of two numbers. 
- 
-===== Examples ===== 
- 
-<code> 
-40 %%->%%low 
-44 %%->%%high 
-avg2(%%<-%%high %%<-%%low) %%->%%avg2 
-trace(%%<-%%avg2)  #outputs 42 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== break ====== 
- 
-break 
- 
-===== Description ===== 
- 
-Immediately exits the body of a ‘while/repeat/endwhile’ block or a ‘do/loop’ block. 
- 
-===== Examples ===== 
- 
-<code> 
-do(5 0)  
-    if (I mod(2) eq0) #divide inner loop with modulo 2 and test if zero  
-        break  
-    endif  
-    trace(I)  
-loop  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== ceil ====== 
- 
-===== Description ===== 
- 
-Takes one number from the stack, rounds it up, and pushes that number back on the stack. ceil(%%<-%%number) %%->%%number 
- 
-===== Examples ===== 
- 
-<code> 
-trace(ceil(4.2)) #prints '5'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== ClearStack ====== 
- 
-ClearStack 
- 
-===== Description ===== 
- 
-Remove all items from the stack leaving it empty. 
- 
-===== Examples ===== 
- 
-<code> 
-1 2 3 ClearStack #Stack is now empty  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== ClearTraceLog ====== 
- 
-ClearTraceLog 
- 
-===== Description ===== 
- 
-Removes all messages from the debug window. 
- 
-===== Examples ===== 
- 
-<code> 
- 
-ClearTraceLog   
-"Fresh Message" Trace 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== Concat ====== 
- 
-Concat(“abc” “def”) %%->%%sixLetters 
- 
-===== Description ===== 
- 
-Takes the first two items from the stack and concatenates them. 
- 
-===== Examples ===== 
- 
-<code> 
-Trace(Concat("abc" "def")) # Prints "abcdef"  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== CopyList ====== 
- 
-CopyList (%%<-%%list1)%%->%%list2 
- 
-===== Description ===== 
- 
-Creates a copy of a list with the same contents. Note that if the list contains other lists, they will not be copied - for that you need [[[#deepcopylist|DeepCopyList]]]. See [[Copy vs Deep Copy]] for more info. 
- 
-===== Examples ===== 
- 
-<code> 
-Split("1,2,3,4,5,6" ",") %%->%%list  
-%%<-%%list CopyList %%->%%list2  
-SetListElement(%%<-%%list2 0 "banana" 
-Trace(%%<-%%list)  
-Trace(%%<-%%lis2)  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== cos ====== 
- 
-cos(%%<-%%angle) %%->%%cosAngleRadians 
- 
-===== Description ===== 
- 
-Calculates the cosine of the input angle in radians 
- 
-===== Examples ===== 
- 
-<code> 
-trace(cos(PI)) #prints '-1'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== CR ====== 
- 
-CR 
- 
-===== Description ===== 
- 
-Pushes a carriage return to the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-Trace( Concat (Concat("ABC" CR) "DEF"))  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== CreateList ====== 
- 
-CreateList %%->%%list 
- 
-===== Description ===== 
- 
-Creates an empty list. 
- 
-===== Examples ===== 
- 
-<code> 
-if (CreateList GetListCount eq0)  
-    Trace("And lo, the list was empty." 
-endif  
- 
-createlist %%->%%list 
-1 %%->%%list[0] 
-4 %%->%%list[1] 
-9 %%->%%list[2] 
-trace(%%<-%%list) 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== CreateListStartingSize ====== 
- 
-createliststartingsize (%%<-%%size) %%->%%list 
- 
-===== Description ===== 
- 
-Creates a list containing a specified number of null elements. 
- 
-===== Examples ===== 
- 
-<code> 
- 
-9 %%->%%nullSize 
-createliststartingsize (%%<-%%nullSize) %%->%%nullist 
-trace ( %%<-%%nullist) 
-</code> 
- 
----- 
- 
-====== CreateTable ====== 
- 
-createTable %%->%%table 
- 
-===== Description ===== 
- 
-Creates an empty table and pushes it to the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-createTable %%->%%table 
-1 %%->%%table{"Larry"} 
-4 %%->%%table{"Moe"} 
-9 %%->%%table{"Curly"} 
-trace(%%<-%%table) 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== Debug ====== 
- 
-debug 
- 
-===== Description ===== 
- 
-Debug peeks at the stack and then prints out the datatype of the top item on the stack followed by the value coerced into an int, float, and string. 
- 
-===== Examples ===== 
- 
-<code> 
-12 
-debug  
-trace (mul (4)) #yields  48 
-# output_log.txt will contain  
-#  INT 12 12 12 
- 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== DeepCopyList ====== 
- 
-DeepCopyList ( %%<-%%list) %%->%%listDeepCopy 
- 
-===== Description ===== 
- 
-Creates a copy of a list with the same contents. Unlike [[.:CopyList|CopyList]], if the copied list contains other lists, those lists will be copied as well (and if those lists contain other lists, even those will be copied, etc, etc). See [[Copy vs Deep Copy]] for more info. 
- 
-===== Examples ===== 
- 
-<code> 
-Split("A,B,C" ",") %%->%%listInner 
-Split("1,2,3,4,5,6" ",") %%->%%list 
-%%<-%%list %%<-%%listInner AppendToList 
-  
-%%<-%%list CopyList %%->%%listCopy 
-%%<-%%list DeepCopyList %%->%%listDeepCopy 
-SetListElement(%%<-%%listInner 0 "banana" 
-SetListElement(%%<-%%list 0 "orange" 
- 
-Trace(%%<-%%list)  
-Trace(%%<-%%listCopy)  
-Trace(%%<-%%listDeepCopy)  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== Deg2Rad ====== 
- 
-mul(Deg2Rad %%<-%%angle) 
- 
-===== Description ===== 
- 
-Pushes the constant to use in converting from degrees to radians to the stack. Multiply this value with a value expressed as degrees to obtain radians. 
- 
-===== Examples ===== 
- 
-<code> 
-trace(180 mul(Deg2Rad)) #prints PI  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== DISTANCE ====== 
- 
-distance(%%<-%%x %%<-%%z %%<-%%centerX %%<-%%centerZ) %%->%%dist 
- 
-===== Description ===== 
- 
-Returns the distance between two given pairs of coordinates. (Or two sets of number pairs on the coordinate plane) 
- 
-===== Examples ===== 
- 
-<code> 
-CurrentCoords 0 0 Distance %%->%%Distance #Find the distance between itself and 0,0 
-%%<-%%Distance Trace 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== div ====== 
- 
-%%<-%%num1 div( %%<-%%num2) %%->%%result 
- 
-===== Description ===== 
- 
-Divides the two arguments together and pushes the result on the stack. the output type (integer or float) depends on the input, except is the result is explicitly cast. See examples. 
- 
-===== Examples ===== 
- 
-<code> 
-trace(5 div(4)) #prints '1'. Both arguments are integers so division is integer division  
-trace(5 div(4.0)) #prints '1.2'. Handled as floating point division  
-trace(5 div(4 asfloat)) #prints '1.2'. Handled as floating point division  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== do ====== 
- 
-do(5 0) 
- 
-===== Description ===== 
- 
-The statements following the do, up to the loop statement, are executed repeatedly. Each iteration (loop), the initial value (Index) is incremented by one at the bottom of the loop and compared to Limit. When Index=Limit, execution will proceed at the first statement following Loop. Loops can be nested, but no more than 3 deep. See also: [[[#i|I]]], [[[#j|J]]] and [[[#k|K]]]. 
- 
-NOTE: Limit comes first, then the initial value (index). This means that the first number should usually be bigger than the second number. 
- 
-===== Examples ===== 
- 
-<code> 
- 
-# single loop  
-do(5 0)  
-   trace(I)  
-loop  
-#  Prints: 
-#  0 
-#  1 
-#  2 
-#  3 
-#  4 
- 
-Nested loops 
- 
-do(2 0)  
-    trace(I)  
-    Do (4 2) 
-        Trace2 (J I) 
-        Do (6 4) 
-            Trace3 (K J I ) 
-        loop 
-    loop 
-loop  
- 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== DQ ====== 
- 
-DQ 
- 
-===== Description ===== 
- 
-Pushes a double-quote (") to the stack. This is the only way to create a string containing this character as they are normally used to delineate strings. 
- 
-===== Examples ===== 
- 
-<code> 
- DQ "Hello!" DQ concat concat trace 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== dup ====== 
- 
-dup 
- 
-===== Description ===== 
- 
-Duplicates the item currently on the stack without removing the original item. 
- 
-===== Examples ===== 
- 
-<code> 
-trace2(42 dup) #prints '42 42'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== dup2 ====== 
- 
-dup2 
- 
-===== Description ===== 
- 
-Duplicates the top two items currently on the stack without removing the original pair. 
- 
-===== Examples ===== 
- 
-<code> 
-trace4(42 1 dup2) #prints '42 1 42 1'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== E ====== 
- 
-e 
- 
-===== Description ===== 
- 
-Pushes the value of Euler’s number (e) to the stack (2.71828…) 
- 
-===== Examples ===== 
- 
-<code> 
-trace(e) #prints 2.71828182845  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== else ====== 
- 
-else ## Description When an if statement evaluates to false, then the statements following the else, up to the endif, are executed instead. see[[[#if|if]]] 
- 
-===== Examples ===== 
- 
-<code> 
-if (%%<-%%var eq (1))  
-   #Do something  
-else  
-   #Do something else  
-endif  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== endif ====== 
- 
-===== Description ===== 
- 
-Delimits the scope of an if-else-statement. Instructions between the if and endif statement are conditionally executed, depending on the results of the if evaluation. see [[[#if|if]] 
- 
-===== Examples ===== 
- 
-<code> 
-if (%%<-%%var eq (1))  
-   #Do something  
-else  
-   #Do something else  
-endif  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== endonce ====== 
- 
-endonce 
- 
-===== Description ===== 
- 
-Ends a block defined by once. See [[[#once|once]]] 
- 
-===== Examples ===== 
- 
-<code> 
-once  
-    trace("42") #Only prints once  
-endonce  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== EndsWith ====== 
- 
-===== Description ===== 
- 
-Takes two strings from the stack and returns whether the first string ends with the second (case sensitive) 
- 
-===== Examples ===== 
- 
-<code> 
-if (EndsWith("Hello there" "there"))  
-    Trace("I went there" 
-endif  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== endwhile ====== 
- 
-===== Description ===== 
- 
-Returns execution to the ‘while’ statement. Note that endwhile is only executed, if ‘repeat’ evaluated to true. See [[[#while|while]]] and [[[#repeat|repeat]]] 
- 
-===== Examples ===== 
- 
-<code> 
-5 %%->%%y  
-while  
-    %%<-%%y gt(0)       #is y greater than zero?  
-repeat              #repeat this section of code  
-    trace(%%<-%%y)  
-    %%<-%%y sub(1) %%->%%y  #subtract 1 from y so we don't end in infinite loop  
-endwhile  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== eq ====== 
- 
-eq 
- 
-===== Description ===== 
- 
-Top two items are popped from the stack and compared for equality. 0 or 1 is pushed back to the stack where 1 indicates equal and 0 (zero) ndicates not equal 
- 
-the equal/not equal evaluation can also be performed with “true” (1) and false(0), respectively. 
- 
-===== Examples ===== 
- 
-<code> 
-if (1 eq (1))  
-    trace("1 is equal to 1" 
-endif  
- 
-#  alternate example  
- 
-1 dup eq  
-if true  
-  trace ("one is always one") 
-endif 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== eq0 ====== 
- 
-eq0 
- 
-===== Description ===== 
- 
-Top item is popped from the stack and Compared to 0. 0 (false) or 1 (true) is pushed back to the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-if (0 eq0)  
-    trace("0 is equal to 0" 
-endif  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== false ====== 
- 
-false 
- 
-===== Description ===== 
- 
-Pushes a 0 (false) nto the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-if (false)  
-    trace("false" 
-endif  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== floor ====== 
- 
-floor (%%<-%%num) %%->%%num 
- 
-===== Description ===== 
- 
-Takes one number from the stack, rounds it down, and pushes that number back on the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-trace(floor(4.2)) #prints '4'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== GetListCount ====== 
- 
-GetListCount(%%<-%%list) %%->%%listSize 
- 
-===== Description ===== 
- 
-Returns the number of entries in a list. 
- 
-===== Examples ===== 
- 
-<code> 
-Split("There are four words" " ") %%->%%list  
-Trace(GetListCount(%%<-%%list))  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== GetListElement ====== 
- 
-GetListElement (I) %%->%%element 
- 
-===== Description ===== 
- 
-Returns the value at the specified index of a list. Lists are indexed from zero. 
- 
-Note: If a list is stored in a variable, this can be abbreviated to %%<-%%list[%%<-%%index]. 
- 
-===== Examples ===== 
- 
-<code> 
-Split("1,2,3,4,5,6" ",") %%->%%list  
-6 0 do  
-    Trace (%%<-%%list I GetListElement)  #functionally equivalent 
-    Trace (%%<-%%list[I])                #functionally equivalent 
-loop  
-</code> 
- 
----- 
- 
-====== Gettableelement ====== 
- 
-To be supplied 
- 
- 
----- 
- 
- 
----- 
- 
- 
----- 
- 
-====== GetType ====== 
- 
-GetType (%%<-%%something) %%->%%typeOfSomething 
- 
-===== Description ===== 
- 
-Takes a value and returns a string of what type of value it is. Types: STRING INT FLOAT LIST NULL 
- 
-===== Examples ===== 
- 
-<code> 
-"Value" GetType %%->%%Type 
-%%<-%%Type trace #Would return STRING as the result  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== gt ====== 
- 
-5 GT (4) #true 
- 
-===== Description ===== 
- 
-The first item on the stack is compared to the second item on the stack. Both items are removed from the stack. If the first item is greater than the second, True (1) is pushed to the stack. If not, False (o) is pushed to the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-# Wrap notation 
-if (42 gt (1))  
-    trace("42 is greater than 1" 
-endif 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== gte ====== 
- 
-5 GTE (5) #true 
- 
-===== Description ===== 
- 
-The first item on the stack is compared to the second item on the stack. Both items are removed from the stack. If the first item is greater than or equal to the second, True (1) is pushed to the stack. If not, False (o) is pushed to the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-if (2 gte (2))  
-    trace("2 is greater than or equal to 2" 
-endif  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== HALFPI ====== 
- 
-HALFPI 
- 
-===== Description ===== 
- 
-Pushes the value of PI/2 to the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-trace(HALFPI) #prints '1.570796325'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== I ====== 
- 
-===== Description ===== 
- 
-Current loop index. Pushes the value of the current “do” loop onto the stack. Only use within loops. 
- 
-Note that I refers to the innermost loop. As loops are nested, I will continue to reference the innermost of the nested loops. See [[[#j|J]]] [[[#k|k]]] for other loop indexes. See [[[#do|do]]] and [[[#loop|loop]]] 
- 
-===== Examples ===== 
- 
-<code> 
-do(2 0)  
-    trace(I)  
-    Do (4 2) 
-        Trace2 (J I) 
-        Do (6 4) 
-            Trace3 (K J I ) 
-        loop 
-    loop 
-loop  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== if ====== 
- 
-if (%%<-%%var1 eq (%%<-%%var2)) 
- 
-===== Description ===== 
- 
-Evaluate the first element on the stack. If True, then execute statements that follow, up to the endif or else statement. If False, execution skips to the first statement following the endif or else statement. Any nonzero value is considered True, a value of zero is False. 
- 
-===== Examples ===== 
- 
-<code> 
-if (%%<-%%var eq (1))  
-   #Do Something  
-endif  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== InsertListElement ====== 
- 
-InsertListElement(%%<-%%list 3 %%<-%%value) 
- 
-===== Description ===== 
- 
-Stores a value at the specified index of a list. The previously stored value, and all subsequent values have their indices shifted up by one. 
- 
-===== Examples ===== 
- 
-<code> 
-Split("1,2,3,4,5,6" ",") %%->%%list  
-InsertListElement(%%<-%%list 3 "Spoon" 
-Trace(%%<-%%list)  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== J ====== 
- 
-J 
- 
-===== Description ===== 
- 
-First outer loop index. When loops are nested, this pushes the value of the first (or only) outer “do” loop onto the stack. Do not use outside nested loops. 
- 
-Note: after the inner loop finishes, this value is accessed with I, it being now the innermost loop. See also: [[[#do|do]]], [[[#i|I]]], [[[#k|K]]], and [[[#loop|loop]]] 
- 
-===== Examples ===== 
- 
-<code> 
-do(6 5)  
-    do(4 3)  
-        trace4 ("Inner loop J=" J ", I=" I) 
-    loop  
-     trace2 (" I =" I) #note: The value og I here will be the value of J when the loop above has terminated. 
-loop  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== K ====== 
- 
-K 
- 
-===== Description ===== 
- 
-Outer loop index. When “do” loops are nested, this pushes the value of the third-innermost loop onto the stack. Do not use outside of triply-nested loops. 
- 
-Note that before the inner loops begin, after they end, or between inner loops, this value may need to be referred to with J or even I. See also: [[[#do|do]]], [[[#i|I]]], [[[#j|J]]], and [[[#loop|loop]]] 
- 
-===== Examples ===== 
- 
-<code> 
-do(2 1)  
-    do(4 3)  
-        do(6 5)  
-            I J K Trace3 
-        loop  
-    loop  
-loop  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== LF ====== 
- 
-LF 
- 
-===== Description ===== 
- 
-Pushes a line feed to the stack. Useful for printing 
- 
-===== Examples ===== 
- 
-<code> 
-Trace( Concat (Concat("ABC" LF) "DEF"))  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== ln ====== 
- 
-LN 
- 
-===== Description ===== 
- 
-The natural logarithm. Gives the magnitude of the number. On zero, returns -inf. Below zero, returns NaN, a special value that always causes failure when compared to other numbers. Eg. (NaN<0) %%->%% false, (Nan>=0) %%->%% false 
- 
-other logarithms \ ln(x) = log(x, e) \ ln(x)/ln(10) = log10(x) \ ln(2)=0.6931… \ ln(e)=.999999 \ ln(10)=2.3026… \ 
- 
-===== Examples ===== 
- 
-<code> 
-trace(ln(-1)) #prints 'NaN'  
-trace(ln(0))  #prints '-inf'  
-trace(ln(1))  #prints '0'  
-trace(ln(e))  #prints '1'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== log ====== 
- 
-log 
- 
-===== Description ===== 
- 
-Allows the performance of arbitrary based logarithms. See examples. On zero, returns -inf. Below zero, returns NaN, a special value that always causes failure when compared to other numbers. Eg. (NaN<0) %%->%% false, (Nan>=0) %%->%% false 
- 
-other logarithms \ log(x,10) = log10(x) \ log(x,e) = ln(x) 
- 
-===== Examples ===== 
- 
-<code> 
-trace(log(2 .5))   #prints '-1'  
-trace(log(.25 .5)) #prints '2'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== log10 ====== 
- 
-LOG10 
- 
-===== Description ===== 
- 
-The base ten logarithm. Gives the number of digits in the number before the decimal point. On zero, returns -inf. Below zero, returns NaN, a special value that always causes failure when compared to other numbers. Eg. (NaN<0) %%->%% false, (Nan>=0) %%->%% false 
- 
-other logarithms %%//%% log10(x) = log(x, 10) %%//%% log10(x)/log10(e) = ln(x) %%//%% log10(2)=0.3010-ish %%//%% log10(e)=0.4343-ish \ log10(10)=1 \ 
- 
-===== Examples ===== 
- 
-<code> 
-trace(log10(1))  # prints '0'  
-trace(log10(10)) # prints '1'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== loop ====== 
- 
-LOOP 
- 
-===== Description ===== 
- 
-Terminates the ‘do’ instruction loop . Control flow will return to the ‘do’ instruction until the Index is equal to the Limit. 
- 
-===== Examples ===== 
- 
-<code> 
-do(5 0)  
-   trace(I)  
-loop  
-  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== lt ====== 
- 
-LT 
- 
-===== Description ===== 
- 
-First item on the stack is compared to the second item on the stack.\\ 
-0 (fasle) or 1 (true) is pushed to the stack depending on whether the first value was less than the second or not. 
- 
-===== Examples ===== 
- 
-<code> 
-if (1 lt (42))  
-    trace("1 is less than 42" 
-endif  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== lte ====== 
- 
-LTE 
- 
-===== Description ===== 
- 
-First item on the stack is compared to the second item on the stack.\\ 
-0 (fasle) or 1 (true) is pushed to the stack depending on whether the first value was less or equal to the second or not. ## Examples 
- 
-<code> 
-if (1 lte (1))  
-    trace("1 is less than or equal to 1" 
-endif  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== max ====== 
- 
-MAX 
- 
-===== Description ===== 
- 
-Push the greater of two arguments to the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-trace(max(4 5)) #prints '5'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== min ====== 
- 
-MIN 
- 
-===== Description ===== 
- 
-Push the smaller of two arguments to the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-trace(max(4 5)) #prints '4'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== mod ====== 
- 
-MOD 
- 
-===== Description ===== 
- 
-Perform integer division and returns the value (modulo) of the difference. 
- 
-===== Examples ===== 
- 
-<code> 
-trace(5 mod (3)) #prints '2'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== mul ====== 
- 
-MUL 
- 
-===== Description ===== 
- 
-Multiplies the two arguments together and pushes the result on the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-trace(2 mul(3)) #prints '6'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== neg ====== 
- 
-NEG 
- 
-===== Description ===== 
- 
-Calculates the negative value of the item and pushes the result on the stack. The result is effectively the same as multiplying the original number by -1. 
- 
-===== Examples ===== 
- 
-<code> 
-trace(neg(42)) #prints '-42'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== neq ====== 
- 
-NEQ 
- 
-===== Description ===== 
- 
-Top two items are popped from the stack and compared for equality. 0 or 1 is pushed back to the stack where 0 indicates false and 1 indicates true. 
- 
-===== Examples ===== 
- 
-<code> 
-if (1 neq (2))  
-    trace("1 is not equal to 2" 
-endif  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== neq0 ====== 
- 
-NEQ0 
- 
-===== Description ===== 
- 
-first item on the stack is compared to zero. If zero, true (1) is pushed on the stack, otherwise falsse (0) is pushed back to the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-if (1 neq0)  
-    trace("1 is not equal to 0" 
-endif  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== not ====== 
- 
-NOT 
- 
-===== Description ===== 
- 
-Treats first item on the stack as a boolean value (true/false (1/0) , ‘nots’ it, and pushes 0 or 1 back to the stack. If the item is TRUE, 0 is pushed to the stack. If the item is FALSE, 1 is pushed to the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-if (not(false))  
-    trace("not false is true" 
-endif  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== NotPersist ====== 
- 
-NotPersist(“var_name”) 
- 
-===== Description ===== 
- 
-By default, variables persist across saves. Using this command makes them not persist across saves. 
- 
-===== Examples ===== 
- 
-<code> 
-NotPersist("variableName") 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== once ====== 
- 
-ONCE 
- 
-===== Description ===== 
- 
-Start a block of instructions that are executed once only for the lifetime of the entity the script is associated with. 
- 
-===== Examples ===== 
- 
-<code> 
-once  
-    trace("42") #Only prints once  
-endonce  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== or ====== 
- 
-OR 
- 
-===== Description ===== 
- 
-Pops two items from the stack, treats them as boolean values, ‘ors’ them, and pushes 0 or 1 back to the stack. If one or both items evaluate to True, it returns TRUE (1) to the stack. If both items evaluate to FALSE, FALSE (0) is returned to the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-if (1 or (false))  
-    trace("1 or false is true" 
-endif  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== PI ====== 
- 
-PI 
- 
-===== Description ===== 
- 
-Pushes the value of PI (3.14159265…) to the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-trace(PI) #prints '3.14159265'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== pop ====== 
- 
-POP 
- 
-===== Description ===== 
- 
-Removes the item at the top of the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-42 pop #stack is now empty  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== pow ====== 
- 
-POW 
- 
-===== Description ===== 
- 
-Pops two arguments from the stack and raises the first to the second and pushes the result to the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-Trace (8 pow (3)) ) #prints '512'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== PrependStackToList ====== 
- 
-PrependStackToList (“Hello” “Creeper” “World” %%<-%%list) 
- 
-===== Description ===== 
- 
-Inserts the contents of the stack at the beginning of L1 (at index 0) and shifts the index of all other elements in the list up by the number of elements on the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-createlist %%->%%list 
-AppendStacktoList ("foo" "bar" %%<-%%list) 
-PrependStackToList ("Hello" "Creeper" "World" %%<-%%list) 
-print (%%<-%%list) 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== Print ====== 
- 
-PRINT (“Hello World”) 
- 
-===== Description ===== 
- 
-Takes one item from the stack and writes it on a new line in a file called PRPL.txt in the game’s root content folder, preceded by the identifying information that indicates which unit or component called the PRINT function. Note that this file is truncated (cleared) each time a map is loaded. 
- 
-To avoid having to constantly re-open the RPL.txt file to refresh it, a Windows Powershell commad (or Linus shell command) can be written to monitor the file and show new output. 
- 
-Eg. Create a file in the game’s root directory named ShowRPL.PS1. Put this single line in the file 
- 
-<code> 
-Get-Content RPL.txt -wait 
-</code> 
-Now, in the context menu for the file, click on “Run with PowerShell”. 
- 
-===== Examples ===== 
- 
-<code> 
-#  Assume this core is at map coordinates (100, 50). Assume this script is named "Hello.prpl" 
-"Hello World!" print 
-#  Each time this line is invoked, a new line appears in PRPL.txt: 
-#  [100,50] Hello.prpl: Hello World! 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== Print2 ====== 
- 
-PRINT2 (“Hello” “World”) 
- 
-===== Description ===== 
- 
-Prints 2 values from the stack into the rpl.txt output file. See [[[#print|PRINT]]] for more details 
- 
-===== Examples ===== 
- 
-<code> 
-Print2 ("X" %%<-%%x) 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== Print3 ====== 
- 
-PRINT3 (“Hello” “World” " Again") 
- 
-===== Description ===== 
- 
-Prints 3 values from the stack into the rpl.txt output file. See [[[#print|PRINT]]] for more details 
- 
-===== Examples ===== 
- 
-<code> 
-Print3 ("Coords:" %%<-%%x %%<-%%y ) 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== Print4 ====== 
- 
-PRINT4 (“Oh” “Hello” “World” " Again") 
- 
-===== Description ===== 
- 
-Prints 4 values from the stack into the rpl.txt output file. See [[[#print|PRINT]]] for more details 
- 
-===== Examples ===== 
- 
-<code> 
- 
-Print4  ("Coords and angle:" %%<-%%x %%<-%%y %%<-%%angle ) 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== Print5 ====== 
- 
-PRINT4 (“not” “another” “Hello” “world” “example”) 
- 
-===== Description ===== 
- 
-Prints 5 values from the stack into the rpl.txt output file. See [[[#print|PRINT]]] for more details 
- 
-===== Examples ===== 
- 
-<code> 
- 
-Print5 (%%<-%%x "plus" %%<-%%y "is" %%<-%%x  add (%%<-%%y))   
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== PrintAll ====== 
- 
-PrintAll 
- 
-===== Description ===== 
- 
-Removes all values from the stack and prints them in the RPL.txt file The values will be on a single line and **not** separated by a space when printed. See [[[#print|PRINT]]] for more details 
- 
-===== Examples ===== 
- 
-<code> 
-PRINTALL ("cat" "dog" "rat" "mouse" "flea" "tick" "worm" "caterpillar" ) 
-  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== PrintAllSp ====== 
- 
-PrintAllSp 
- 
-===== Description ===== 
- 
-Removes all values from the stack and prints them into the RPL.txt file The values will be on a single line and **will** be separated by a space when printed. See [[[#print|PRINT]]] for more details 
- 
-===== Examples ===== 
- 
-<code> 
-PRINTALLSP ("cat" "dog" "rat" "mouse" "flea" "tick" "worm" "caterpillar" ) 
-  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== PrintStack ====== 
- 
-PrintStack 
- 
-===== Description ===== 
- 
-Prints all the values from the stack to the RPL.txt file without removing them. The top and bottom of the stack will be identidfied, and the data type of each item will be provided. See [[[#print|PRINT]]] for more details 
- 
-Note ## Examples 
- 
-<code> 
-PrintStack ("cat" "dog" "rat" "mouse" "flea" "tick" "worm" "caterpillar" ) 
- 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== QUARTERPI ====== 
- 
-QuarterPI 
- 
-===== Description ===== 
- 
-Pushes the value of PI/4 to the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-trace(HALFPI) #prints '0.7853981625'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== Rad2Deg ====== 
- 
-Rad2Deg 
- 
-===== Description ===== 
- 
-Pushes the constant to use in converting radians to degrees onto the stack. Multiply this value with a value expressed in radians to obtain degrees. 
- 
-===== Examples ===== 
- 
-<code> 
-trace(PI mul(Rad2Deg)) #prints '180'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== RANDFLOAT ====== 
- 
-%%->%%rando (randfloat) 
- 
-===== Description ===== 
- 
-Gives a random floating-point number between 0 and 1 
- 
-===== Examples ===== 
- 
-<code> 
-Trace ( RandFloat mul ( 2 mul (PI))) 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== RANDINT ====== 
- 
-%%->%%randi (randInt(0 10)) 
- 
-===== Description ===== 
- 
-Returns a random integer from a range of two numbers Inclusive of the lower number, but exclusive of the higher number. A workaround for between 0 and 10 both inclusive is in the example below. is to do 0 11 RandInt, so 11 will exclude but 10 will include [basically, 0 10 1 add RandInt] 
- 
-===== Examples ===== 
- 
-<code> 
-# get a random integer between 1 and 10 (both numbers inclusive)  
-RandInt(0 11) 
- 
-# or  
-#    
-RandInt( 0 10 add (1)) # functionally equivalent.  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== RemoveListElement ====== 
- 
-===== Description ===== 
- 
-Removes an element from a list at a given position. Position are indexed from 0. 
- 
-Elements after the removed one will be shifted towards the start of the list. 
- 
-===== Examples ===== 
- 
-<code> 
-createlist %%->%%list 
-"a" %%->%%list[0] 
-"b" %%->%%list[1] 
-"c" %%->%%list[2] 
-RemoveListElement(%%<-%%list 1)  #["a", "c"] 
-</code> 
- 
----- 
- 
-====== removetableelement ====== 
- 
-To be supplied 
- 
- 
----- 
- 
- 
----- 
- 
- 
----- 
- 
-====== repeat ====== 
- 
-Repeat 
- 
-===== Description ===== 
- 
-Part of the "while: loop construct. Pops an item from the stack. If true, execute the following statements. If false, jump to the statement following ‘endwhile’. 
- 
-===== Examples ===== 
- 
-<code> 
-5 %%->%%y  
-while  
-    %%<-%%y gt(0)       #is y greater than zero?  
-repeat              #repeat this section of code  
-    trace(%%<-%%y)  
-    %%<-%%y sub(1) %%->%%y  #subtract 1 from y so we don't end in infinite loop  
-endwhile  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== return ====== 
- 
-Return 
- 
-===== Description ===== 
- 
-Stops execution of a function call and returns immediately. If called from some place other than a function, it will stop the script execution and ‘return’ immediately. Useful for aborting function execution or script execution when necessary. 
- 
-===== Examples ===== 
- 
-<code> 
-trace(42)  
-@MyFunc  
-trace (43) 
-  
-:MyFunc  
-    trace("1" 
-    return  
-    trace("2" 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== round ====== 
- 
-Round (%%<-%%value 2) 
- 
-===== Description ===== 
- 
-Rounds off a number to the specified number of decimal places. This always returns a float, even when you are rounding to a whole number. 
- 
-===== Examples ===== 
- 
-<code> 
-trace(PI round(2)) #print '3.14'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== SetListElement ====== 
- 
-SetListElement(%%<-%%list %%<-%%index %%<-%%value) 
- 
-===== Description ===== 
- 
-Stores a value at the specified index of a list. The previously stored value is overwritten. 
- 
-If a list is stored in a variable, this can be abbreviated to %%<-%%value %%->%%list[%%<-%%index]. 
- 
-===== Examples ===== 
- 
-<code> 
-Split("1,2,3,4,5,6" ",") %%->%%list  
-SetListElement(%%<-%%list 2 "G" 
-"R" %%->%%list[4]  
-Trace(%%<-%%list)  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== settableelement ====== 
- 
-To be supplied 
- 
- 
----- 
- 
- 
----- 
- 
- 
----- 
- 
-====== ShortestAngle ====== 
- 
-ShortestAngle(%%<-%%cur %%<-%%new) %%->%%rotAngle 
- 
-===== Description ===== 
- 
-Given two angles, calculates the shortest angle between the two. Useful for determining which direction a unit should rotate in order to turn to a given direction. A positive or negative value will be returned in the range of PI to -PI. Negative values indicate clockwise rotation. 
- 
-===== Examples ===== 
- 
-<code> 
-trace(ShortestAngle(1.1 2.5))  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== SignalGenerator ====== 
- 
-SignalGenerator(%%<-%%clockTick %%<-%%sigFrequency %%<-%%phaseShift false false %%->%% i-<signalType) %%->%%sigValue 
- 
-===== Description ===== 
- 
-Computes the value for a given signal waveform and pushes it to the stack. 
- 
-A function to derive the y-coordinate for a given x-co-ordiante on a graph line following one of the indicated wave patterns. Uselful to animate an object or to a given pattern over time. Could be used for instance to vary output from an emitter. Oscillating rightness of light source or beacon; Oscillating strength of an emitter over time - both of these can be thought of as a a use case for this function. 
- 
-Arguments and type in order: 1: Integer. the X coordinate in the waveform (Eg. time) \ 2: Float. Frequency of the waveform \ 3: Float. PhaseShift of the waveform \ 4: Bool. invert the waveform \ 5: Integer. Signal type (0 to 6 in types, below) \ 
- 
-Signal types. 0 = NONE <html><br/></html> 1 = SINE <html><br/></html> 2 = SQUARE <html><br/></html> 3 = TRIANGLE <html><br/></html> 4 = SAWTOOTH <html><br/></html> 5 = RANDOM <html><br/></html> 6 = CONSTANT <html><br/></html> 
- 
-===== Examples ===== 
- 
-<code> 
-#  On a map with terrain of 200 in X direction and at least 150 in Z direction (3D coordinates)  
-# generate a sine wave of creeper across the map. 
-200    %%->%%numFrames 
-      %%->%%frequency (1 div (AsFloat (%%<-%%numFrames)))  
-0     %%->%%phaseShift 
-false %%->%%invert 
-1     %%->%%signalType #sine 
- 
-do  (%%<-%%numFrames 0) 
-    round (SignalGenerator(I %%<-%%frequency %%<-%%phaseShift %%<-%%invert %%<-%%signalType ) 2) %%->%%sigValue 
-    print3 (I " : " %%<-%%sigValue ) 
-    SetCreeper(I 75 add (%%<-%%sigValue mul (50)) 15 true) 
-loop 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== sin ====== 
- 
-sin (PI) 
- 
-===== Description ===== 
- 
-Calculates the sine of the input angle 
- 
-===== Examples ===== 
- 
-<code> 
-trace(sin(PI)) #prints 0  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== Split ====== 
- 
-Split (%%<-%%string %%<-%%delimiter) %%->%%list 
- 
-===== Description ===== 
- 
-Takes two strings from the stack and splits the first wherever the second occurs. Returns a list of strings. 
- 
-===== Examples ===== 
- 
-<code> 
-Split("Here is a sentence with some words in." " ") %%->%%wordsList  
-%%<-%%wordsList GetListCount 0 do  
-    Trace(%%<-%%wordsList[I])  
-loop  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== sqrt ====== 
- 
-SQRT (%%<-%%value) 
- 
-===== Description ===== 
- 
-Pops an item from the stack and pushes the square root of that number to the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-trace(sqrt(9)) #prints '3'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== StackSize ====== 
- 
-StackSize <stackDepth 
- 
-===== Description ===== 
- 
-Returns the number of items currently on the stack 
- 
-===== Examples ===== 
- 
-<code> 
-1 2 3 trace(StackSize) #prints '3'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== StartsWith ====== 
- 
-StartsWith (%%<-%%thisString %%<-%%preamble) 
- 
-===== Description ===== 
- 
-Takes two strings from the stack and returns whether the first string starts with the second (case sensitive) 
- 
-===== Examples ===== 
- 
-<code> 
-if (StartsWith("Hello there" "Hello"))  
-    Trace("I opened with hello" 
-endif  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== StringLength ====== 
- 
-Stringlength (%%<-%%thisString) %%->%%numchar 
- 
-===== Description ===== 
- 
-Returns the number of characters in a string. 
- 
-===== Examples ===== 
- 
-<code> 
-Trace( StringLength ("PRPL")) #Prints 4  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== StringReplace ====== 
- 
-StringReplace (%%<-%%inputString %%<-%%match -<replace) 
- 
-===== Description ===== 
- 
-string ARG1: The string to be searched string ARG2: The string to search for in ARG1 string ARG3: The string to replace ARG2 with 
- 
-Searches a string for all instances for another string, and replaces them with a different string. 
- 
-===== Examples ===== 
- 
-<code> 
-Trace(StringReplace ("Where there's a will, there's a way." "will" "way"))  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== StringToList ====== 
- 
-StringToList (%%<-%%inputstring) %%->%%charList 
- 
-===== Description ===== 
- 
-Takes a string from the stack and returns the list of characters in the string. 
- 
-===== Examples ===== 
- 
-<code> 
-StringToList("Hello human") %%->%%charactersList  
-%%<-%%charactersList GetListCount 0 do  
-    Trace(%%<-%%wordsList[I])  
-loop  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== sub ====== 
- 
-44 sub (2) %%->%%result 
- 
-===== Description ===== 
- 
-Subtracts the two arguments together and pushes the result on the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-trace(44 sub(2)) #prints '42'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== Substring ====== 
- 
-Substring (%%<-%%aString %%<-%%startAt %%<-%%lenth) %%->%%aPiece 
- 
-===== Description ===== 
- 
-Extracts a portion of a string into a new item on the stack. 
- 
-The command has 3 arguments. First the string to be examined, second the starting position of the substring within the original string, starting from offset 0 (zero) and thirdly the length of the extrated string. 
- 
-===== Examples ===== 
- 
-<code> 
-Trace( Substring("Particle" 1 3)) # Prints "art"  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== swap ====== 
- 
-swap 
- 
-===== Description ===== 
- 
-Swaps the order of the top two items on the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-trace2(swap(1 2)) #prints '2 1'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== tan ====== 
- 
-tan (PI) %%->%%tangent 
- 
-===== Description ===== 
- 
-Calculates the tangent of the input angle. 
- 
-===== Examples ===== 
- 
-<code> 
-trace(tan(PI)) #prints 0  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== TAU ====== 
- 
-TAU 
- 
-===== Description ===== 
- 
-Pushes the value of TAU (2PI) to the stack (6.2831853…) 
- 
-===== Examples ===== 
- 
-<code> 
-trace(TAU) #prints '6.2831853'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== ToLower ====== 
- 
-ToLower(%%<-%%string) %%->%%string 
- 
-===== Description ===== 
- 
-Converts a string to lowercase. 
- 
-===== Examples ===== 
- 
-<code> 
-Trace( ToLower("CRACKER"))  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== ToUpper ====== 
- 
-ToUpper (%%<-%%string) %%->%%string ## Description Converts a string to uppercase. 
- 
-===== Examples ===== 
- 
-<code> 
-Trace( ToUpper("knuckle"))  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== Trace ====== 
- 
-Trace (“ABC”) 
- 
-===== Description ===== 
- 
-Prints a value from the stack into the debug window. 
- 
-===== Examples ===== 
- 
-<code> 
- 
-Trace ("ABC" 
- 
- if (%%<-%%value lt (0)) 
-     Trace ("Warning: value is less than zero") 
-endif 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== Trace2 ====== 
- 
-Trace2 (%%<-%%thing1 %%<-%%thing2) 
- 
-===== Description ===== 
- 
-Prints 2 values from the stack into the debug window. 
- 
-===== Examples ===== 
- 
-<code> 
- 
-Trace2 ("X:" %%<-%%x ) 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== Trace3 ====== 
- 
-Trace3 (%%<-%%thing1 %%<-%%thing2 %%<-%%thing3) 
- 
-===== Description ===== 
- 
-Prints 3 values from the stack into the debug window. 
- 
-===== Examples ===== 
- 
-<code> 
- 
-Trace3 ("Coords:" %%<-%%x %%<-%%z ) 
-</code> 
-%%<-%% [[.:prplreference| PRPL reference]] %%<-%% [[.:prplreference#everything_else_2|Everything Else 2]] 
- 
- 
----- 
- 
- 
----- 
- 
-====== Trace4 ====== 
- 
-Trace4 (%%<-%%thing1 %%<-%%thing2 %%<-%%thing3 %%<-%%thing4) 
- 
-===== Description ===== 
- 
-Prints 4 values from the stack into the debug window. 
- 
-===== Examples ===== 
- 
-<code> 
- 
-Trace3 ("3 Coords:" %%<-%%x %%<-%%z %%<-%%y ) 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== Trace5 ====== 
- 
-Trace5 (%%<-%%thing1 %%<-%%thing2 %%<-%%thing3 %%<-%%thing4 %%<-%%thing5) 
- 
-===== Description ===== 
- 
-Prints 5 values from the stack to the debug window. 
- 
-===== Examples ===== 
- 
-<code> 
- 
-Trace5 (%%<-%%x " plus " %%<-%%y " is " %%<-%%x  add  (%%<-%%y)) 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== TraceAll ====== 
- 
-TraceAll 
- 
-===== Description ===== 
- 
-Removes all the values from the stack and prints them into the debug console. The values will be on a single line and **not** separated by a space when printed. Compare to [[[#traceallsp|TraceAllSp]]] 
- 
-===== Examples ===== 
- 
-<code> 
-"Where" 
-"is"   
-"Waldo?" 
- 
-traceAll   
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== TraceAllSp ====== 
- 
-TraceAllSp 
- 
-===== Description ===== 
- 
-Removes all the values from the stack and prints them into the debug console. The values will be on a single line and **will** be separated by a space when printed. Comparae to [[[#traceall|traceAll]]] 
- 
-===== Examples ===== 
- 
-<code> 
-"Where" 
-"is"   
-"Waldo?" 
- 
-traceAllSp  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== TraceStack ====== 
- 
-TraceStack 
- 
-===== Description ===== 
- 
-Prints all the items from the stack to the debug window without removing them. Items are printed one per line and the type of each is also provided. 
- 
-===== Examples ===== 
- 
-<code> 
- 
-# inspect what a function does to the stack 
-TraceStack # see stack before the call 
-@MyFunction 
-TraceStack # see stack after the call 
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== true ====== 
- 
-true 
- 
-===== Description ===== 
- 
-Pushes a 1 onto the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-if (true)  
-    trace("True" 
-endif  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== TWOPI ====== 
- 
-TwoPI 
- 
-===== Description ===== 
- 
-Pushes the value of TAU (2PI) to the stack (6.2831853…) 
- 
-===== Examples ===== 
- 
-<code> 
-trace(TWOPI) #prints '6.2831853'  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== while ====== 
- 
-While 
- 
-===== Description ===== 
- 
-Beginning of a while loop. The statements between a ‘while’ and a ‘repeat’ should ultimately push a value to the stack that will determine if the loop executes the body of the ‘repeat’ block. 
- 
-A while loop is a control flow statement that allows code to be executed repeatedly based on a given Boolean condition. The while loop can be thought of as a repeating if statement. 
- 
-===== Examples ===== 
- 
-<code> 
-5 %%->%%y  
-while   %%<-%%y gt(0)   #is y greater than zero?  
-repeat              #repeat this section of code  
-    trace(%%<-%%y)  
-    %%<-%%y sub(1) %%->%%y  #subtract 1 from y so we don't end in infinite loop  
-endwhile  
-</code> 
- 
----- 
- 
- 
----- 
- 
-====== xor ====== 
- 
-XOR 
- 
-===== Description ===== 
- 
-Pops two items from the stack, treats them as boolean values, ‘xors’ them, and pushes 0 or 1 back to the stack. If both items are TRUE, 0 is pushed to the stack. If both items are FALSE, 0 is pushed to the stack. If one item is TRUE and the other is FALSE, 1 is pushed to the stack. 
- 
-===== Examples ===== 
- 
-<code> 
-if (1 xor (false))  
-    trace("1 xor false is true" 
-endif  
-</code> 
- 
----- 
  
xrpl/full_doc_of_base_commands.1551923851.txt.gz · Last modified: 2025/02/14 14:56 (external edit)