User Tools

Site Tools


tutorials:tool_quick_reference_card

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
tutorials:tool_quick_reference_card [2012/02/22 22:45]
marcus.williams
tutorials:tool_quick_reference_card [2019/02/28 22:14]
marcus.williams [M]
Line 6: Line 6:
  
 ===== Tools and examples ===== ===== Tools and examples =====
 +==== A ====
 +**avg()** syntax and example: ​
 +<​code>​
 +A[s1,​..,​sn,​t1,​..,​tm] = avg (B[s1,​..,​sn,​k,​t1,​..,​tm];​ {dim=Name(k)},​
 +{inlcudeZero={on,​off}},​{weight=W[s1,​..,​sn,​k,​t1,​..,​tm]})
 +</​code>​
 +
 ==== E ==== ==== E ====
 **extend()** syntax and example: ​ **extend()** syntax and example: ​
Line 12: Line 19:
 A[s,t] = extend (B[s,t]; dim=time, end=1998) A[s,t] = extend (B[s,t]; dim=time, end=1998)
 </​code>​ </​code>​
- 
  
 ==== L ==== ==== L ====
Line 29: Line 35:
 </​code>​ </​code>​
  
 +Note the syntax for one-to-many:​
 +<​code>​
 +map1[x,y] = create (; dim=x, dim=y, format=mapping,​ \
 +  y1->"​x1,​x2,​x3",​ ..,​yi->​xi,​...)
 +</​code>​
 +
 +There is also a dimension mapping:
 +<​code>​A[I1,​..,​ In, X,K1,..,Km] = map (B[I1,.., In, Y,​K1,​..,​Km];​ Y->​X)</​code>​
 +which matches up element names in Y with those in X.
 +
 +{{ :​howtos:​toolcoding:​mappingtemplate.xls |Mapping Template}}
 ==== N ==== ==== N ====
 **norm()** examples: **norm()** examples:
Line 45: Line 62:
 a[s,t] = sum (b[s->​c,​t];​ dim=stateCOcounty@state) a[s,t] = sum (b[s->​c,​t];​ dim=stateCOcounty@state)
 a[] = sum (b[s,a]; dim=all) a[] = sum (b[s,a]; dim=all)
 +</​code>​
 +
 +**shrink()** examples:
 +<​code>​
 +a[t] = shrink (b[byrs,a])
 +a[t] = shrink (b[byrs,a]; time)
 </​code>​ </​code>​
  
Line 55: Line 78:
 TOOL **comments** are lines beginning with the '​!'​ character and will be ignored. TOOL **comments** are lines beginning with the '​!'​ character and will be ignored.
  
-Navigation and display: ''​where(),​ moveto("​pathName"​),​ up(), look(), showenv()''​+Goto functionality via ''​skipto''​ command: 
 +<​code>​ 
 +skipto label1 
 + ... 
 + skipped code 
 + ... 
 +label1: 
 +</​code>​ 
 + 
 +Navigation and display: ''​where()''​''​moveto("​pathName"​)''​''​up()''​''​look()''​''​showenv()''​
  
  
Line 63: Line 95:
 </​code>​ </​code>​
  
-**listen()** example:+**listen()** example ​1 (for a value to put into a TOOL object):
 <​code>​ <​code>​
 string $target  string $target
Line 75: Line 107:
 endif endif
 </​code>​ </​code>​
 +
 +Example 2 (for TOOL integer type variable):
 +<​code>​
 +integer $elec_startYear
 +say (""​)
 +listen (" ​ What is your elec start year? {2007..2090}[2010] ",​$elec_startYear)
 +if $elec_startYear == 0
 + $elec_startYear = 2010
 +endif
 +</​code>​
 +
 +Example 3 (for a yes/no question):
 +<​code>​
 +boolean $answer
 +say (""​)
 +listen ("Do you want to do something? {y n}[n] ",​$answer)
 +if $answer== true
 + say ("Do stuff here")
 +endif
 +</​code>​
 +
 +
  
 **menu()** syntax: **menu()** syntax:
Line 128: Line 182:
 </​code>​ </​code>​
  
 +**while-loop** syntax:
 +
 +<​code>​
 +while arithmeticExpression
 +...
 +endwhile
 +</​code>​
 +
 +**Boolean** operators: ''>'',​ ''<'',​ ''>​='',​ ''<​='',​ ''​=='',​ ''​!='',​ ''​AND'',​ ''​OR''​
 ===== Object Creation and Shaping ===== ===== Object Creation and Shaping =====
  
Line 270: Line 333:
 kingLear kingLear
 </​file>​ </​file>​
 +
 +Or creation with category definition using parameters:
 +
 +<​code>​
 +localinformant vwcCOvpshd[] = create (; object=category,​ groups=vehWeightClass,​ members=vehPowerSrcHD,​ \
 + 4_5andUnder="​ICE_Gas ICE_Diesel ICE_NGL",​ \
 + 4_5-14_9="​ICE_Gas ICE_Diesel",​ \
 + 15andOver="​ICE_Diesel"​)
 +</​code>​
  
 **mapcat()** syntax: **mapcat()** syntax:
Line 306: Line 378:
 </​code>​ </​code>​
  
-Variable types: ''​integer,​ real, boolean, string''​+Variable types: ''​integer''​''​real''​''​boolean''​''​string''​
  
 +TOOL operators by order of precedence:
 +<​code>​
 +* /
 ++ -
 +> < >= <=
 +== !=
 +AND OR
 +assign
 +</​code>​
 ===== Object Display ===== ===== Object Display =====
  
Line 351: Line 432:
 where objectTypes are: ''​view,​ creview, localview''​ where objectTypes are: ''​view,​ creview, localview''​
  
-[List reserved ​TOOL variables]+Reserved ​TOOL variables: ''​$numScns'',​ ''​$numVars'',​ ''​$scnNumbers[]'',​ ''​$scnNames[]'',​ ''​$scnColours[]'',​ ''​$scnDescs[]'',​ ''​$createView'',​ ''​$history'',​ ''​$background''​
  
  
 **quit()** is called as ''​quit (return code)''​ **quit()** is called as ''​quit (return code)''​
tutorials/tool_quick_reference_card.txt · Last modified: 2020/09/08 16:12 by marcus.williams