User Tools

Site Tools


pf:prpldocs:vars_and_functions

Differences

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

Link to this comparison view

Next revision
Previous revision
pf:prpldocs:vars_and_functions [2016/06/23 09:18] – created virgilwpf:prpldocs:vars_and_functions [2016/06/23 12:48] (current) virgilw
Line 1: Line 1:
 <html> <html>
-    <script type="text/javascript">+<script type="text/javascript"
 +    function selectText(containerid) { 
 +        if (document.selection) { 
 +            var range = document.body.createTextRange(); 
 +            range.moveToElementText(document.getElementById(containerid)); 
 +            range.select(); 
 +        } else if (window.getSelection) { 
 +            var range = document.createRange(); 
 +            range.selectNode(document.getElementById(containerid)); 
 +            window.getSelection().addRange(range); 
 +        } 
 +    } 
 +</script>
  
 +<a href="#" onclick="selectText('selectable')">Select All</a><br/>
 +Save the contents to "Vars and Functions.txt"
  
-            // Wait for the page to load first +<div id="selectable"> 
-            window.onload function() {+</html> 
 +<code> 
 +=CMD 
 +=COMMAND $VARNAME:DEF_VAL 
 +=DESC  
 +Defines an input variableInput variables are created at script start and assigned either the default value, or a value specified in the editor. Input variables must start with a $ sign 
 +=ENDDESC 
 +=EX  
 +$enemy:1 
 +$particleType:0
  
-              //Get a reference to the link on the page +CreateParticle(CurrentCoords 0 0 <-particleType <-enemy) 
-              // with an id of "exportxt" +=ENDEX 
-              var a document.getElementById("exportxt");+=ENDCMD
  
-              //Set code to run when the link is clicked +=CMD 
-              // by assigning a function to "onclick" +=COMMAND ClearLocals 
-              a.onclick function() {+=DESC  
 +Clears all local variablesLocal variables persist across script invocations. 
 +=ENDDESC 
 +=EX  
 +1 ->temp 
 +trace(<-temp#prints out 1 to the tracelog 
 +ClearLocals 
 +trace(<-temp) #prints out 0 to the tracelog 
 +=ENDEX 
 +=ENDCMD
  
-                // Your code here...+=CMD 
 +=COMMAND --VARNAME 
 +=DESC  
 +Deletes VARNAME from the heapIt is now unassigned. 
 +=ENDDESC 
 +=EX  
 +42 ->TheAnswer 
 +trace(<-TheAnswer) #prints out 42 
 +--TheAnswer 
 +trace(<-TheAnswer) #prints out 0 
 +=ENDEX 
 +=ENDCMD
  
 +=CMD
 +=COMMAND <-VARNAME value
 +=DESC 
 +Reads the contents of the local variable VARNAME and pushes it to the stack. If VARNAME does not exist, 0 is pushed to the stack.
 +=ENDDESC
 +=EX 
 +#Increment a variable named 'i' by 1 and store the result back in 'i' 
 +<-i add(1) ->i
 +=ENDEX
 +=ENDCMD
  
-    function downloadInnerHtml(filename, elId, mimeType) { +=CMD 
-        var elHtml document.getElementById(elId).innerHTML; +=COMMAND ->VARNAME (value
-        var link document.createElement('a'); +=DESC 
-        mimeType = mimeType || 'text/plain'; +value ARG1: The value to pop from the stack and store in the heap at VARNAME.<p/ 
-        link.setAttribute('download', filename); +Pops an item from the stack and stores it in the local variable named VARNAME
-        link.setAttribute('href', 'data:' + mimeType  +  ';charset=utf-8,' + encodeURIComponent(elHtml)); +=ENDDESC 
-        link.click();  +=EX  
-    } +# Store coordinate points in local variables.  
-    var fileName =  'myexportedhtml.txt'; // You can use the .txt extension if you want +# The points are defined once and assigned to local variables.  
-    downloadInnerHtml(fileName, 'editor','text/plain'); +once  
-                //If you don't want the link to actually  + 10 ->x1  
-                // redirect the browser to another page, then + 20 ->y1  
-                // return false at the end of this block. + 40 ->x2  
-                // Note that this also prevents event bubbling, + 50 ->y2  
-                // which is probably what we want here, but won' +endonce 
-                // always be the case. +=ENDEX 
-                return false; +=ENDCMD
-              } +
-            }+
  
-    </script>+=CMD 
 +=COMMAND -?VARNAME bool 
 +=DESC  
 +Checks to see if VARNAME exists (has been assigned). If so, 1 is pushed to the stack else 0. 
 +=ENDDESC 
 +=EX  
 +if (not(-?unit)) 
 + CreateUnit(10 20 "AmpGem") ->unit 
 +endif 
 +=ENDEX 
 +=ENDCMD
  
 +=CMD
 +=COMMAND <-! (string) value
 +=DESC 
 +string ARG1: The string name of the heap variable to read.<p/>
 +Reads the contents of the local variable and pushes it to the stack. This allows dynamic reading of variables.
 +=ENDDESC
 +=EX 
 +42 ->someVar
 +trace( <-!("someVar") )
 +=ENDEX
 +=ENDCMD
  
-    <a id="exportxt" href="#">SAVE PROJECT IN TXT FILE</a> +=CMD 
 +=COMMAND ->! (value string) 
 +=DESC  
 +value ARG1: The value to store.<br/
 +string ARG2: The string name of the heap variable to write to.<p/> 
 +Pops name of a variable and an item from the stack and stores the item in the variable. 
 +=ENDDESC 
 +=EX  
 +->!(42 "someVar"
 +trace(<-someVar) 
 +=ENDEX 
 +=ENDCMD
  
-<div id="editor"><p style="font-family:'Courier New', Courier, monospace; font-size:11px; color:#663300">Lorem ipsum dolor sit amet, consectetur adipiscing elitNam luctus facilisis ante id luctusAliquam vestibulumdui in pulvinar facilisis, felis nisl viverra nisl, nec ultrices neque tortor eget erat. Vivamus vel leo vehicula, condimentum quam aliquam, congue mauris. Pellentesque id lectus id nulla molestie vehicula sed at velit. Maecenas sit amet tristique nunc, in lobortis mi. Integer in turpis odio. Duis eget urna vestibulum, venenatis justo et, semper neque. Suspendisse in ante massa. Aenean massa nisl, tincidunt id nisl eu, convallis lobortis augue. Integer blandit augue eget nunc condimentum consectetur. Duis gravida nisl hendrerit, sagittis orci in, sollicitudin risus. Nullam elementum sem nec nunc facilisis, et semper metus tincidunt.+=CMD 
 +=COMMAND -?! (string) bool 
 +=DESC  
 +string ARG1The string name of the heap variable to check.<p/> 
 +Takes a string from the stack and uses it as a variable nameChecks to see if the variable exists (has been assigned)If so1 is pushed to the stack else 0. 
 +=ENDDESC 
 +=EX  
 +42 ->somevar 
 +trace(-?!("somevar")) 
 +=ENDEX 
 +=ENDCMD
  
-Phasellus ornare quis ipsum non scelerisqueIn sollicitudin est placerat nibh porttitor pretiumPhasellus ac purus nullaPhasellus in enim vel leo viverra sodales eget sit amet anteSed ultrices elementum nibh, tristique euismod nunc volutpat sit ametSuspendisse potentiMorbi feugiat diam tristique, euismod dui in, mattis diamVestibulum euismod commodo cursusProin posuere libero vitae purus blanditin posuere erat malesuadaDonec ultrices vel velit in feugiatVestibulum suscipit erat urnabibendum vestibulum dui varius sit amet.</p></div> +=CMD 
-</html>+=COMMAND --? 
 +=DESC  
 +string ARG1: The string name of the heap variable to delete.<p/> 
 +Finds a local variable by string name and deletes it. 
 +=ENDDESC 
 +=EX  
 +42 ->theAnswer 
 +--?("theAnswer"
 +trace(<-theAnswer) 
 +=ENDEX 
 +=ENDCMD 
 + 
 +=CMD 
 +=COMMAND @FUNC_NAME 
 +=DESC  
 +Invokes a functionExecution passes to the function that is named and returns to the statement after the call when the function is completeArguments can be passed to and received from functions via the stack. 
 +=ENDDESC 
 +=EX  
 +if (@GetAnswer(true) eq(42)) 
 + trace("The Answer"
 +endif 
 + 
 +:GetAnswer 
 + ->really 
 + if (really) 
 + 42 
 + else 
 +
 + endif  
 +=ENDEX 
 +=ENDCMD 
 + 
 +=CMD 
 +=COMMAND :FUNC_NAME 
 +=DESC  
 +Defines the beginning of a function blockChoose a unique name for the functionStatements after a function block only execute if called by invoking the function with an '@FUNC_NAME' callThe end of a function block is either the end of the script or the beginning of another functionwhichever comes first. 
 +=ENDDESC 
 +=EX  
 +if (@GetAnswer(true) eq(42)) 
 + trace("The Answer"
 +endif 
 + 
 +:GetAnswer 
 + ->really 
 + if (really) 
 + 42 
 + else 
 +
 + endif  
 +=ENDEX 
 +=ENDCMD 
 + 
 +=CMD 
 +=COMMAND # 
 +=DESC  
 +Turns the rest of the line into a commentComments are not code: They do nothing. 
 +=ENDDESC 
 +=EX  
 +#This is a commentit does nothing. 
 +=ENDEX 
 +=ENDCMD 
 + 
 +</code> 
 +<html></div></html>
pf/prpldocs/vars_and_functions.1466687918.txt.gz · Last modified: 2016/06/23 09:18 by virgilw