home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 545a.lha / PowerVisor_v1.0 / docs.LZH / docs / Expressions < prev    next >
Encoding:
Text File  |  1991-09-01  |  22.5 KB  |  734 lines

  1. *------------------------*
  2. * Tutorial : expressions * Sun Sep  1 14:42:42 1991
  3. *------------------------*
  4.  
  5.  
  6. ===================== Commands used in this tutorial =========================
  7.  
  8.    disp        Display integer
  9.    exec        Go to the ExecBase list
  10.    help        Ask for help
  11.    list        Show a list (tasks, libraries, message ports, ...)
  12.    loadfd      Load a fd file
  13.    memory      List memory
  14.    print       Print a string
  15.    remvar      Remove a variable
  16.    scan        Ask input
  17.    task        Go to the task list
  18.    void        Evaluate the arguments given
  19.  
  20. ===================== Functions used in this tutorial ========================
  21.  
  22.    alloc       Allocate memory
  23.    cols        Ask the number of columns in logical window
  24.    eval        Evaluate string
  25.    free        Free memory
  26.    if          Conditional evaluation
  27.    lines       Ask the number of rows in logical window
  28.  
  29. ============================== Introduction ==================================
  30.  
  31. PowerVisor has a very powerful expression evaluator. Before you continue
  32. reading this file make sure you have mastered the basic features of
  33. PowerVisor (read the file 'GettingStarted' first).
  34.  
  35. First start PowerVisor (if it is not already in memory).
  36.  
  37. PowerVisor has two basic types: ¹strings and ¹integers. Sometimes these two
  38. types collide a bit. In this tutor file I will make you more comfortable
  39. with all the features PowerVisor has in this regard.
  40.  
  41. All commands and functions in PowerVisor expect integers and/or strings
  42. as their arguments. You can use expressions everywhere.
  43.  
  44. ============================= Simple integers ================================
  45.  
  46. First we have ²decimal integers :
  47.  
  48. < disp 5 <enter>
  49. > 00000005 , 5
  50.  
  51. < disp 1236 <enter>
  52. > 000004D4 , 1236
  53.  
  54. < disp -100 <enter>
  55. > FFFFFF9C , -100
  56.  
  57. But not (can you see why ?) :
  58.  
  59. < disp 01236 <enter>
  60. > 00001236 , 4662
  61.  
  62. This last notation is used for ²²hexadecimal numbers :
  63.  
  64. < disp 01A <enter>
  65. > 0000001A , 26
  66.  
  67. < disp $1a <enter>
  68. > 0000001A , 26
  69.  
  70. You can see that PowerVisor has two ways to notate a hexadecimal number.
  71. PowerVisor interpretes '0<number>' as a hexadecimal number because this is
  72. very convenient if you 'snap' a hex number from the PowerVisor screen. Such
  73. a number almost always contains some leading zeroes.
  74.  
  75. Note that in the current version of PowerVisor the following command :
  76.  
  77. < disp 1A <enter>
  78.  
  79. does not give an error :
  80.  
  81. > 00000001 , 1
  82.  
  83. This is in fact a bug and it will be solved in a later version of PowerVisor.
  84.  
  85. =============================== Expressions ==================================
  86.  
  87. You can use more complex ¹expressions :
  88.  
  89. < disp 5+5 <enter>
  90. > 0000000A , 10
  91.  
  92. < disp 1+(5*9)-(3&5) <enter>
  93. > 0000002D , 45
  94.  
  95. Note that you cannot use spaces in expressions.
  96.  
  97. You can use the following binary operators. The list is from high to
  98. low priority :
  99.  
  100.   * / %       ¹¹multiply, ²²integer divide, ¹¹remainder
  101.   + -         ¹¹add, ¹¹subtract
  102.   << >>       ²²left shift, ²²right shift
  103.   > < >= <=   ²²integer comparisons
  104.   != ==       ³³not equal to, ²²equal to
  105.   &           ²²bitwise and
  106.   ^           ²²bitwise xor
  107.   |           ²²bitwise or
  108.   &&          ²²logical and
  109.   ||          ²²logical or
  110.  
  111. There are also some ²²unary operators :
  112.   -           ¹¹negation
  113.   !           ²²logical not
  114.   ~           ²²bitwise not
  115.   *           ²²contents operator
  116.   &           ²²address operator (explained later)
  117.  
  118. You can also use brackets.
  119. Some examples :
  120.  
  121. < disp 5+(9-(7*(5/(3+~1 <enter>
  122. > FFFFFFEB , -21
  123.  
  124. Note that you need not close all brackets.
  125.  
  126. The contents operator needs some more examples :
  127.  
  128. < disp *4 <enter>
  129. > 07E007E4 , 132122596
  130.  
  131. (This is the pointer to execbase)
  132.  
  133. < disp *4.b <enter>
  134. > 00000007 , 7
  135.  
  136. < disp *4.w <enter>
  137. > 000007E0 , 2016
  138.  
  139. < disp *(2+2).l <enter>
  140. > 07E007E4 , 132122596
  141.  
  142. The syntax of the * operator is:
  143.    '*'<expression>['.' ('b' | 'w' | 'l') ]
  144. 'b', 'w' and 'l' are the size indicators (b = byte, w = word, l = long).
  145. If you do not specify '.', PowerVisor assumes long mode. This operator checks
  146. for illegal addresses :
  147.  
  148. < disp *5 <enter>
  149. > Odd address error !
  150.  
  151. On the ¹68000 processor you cannot read a long at an ²odd address.
  152. PowerVisor will always give this error even if you have a ¹68020/68030
  153. processor.
  154.  
  155. ============================= String pointers ================================
  156.  
  157. A ²²string pointer is NOT a string, it is an integer. When you use a string
  158. pointer, PowerVisor will allocate a temporary space for this string and
  159. give you the address. Example :
  160.  
  161. < disp "Hello" <enter>
  162. > 07E50E52 , 132451922
  163.  
  164. < memory 07E50E52 10 <enter>
  165. > 07E50E52: 68656C6C 6F0007E2 1010                           Hello.....
  166.  
  167. PowerVisor remembers the last 10 strings and string pointers (all in one
  168. pool) before it frees them. This means that you can only use 10 string
  169. pointers in one command at the same time.
  170. If you want a permanent string pointer you can use the 'alloc' function.
  171.  
  172.  
  173. The next example illustrates the use of the ²contents operator (*) and
  174. a string pointer :
  175.  
  176. < disp *("Hello"+1).b <enter>
  177. > 00000065 , 101
  178.  
  179. (101 is the ascii value for 'e').
  180.  
  181. Look at the following example :
  182.  
  183. < memory "Left\41\42\43Right" 16 <enter>
  184. > 07EC98A2: 4C656674 41424352 69676874 000007EC              LeftABCRight....
  185.  
  186. The '\' notation is useful for ²unprintable characters (and untypable).
  187. After the '\' follow two hexadecimal digits. If the first character following
  188. the '\' is not a hexadecimal digit the first '\' is ignored :
  189.  
  190. < memory "Left\\Right" 10 <enter>
  191. > 07E5C0BA: 4C656674 5C526967 6874                           Left\Right
  192.  
  193. < memory "Left\"Right" 10 <enter>
  194. > 07E5C0BA: 4C656674 22526967 6874                           Left"Right
  195.  
  196.  
  197. There is one extra feature that you have with quoting. Consider the
  198. following example :
  199.  
  200. < memory "Left\(4+5)Right" 16 <enter>
  201. > 07E31A72: 4C656674 39526967 68740000 00000000              Left9Right......
  202.  
  203. The expression between the two brackets can be as complex as you wish.
  204. You can use variables, functions, ...
  205. You can use an optional ²format string directly after the expression (include
  206. some white space of course). Use standard ¹C-formatting conventions :
  207.  
  208. < memory "Left(4+5,%02ld)Right" 16 <enter>
  209. > 07E31A72: 4C656674 30395269 67687400 00000000              Left09Right.....
  210.  
  211. < memory "Left(65,%lc)Right" 16 <enter>
  212. > 07E31A72: 4C656674 41526967 68740000 00000000              LeftARight......
  213.  
  214.  
  215. ================================== Names =====================================
  216.  
  217. ¹¹Names are probably the most difficult things in the PowerVisor parsing
  218. language. They can be almost everything. I think examples are the best
  219. way to illustrate their purpose :
  220.  
  221. < task <enter>
  222. < list <enter>
  223.  
  224. > Task node name      : Node     Pri StackPtr  StackS Stat Command        Acc
  225. > ---------------------------------------------------------------------------
  226. > RAM                 : 07E25260 00  07E2554E    1200 Rdy             PROC -
  227. > Background Process  : 07E26BA8 00  07E2CBD8    4000 Wait iprefs     (02) -
  228. > RexxMaster          : 07E39BA8 04  07E3A3EA    2048 Wait            (00) -
  229. > SYS:System/CLI      : 07E529C0 00  07E538CA    4096 Wait            (00) -
  230. > ramlib              : 07E1F680 00  07E1FE80    2048 Wait            PROC -
  231. > CON                 : 07E56A20 05  07E57522    3200 Wait            PROC -
  232. > Background CLI      : 07E65518 00  07E65F66    3200 Wait            (01) -
  233. > console.device      : 07E0E1A2 00  07E0F1A4    4096 Wait            TASK -
  234. > PowerSnap 1.0 by Nic: 07E48450 05  07E48C9A    2000 Wait            PROC -
  235. > WB_2.x              : 07E11488 0A  07E11E4E    2400 Wait            PROC -
  236. > DF0                 : 07E17208 0A  07E17BCE    2400 Wait            PROC -
  237. > Workbench           : 07E54930 01  07E56956    8192 Wait            (05) -
  238. > PowerVisor1.0.task  : 07E7CBE0 00  07E7D096    1024 Wait            TASK -
  239. > SCSI bus handler    : 07E0AFD0 0C  07E0B3B6    1000 Wait            TASK -
  240. > scsi.device         : 07E0A3F8 0B  07E0A396    1000 Wait            TASK -
  241. > trackdisk.device    : 07E0F988 05  07E0FB96     512 Wait            TASK -
  242. > Work                : 07E19940 0A  07E1A306    2400 Wait            PROC -
  243. > Background Process  : 07E3B4A0 00  07E52354    4000 Wait clock      (03) -
  244. > input.device        : 07E08AF2 14  07E09AF8    4096 Wait            TASK -
  245. > Background Process  : 07E7B418 04  07E8E386    4000 Run  pv         (04) -
  246.  
  247. < disp powervisor <enter>
  248. > 07E7CBE0 , 132631520
  249.  
  250. In this case we used a name ('powervisor') as an ¹abbreviation for an element
  251. in the ²current list. We could also have written :
  252.  
  253. < disp POWERvi <enter>
  254.  
  255. or
  256.  
  257. < disp 'Powervisor1' <enter>
  258.  
  259. or
  260.  
  261. < disp power <enter>
  262.  
  263. The last command is correct but it is ambiguous in this case since there are
  264. two names in the current list beginning with 'power'. When this is the case
  265. the first match is used (PowerSnap 1.0 in this case).
  266.  
  267. Important to remember is that when we use names for this purpose the
  268. following rules apply :
  269.  
  270.   - you may use quotes (if you want to include spaces for example)
  271.   - the searching is case insensitive
  272.   - you can use abbreviations, i.e. you need not give the full name
  273.  
  274. Consider the following example :
  275.  
  276. < powervisor=5 <enter>
  277.  
  278. < disp powervisor <enter>
  279. > 00000005 , 5
  280.  
  281. < disp 'powervisor' <enter>
  282. > 07E7CBE0 , 132631520
  283.  
  284. < disp powerviso <enter>
  285. > 07E7CBE0 , 132631520
  286.  
  287. < disp powervisor1 <enter>
  288. > 07E7CBE0 , 132631520
  289.  
  290. We have created a ¹¹variable 'powervisor' with value 5. The name 'powervisor'
  291. has now lost it's meaning as an abbreviation for an element in the current
  292. list. Note that we can still use 'powerviso' and 'powervisor1' for the
  293. element in the current list.
  294. So we see that the following rules apply for variables :
  295.  
  296.   - you can't use quotes for variable names (if you do it is interpreted
  297.     as an element in the current list)
  298.   - variable names can't be abbreviated
  299.   - variable names are case insensitive
  300.  
  301. When you use quotes you ²force interpretation of the ²current list. There
  302. is a shorter and better way to do this (also see the 'List operator'
  303. section) :
  304.  
  305. < disp :powervisor <enter>
  306. > 07E7CBE0 , 132631520
  307.  
  308. Now we remove the created variable :
  309.  
  310. < remvar powervisor <enter>
  311.  
  312. There is still a third way to interprete names. But it is at this moment
  313. not appropriate to give examples. A name can also be a ¹symbol
  314. for the ³current debug task (see debugging). The rules for symbol names
  315. are :
  316.  
  317.   - you can use quotes
  318.   - symbol names are case sensitive
  319.   - no abbreviations are possible
  320.  
  321. In case of ambiguity observe the following order of checking :
  322.  
  323.   - PowerVisor will first check if it is a variable
  324.   - If it is not a variable it could be a symbol for the current debug task
  325.   - If it is not a symbol PowerVisor will search the current list
  326.  
  327. If you use quotes for the name, PowerVisor will skip the variable testing
  328. and only test if it is a symbol or a list element. If you use the ':'
  329. operator (see above) PowerVisor will only search the current list.
  330.  
  331.  
  332. ================================ Functions ===================================
  333.  
  334. ¹¹Functions are a special form of ¹variables. Internally they are almost the
  335. same. Type :
  336.  
  337. < help functions <enter>
  338.  
  339. > General functions
  340. > -----------------
  341. > ALLOC      : allocate memory          LASTMEM    : give last memory
  342. > FREE       : free memory              LASTFOUND  : last search address
  343. > REALLOC    : reallocate memory        PEEK       : peek value in structure
  344. > GETSIZE    : give size of memoryblock APEEK      : peek address
  345. > ISALLOC    : is memory a pv-block ?   STSIZE     : get structure size
  346. > KEY        : returns pressed key      RFCMD      : refresh command
  347. > QUAL       : qualifier for last key   RFRATE     : refresh rate
  348. > GETCOL     : get logical col width    GETLWIN    : current logical window
  349. > GETROW     : get logical row height   GETERROR   : get error of routine
  350. > TOPPC      : get debug win top pc     TAGLIST    : get current tag list
  351. > BOTPC      : get debug win bottom pc  EVAL       : evaluate argument string
  352. > ISBREAK    : check if breakpoint      IF         : conditional evaluation
  353. > GETDEBUG   : get current debug ptr    CURLIST    : current list
  354. > GETX       : get the current x coord  COLS       : get max nr of cols
  355. > GETY       : get y coord              LINES      : get max nr lines
  356. > GETCHAR    : get the current char     BASE       : get first listelem
  357.  
  358. Since functions are so much like variables the same evaluation rules apply
  359. to them (see the previous section: 'names'). You must use the full name
  360. (no abbreviations). The only exception is that you must use brackets after
  361. the function name even if there are no arguments.
  362.  
  363. Some examples :
  364.  
  365. < disp lines(main)
  366. > 00000035 , 53
  367.  
  368. This means that I have 53 lines on my PowerVisor screen.
  369. (See the 'screen' manual for more complete information about this function).
  370. 'main' is the argument for the function.
  371.  
  372. The following is incorrect (There is a space between 'lines' and '(main)') :
  373.  
  374. < disp lines (main)
  375. > You must use brackets with functions !
  376.  
  377. The following is correct (You need not close the brackets) :
  378.  
  379. < disp cols(main
  380. > 00000056 , 86
  381.  
  382. ============================ Library functions ===============================
  383.  
  384. PowerVisor has the very powerful capability to execute ²library functions.
  385. You only need to load the corresponding ¹fd-file (in the fd2.0 or fd1.3
  386. subdirectory) :
  387.  
  388. < loadfd exec :fd2.0/exec_lib.fd <enter>
  389.  
  390. or
  391.  
  392. < loadfd libs:exec :fd2.0/exec_lib.fd <enter>
  393.  
  394. > New functions: 0000007E,126
  395.  
  396. PowerVisor will then know how to call all functions from the exec library.
  397.  
  398. You can now use all the exec library functions as if they were normal
  399. PowerVisor functions :
  400.  
  401. < disp typeofmem(100000) <enter>
  402. > 00000303 , 771
  403.  
  404. < disp openlibrary("exec.library",0) <enter>
  405. > 07E007E4 , 132122596
  406.  
  407. The following rules for ²²library functions apply :
  408.  
  409.   - you MUST use brackets even if there are no arguments (like functions)
  410.   - you MUST close the brackets for the library function arguments. This
  411.     means that if you use an expression as an argument you must close the
  412.     brackets for this expression as well
  413.   - you cannot use abbreviations for library functions
  414.   - library function names are case insensitive
  415.   - you cannot use quotes
  416.  
  417. ============================ The list operator ===============================
  418.  
  419. Example :
  420.  
  421. < exec <enter>
  422. < list <enter>
  423.  
  424. > SoftVer      : 00CF     | LowMemChkSum : 0000     | ChkBase      : F81FF81B
  425. > ColdCapture  : 00000000 | CoolCapture  : 00000000 | WarmCapture  : 00000000
  426. > SysStkUpper  : 07E02248 | SysStkLower  : 07E00A48 | MaxLocMem    : 00200000
  427. > DebugEntry   : 00F82E28 | DebugData    : 00000000 | AlertData    : 00000000
  428. > MaxExtMem    : 00000000 | ChkSum       : A366     | ThisTask     : 07E7B418
  429. > IdleCount    : 000CC6E6 | DispCount    : 0005444A | Quantum      : 0004
  430. > Elapsed      : 0004     | SysFlags     : 0000     | IDNestCnt    : FF
  431. > TDNestCnt    : F4       | AttnFlags    : 0017     | AttnResched  : 0000
  432. > ResModules   : 07E00428 | TaskTrapCode : 07E80AE6 | TaskExceptCod: 00F83A9C
  433. > TaskExitCode : 00F823D0 | TaskSigAlloc : 0000FFFF | TaskTrapAlloc: 8000
  434. > VBlankFreq   : 32       | PowerSupplyFr: 32       | KickTagPtr   : 00000000
  435. > KickCheckSum : 00000000 | RamLibPrivate: 07E1F470 | EClockFreq   : 000AD303
  436. > CacheCtrl    : 00002919 | TaskID       : 00000001 | PuddleSize   : 00000000
  437. > MMULock      : 00000000 |
  438.  
  439. We are now in the execbase ²structure list.
  440.  
  441. < disp quantum <enter>
  442. > 00000004 , 4
  443.  
  444. The same rules apply as for normal list element searching (see the 'Names'
  445. section).
  446.  
  447. If there are possible ambiguities you can use the ':' operator.
  448.  
  449. < disp :quantum <enter>
  450. > 00000004 , 4
  451.  
  452. If you want to change the quantum variable you can use the '&' operator
  453. (This operator is only supported for lists of this type (exec, graf, intb,
  454. ...)) :
  455.  
  456. < disp &exec:quantum <enter>
  457. > 07E00904 , 132122884
  458.  
  459. This operator returns the address of the quantum variable in the exec base
  460. list.
  461.  
  462. You can now use this address to change the variable (also see the 'Assignment'
  463. section) :
  464.  
  465. < *&exec:quantum.w=16 <enter>
  466.  
  467. You can also use the list name before the operator (useful if you are in
  468. another current list) :
  469.  
  470. < d exec:quantum <enter>
  471. > 00000004 , 4
  472.  
  473. =============================== Assignment ===================================
  474.  
  475. We have already used ¹¹assignment a few times. We used it to assign a value
  476. to a ¹variable, and we used it (in the previous section) to assign a value
  477. to a memory location. Here are some more examples :
  478.  
  479. < a=4 <enter>
  480. < b=5 <enter>
  481. < disp a+b <enter>
  482. > 00000009 , 9
  483.  
  484. < var100=100 <enter>
  485. < var100=var100+var100 <enter>
  486. < disp var100+var100 <enter>
  487. > 00000190 , 400
  488.  
  489. In this form we use assignment to assign a value to a variable.
  490.  
  491. Do not put spaces arround the '=' operator. Otherwise PowerVisor will
  492. try to execute the variable as a command and the '=' as an argument.
  493.  
  494. One more example :
  495.  
  496. < mem=alloc(n,100) <enter>
  497. < *mem=$11111111 <enter>
  498. < *(mem+4).w=$2222 <enter>
  499. < *(mem+6).b=$33 <enter>
  500.  
  501. < memory mem 16 <enter>
  502. > 07E7761A: 11111111  22223300  00000000  00000000           ....""3.........
  503.  
  504. < void free(mem) <enter>
  505.  
  506. With the 'alloc' function we allocated 100 bytes of memory. (The 'n' argument
  507. means the next argument is a number (see the 'alloc' function for more
  508. details). Then we fill this memory with some values. With the 'memory'
  509. command we display them.
  510. After that we use the 'free' function to free our ²allocated memory. Note
  511. that PowerVisor will automatically ²free memory allocated with 'alloc' when
  512. PowerVisor quits.
  513.  
  514. =========================== The group operator ===============================
  515.  
  516. Sometimes it is conveniant to ³group several commands together. You can do
  517. just this with the ²²group operator. You can use the group operator in two
  518. different ways. As a command or as a function. Here are some examples :
  519.  
  520. Using the group operator as a command :
  521.  
  522. < {disp 3;disp 5;disp 7} <enter>
  523. > 00000003 , 3
  524. > 00000005 , 5
  525. > 00000007 , 7
  526.  
  527. < {{disp 1;{{disp 2};disp 3};disp 4};disp 5} <enter>
  528. > 00000001 , 1
  529. > 00000002 , 2
  530. > 00000003 , 3
  531. > 00000004 , 4
  532. > 00000005 , 5
  533.  
  534. < {a=2;b=3;disp a*b} <enter>
  535. > 00000006 , 6
  536.  
  537. You can see that the sole purpose of this operator is to allow you to
  538. give more than one command on the commandline. This can be very useful
  539. when some command expects another command as an argument (see the
  540. 'refresh' command).
  541.  
  542. You can also use the group operator as a function :
  543.  
  544. < disp {a=4}*2 <enter>
  545. > 00000008 , 8
  546.  
  547. This command will first assign 4 to 'a' and then execute 'disp 4*2'.
  548.  
  549. < disp {a=4;temp=a*7;void temp+temp*(temp/4)} <enter>
  550. > 000000E0 , 224
  551.  
  552. The 'void' command simply evaluates all it's arguments. It does not
  553. display anything.
  554.  
  555. < disp {disp 1}+2 <enter>
  556. > 00000001 , 1
  557. > 00000003 , 3
  558.  
  559. When the group operator is used as a function, it is the last executed
  560. command in this group that determines the ²return value. The return value
  561. is different for each command. Look at the command reference for more
  562. details.
  563.  
  564. ================================= Strings ====================================
  565.  
  566. All previous sections covered integers. PowerVisor also uses ¹¹strings. A
  567. string is very easy. When a command expects a string, almost everything
  568. is correct. Some examples :
  569.  
  570. < print Hello <enter>
  571. > Hello
  572.  
  573. < print Hello\0a <enter>
  574. > Hello
  575.  
  576. Notice the difference between these two commands. If you do not explicitely
  577. ask for a <enter> at the end of the line you will not get one. '\0a' is the
  578. linefeed character.
  579.  
  580. < print 'Hello\0a' <enter>
  581. > Hello
  582.  
  583. < print 5+6 <enter>
  584. > 5+6
  585.  
  586. < print Complete rubbish <enter>
  587. > Complete
  588.  
  589. < print 'Complete rubbish' <enter>
  590. > Complete rubbish
  591.  
  592. < print 'Complete rubbish <enter>
  593. > Complete rubbish
  594.  
  595. < print "Complete rubbish" <enter>
  596. > Complete rubbish
  597.  
  598. < print 'a\0ab\0ac\0ad\0a' <enter>
  599. > a
  600. > b
  601. > c
  602. > d
  603.  
  604. < print Hello\ you <enter>
  605. > Hello you
  606.  
  607. < print 'Hello you' <enter>
  608. > Hello you
  609.  
  610. Strings are very versatile. Even the notation for ²string pointers (double
  611. quotes) is accepted.
  612.  
  613. There is one exception :
  614.  
  615. < a="Hello there\0a" <enter>
  616. < print a <enter>
  617. > a
  618.  
  619. < print #a <enter>
  620. > Hello there
  621.  
  622. You can use the ²# operator to interprete a string pointer in a variable
  623. as a string. You can't simply use the variable because PowerVisor will parse
  624. this as if it was a string. You must preceed the variable with a '#'.
  625. The expression after the '#' operator is not limited to variables only, you
  626. can use complex expressions.
  627.  
  628. Strings (like string pointers) also support the special integer quoting
  629. feature :
  630.  
  631. < a=1 <enter>
  632. < print 'Testing \(a) \(2,%03ld) \(11+11+11,%04lx) \(65,%lc) !\0a' <enter>
  633. > Testing 1 002 0021 A !
  634.  
  635. < print 'First string : \("Second string",%6.6s).\0a' <enter>
  636. > First string : Second.
  637.  
  638.  
  639. ========================== Some useful functions =============================
  640.  
  641. You can make ²²conditional expressions using the 'if' function. Here is an
  642. example :
  643.  
  644. < a=2 <enter>
  645. < disp if(a==2,1000+5,2000) <enter>
  646. > 000003ED , 1005
  647.  
  648. A very complex example :
  649.  
  650. < disp if(a==3,{disp 3*3;void 1},if(a==2,{disp 2*2;void 1},0))
  651. > 00000004 , 4
  652. > 00000001 , 1
  653.  
  654. This completely useless command computes the square of the variable 'a',
  655. but only if 'a' is equal to 2 or to 3. It also prints the value 1 if 'a'
  656. is equal to 2 or to 3, and 0 if it isn't.
  657.  
  658. I think some detailed explanation can be useful here :-)
  659.  
  660.    The 'disp' command takes it's first argument and prints it.
  661.    This argument is equal to :
  662.  
  663.       if(a==3,{disp 3*3;void 1},if(a==2,{disp 2*2;void 1},0))
  664.  
  665.    The first thing that is evaluated is the 'if' function. The 'if' function
  666.    has three arguments :
  667.  
  668.       one number :
  669.          a==3
  670.  
  671.       and two other expressions :
  672.          {disp 3*3;void 1}
  673.          if(a==2,{disp 2*2;void 1},0)
  674.  
  675.    If 'a' is equal to 3 the first string is taken and evaluated.
  676.  
  677.       This results in evaluation of the following expression :
  678.  
  679.          {disp 3*3;void 1}
  680.  
  681.       This is a ²group expression (see the ²group operator). The group operator
  682.       executes all the commands in it and returns as a result the result
  683.       from the last executed command. This results in the execution of :
  684.  
  685.          disp 3*3
  686.  
  687.       and
  688.  
  689.          void 1
  690.  
  691.       So 9 is printed on the screen and 1 is returned as a result from
  692.       the group operator (the 'void' command simply evaluates all it's
  693.       arguments).
  694.  
  695.       So the result of the first 'if' function is 1 (but 9 is already
  696.       printed). This result is printed. So you have 9 and 1 as output.
  697.  
  698.       ! End evaluation !
  699.  
  700.    If 'a' is not equal to 3 the second string is taken and evaluated.
  701.  
  702.       This results in evaluation of the following string :
  703.  
  704.          if(a==2,{disp 2*2;void 1},0)
  705.  
  706.       This is again an 'if' expression and is evaluated analogous.
  707.  
  708. If you happen to have an ¹expression in a string (this could be a string typed
  709. in by the user) you can evaluate it using the 'eval' function :
  710.  
  711. Ask for input ('scan' returns a pointer to a string. We store the pointer in
  712. variable 'a') :
  713.  
  714. < a={scan} <enter>
  715.  
  716. Type an expression :
  717.  
  718. < 10+5 <enter>
  719.  
  720. See if the string is really correct :
  721.  
  722. < print #a <enter>
  723. > 10+5
  724.  
  725. Evaluate it :
  726.  
  727. < disp eval(#a) <enter>
  728. > 0000000F , 15
  729.  
  730. or you can of course type :
  731.  
  732. < disp eval('10+5') <enter>
  733. > 0000000F , 15
  734.