Home
documentation - Department of Computer Science
Contents
1. is an augmented assignment operation that increments the values by one A list can be obtained from a table by the function sort t i The form of the list depends on the value of i For example if iis 3 the list contains alternate keys and values oft An example of sorting is wordlist sort words 3 while write pop wordlist pop wordlist which writes the words and their counts from words Procedures An Icon program consists of a sequence of procedures An example of a procedure is procedure max i j if i gt j then return i else return j end where the name of the procedure is max and its formal parameters arei and j The return expressions return the value of i orj whichever is larger Proceduresare called like functions Thus k max S1 S2 assigns to k the size of the longer of the strings s1 and s2 A procedure also may generate a sequence of values by suspending instead of returning In this case a result is produced as in the case of a return but the procedure can be resumed to produce other results An example is the following procedure that generates the words in the input file procedure genword letters amp lcase amp ucase while line read do line while tab upto letters do word tab many letters suspend word end Icon Language Overview 8 11 The braces enclose a compound expression Such a generator can be used in the same way that a built in generator is u
2. respectively in program text These character pairs are useful when writing programs that are to be run on IBM 370 systems whose input and output devices may not support braces and brackets Program Location Information A comment that begins at the beginning of a line and has the form line n f changes the currentsource program line number and filename recorded by the Icon translator to n and f respectively This information is used for example in error messages Appendix B Machine Dependencies and Limits There is no longer a distinction between short and long integers There is no limit on the length of a string that can be read Appendix C Running an Icon Program Linking The inclusion of intermediate files during linking canbe specified inasource file by using a link declaration which has the form link intermediate file names For example ifrsg icn contains the declaration link lib then lib u1 and lib u2 are included when the executable file for rsg is produced Note that the suffixes are not used in link declarations Several files can be specified in a comma separated list as in link lib listpak timer which specifies the linking of lib u1 listpak u1 timer u1 and the corre sponding u2 files File names that do not satisfy the syntax of Icon identifi ers must be enclosed in quotation marks An example is link set up Storage Management Storage is allocated automatically during the executio
3. 11 151 alternation 11 190 repeated alternation 11 191 string concatenation 8 2 11 131 augmented 11 151 list concatenation 11 132 augmented 11 151 complement 11 111 numericnotequal 11 141 augmented 11 151 string not equal 11 147 augmented 11 151 object notequal 11 149 augmented 11 151 subscripting 11 158 subscripting orsectioning 11 159 subscripting orsectioning 11 160 subscripting or sectioning 11 161 list creation 11 157 I 2 Index argument list 11 162 argument list 11 163 A About Prolcon 7 1 abs N 11 4 acos r 9 2 11 5 Allocation history files E3 E4 any c s i1 i2 11 6 args p 9 9 11 7 Argument evaluation 11 3 Arrowkeys 6 6 ASCII characterset 8 2 B 1 B 2 asin r 9 2 11 8 Assignment 8 3 Associativelookup 8 10 Associativity C 1 C 3 atan r1 r2 9 2 11 8a Auto Indent 6 7 7 4 Auto indentation 6 7 7 4 7 8 bal c1 c2 c3 s i1 i2 11 9 Balance 6 7 7 3 Balancing text 6 7 7 3 Binary operations SeeO perations infix Bit operations 9 1 9 2 Block region 4 15 9 9 9 10 break 9 10 11 177 Bugs 9 15 C callout s1 s2 x1 x2 xn 10 8 11 10 case of 11 178 case control expressions 11 178 center s1 i s2 11 10a changef s 10 7 11 11 char i 9 2 11 12 Character
4. C 5 C 6 S Save 3 6 6 4 7 1 Save All 6 5 7 5 Save As 3 1 6 5 7 1 Saving files 3 1 3 3 6 4 6 5 7 1 Saving windows 6 5 7 5 Scanning string 2 6 2 7 8 1 8 7 8 8 9 8 Scope 2 7 2 8 Screen 10 6 Scrolling 6 5 Search menu 5 5 5 6 6 6 6 8 6 11 7 3 Search paths 6 9 6 11 Searching and replacing 6 8 6 11 Searching text 7 3 Select All 6 3 7 2 Selecting text 6 3 7 2 seek f i 9 7 11 77 seq i1 i2 9 9 11 78 set L 8 10 9 2 11 79 Sets 8 10 9 3 9 4 Shift Left 6 7 7 2 Shift Right 6 7 7 2 Shifting text 6 7 7 2 sin r 9 2 11 80 SNOBOL4 2 1 2 4 2 9 8 8 sort X i 8 11 9 4 9 5 11 81 Sorting 8 11 9 4 9 5 9 6 sqrt r 9 2 11 82 Stack Windows 6 13 7 5 7 6 Stacks 8 9 Standard error output 4 9 Index l 9 Standard input 4 9 Standard output 4 9 Startup 6 13 7 5 Startup 6 13 7 8 Stop 4 16 7 5 stop x1 x2 xn 11 83 Stopping program execution 4 17 7 5 Storage allocation 4 13 4 16 8 1 Storage management 4 13 4 16 8 1 9 11 9 12 String comparison 4 5 10 1 B 1 B 8 String invocation 9 7 9 9 String region 4 14 4 15 9 11 9 12 String scanning 8 1 8 7 8 8 9 10 string x 11 84 Strings 2 2 8 2 8 3 9 2 Structures 2 2 8 8 8 11 9 2 9 4 Substrings 8 2 Success 2 5 Success and Failure 2 5 8 4 8 5 suspend do 8 11 9 9 9 10 11 187 Suspending program executi
5. F4 perform undo cut copy and paste respectively Closing and Saving It s prudent to save your work every 15 minutes or so since power failures and system crashes usually occur at the worst possible times To save a file without closing it use 36S or select Save from the File menu If you haven t named your file 6 4 Entering and Editing Programs File Signatures yet you get a standard file dialog to prompt you for a name To save a file and close its window you can click the close box at the left edge of the window s title bar If the file has been altered since it was last saved a dialog asks if you want the new version saved Again if it s untitled go through the standard file dialog to name it Another way to close a file isto use 3 W or the Close command in the Edit menu Both are equivalent to click ing the Close box on the window Saving a file does not alter its file type or creator signatures Prol con records information in the file s resource fork to remember font font size tab and compiler options Other resources in the file remain unchanged You can also save a file under a different name by selecting Save as in the File menu This launches the standard file dialog for the new name The original file remains unchanged The new filehasa TEXT filetype and Prolcon s creator signature H ere is a good technique when you re modifying a program and you want to keep
6. 119 set expected 120 cset or set expected 121 function not supported 122 set or table expected 123 invalid type 124 table expected 201 division by zero 202 remaindering by zero 203 integer overflow 204 real overflow underflow or division by zero 205 value out of range 206 negative first operand to real exponentiation 207 invalid field name 208 second and third arguments to map of unequal length 209 invalid second argument to open 210 non ascending arguments to detab entab 211 by value equal to zero 212 attempt to read file not open for reading 213 attempt to write file not open for writing 214 input output error Icon Language Checklists C 5 C 6 Icon Language Checklists 215 216 251 252 301 302 303 304 305 306 307 352 353 500 attempt to refresh amp main external function not found string too long for comparison window identifier expected evaluation stack overflow system stack overflow inadequate space for evaluation stack inadequate space in qualifier list inadequate space for static allocation inadequate space in string region inadequate space in block region inadequate space for XCM D interface could not load XCM D XFCN program malfunction D External Functions External Functions AsmentionedinC hapter 10 Prol con programscan load and execute functionswritten in other programming languages T hese external functionsincludeH yperC ard XC M D sand XFCN sasw
7. 2 s1 2 s1 lt lt 2 s1 s2 and amp compare Mini Reference Manual 11 145 1 lt lt S2 s2 comparelexically s1 lt lt s2 produces s2 if s1 islexicallylessthan orequalto s2 but fails otherwise Errors 103 s1 or s2 not string 306 inadequatespacein string region See also s1 gt gt s2 s1 gt gt 2 s1 2 s1 lt lt s2 s1 s2 and amp compare 11 146 Mini Reference Manual 1 S2 s2 comparelexically 1 s2 produces s2ifs1 isnot lexically equalto s2 but fails otherwise Errors 103 s1 or s2 not string 306 inadequatespacein sring region See also s1 gt gt s2 s1 gt gt 2 s1 2 1 lt lt 2 and s1 lt lt s2 Mini Reference Manual 11 147 X1 x2 x2 comparevalues x1 x2 producesthe valueof x2ifx1 and x2 have the same value but failsotherwise See also x1 x2 11 148 Mini Reference Manual X1 x2 x2 comparevalues x1 x2 producesthevalueof x2 if x1 and x2 do not have the same value but failsotherwise See also x1 x2 Mini Reference Manual 11 149 x1 x2 x1 assign value x1 x2 assignsthe valueof x2to x1 and producesthevariable x1 Errors 101 x1 requires integer but x2 not integer 103 x1 requires string but x2 not string 111 x1 notavariable See also x1 op x2 11 150 Mini Reference Manual X1 op x2 x1 augmented assignment x1 op x2 performsthe operation x1 opx2and assignsthe result to x1 it returns x1 asava
8. When you launch Prolcon again they re set back to the default values Program options and memory settings are persistent The paths you specify for library searches are also persis tent Persistent settings are saved in the Prolcon Profile in your system folder You can delete this file if you want to get back to Prolcon s initial settings Launching Executable Files If you hold down the option key when click launching an executable Prolcon file you get a dialog that allows you to set the parameter string specify input and output files and adjust execution memory regions Compiling and Running Programs 4 17 Stopping Prolcon You can terminate program compilation linking or execution by selecting Stop from the Run menu Caution Prolcon cannot stop all forms of program activity immedi ately If you want to suspend compilation linking or execu tion select Pause from the Run menu You then can resume by selecting Continue MultiFinder Prolcon is MultiFinder friendly It will run in the back ground if you let it When it needs input a small icon alternates with the symbol on the menu bar When running under MultiFinder you can adjust Prolcon s memory partition by highlighting the applica tion on the desktop and using Finder s Get Info command The number at the bottom of the screen is the partition size You can launch another application from Prolcon using launch as described in Chapter 10 If MultiF
9. e e eg Mt 73 aie tat displayed 78 NNna arelike 79 0O00000G06 28 06668 85 UUUUUUGUOE 89 YYyy 91 92 93 String Comparison B 5 B 6 String Comparison 94 95 96 123 124 125 126 127 160 173 174 fi fl B 176 189 192 198 201 208 209 214 215 218 221 224 228 240 246 251 253 a ma Q mY seethe text for additional information about ligatures Other Languages Corresponding tables for other languages differ in small ways H ere are examples of some of the differences The list is not exhaustive but instead gives an overview of the orderings possible with the international string comparison system British The pound currency symbol appears between the quotation mark class and the sharp symbol 34 gw yp 165 35 German Characters with umlauts are expanded to the appropriate two letters so that A is expanded to AE It appears in the secondary ordering between the expanded two letter sequence and any equivalent ligature Thus the orderings are AE A ae OE O oe ce UE U ue Customizing The assembly language programs that control the interna tional comparison process are provided by Apple and reside within your system file The built in core of the comparison system is never altered Instead functionsin the _ itl2 resource accommodate differences from the default actions The simplest method of collating under a different lan guage i
10. i errors to convert to failure If the value of amp error is nonzero a runtime error is converted to expression failure and amp error isdecremented amp error is zero initially amp errorisa variable amp errornumber i number of last error The value of amp errornumber is the number of the last error converted to failure amp errornumber fails if no error has occurred Mini Reference Manual 11 167 amp errortext s description of last error The value of errortext is the error message corresponding to the last error converted to failure amp errortext fails if no error has occurred amp errorvalue x value causing last error The value of amp errorvalue is the value that caused the last error converted to failure amp errorvalue fails if no error has occurred or no specific value caused the error amp errout f standard error output The value of amp errout is standard error output Standard error output defaults to the Intertactive window but it may be redirected elsewhere using the Error Output dialog amp fail failure amp fail simply fails 11 168 Mini Reference Manual amp features 1 2 Sn implementation features The value of amp features generates strings identifying the features of the executing version of Icon amp file s source file The value of amp file is the name of the file from which the current program line was compiled amp ftrace i function tracing If th
11. right edge of the window the window scrolls to the right To go back and forth use the scroll bar at the bottom Selecting Text Text may be selected by placing the mouse at one end of the desired selection and holding the mouse button down while dragging in either direction The selection sticks when the mouse button is released Selected text is displayed by a reverse highlight white letters on a black background If the mouse button is pressed and released without dragging a cursor appears between characters of text There are other methods of selecting text Positioning the mouse pointer over a word and double clicking selects the entire word triple clicking selects the entire line Finally typing 3A or choosing Select All from the Edit menu selects all text in a window An existing selection can be extended or shortened by holding down the shift key prior to pressing the mouse button Clipboard Prolcon supports the M acintosh clipboard as a place to temporarily store text The clipboard can hold up to 32 767 characters of text The clipboard may be used to move text between windows applications desk accesso ries or dialogs that accept text input You can delete and place selected text on the system clipboard by typing X or by choosing Cut from the Edit menu Selected text can be deleted without altering the Entering and Editing Programs 6 3 clipboard by pressing the delete
12. shift shift shift shift 3 Shift option del option U shift A shift option A shift option C option E shift E option N shift N option U shift O option U shift U option E A option A option l A option U A option N A option A option C option E E option E option l E option U E option E option option l option U option N N option E O option O option l O option U O dec 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 oct 233 234 235 236 237 240 241 242 243 244 245 246 247 250 251 252 253 254 255 256 257 260 261 262 263 264 265 266 267 270 271 272 273 274 275 276 277 300 301 302 303 e S O o 3 oO i o a amp TOOTA ot eR e wma TM SE KV IA H 8g QAH o Zaire egy Symbol vil oebk e exiv SH oH DEPT Ree RH SN B So Boat Zapf dingbats SPOOSCSOOSSPSFOOSSOHGAPAOG HOHOMw SH HE EY Ee 0m keyboard sequence option N O option E U option U option l U option U U option T shift option 8 option 4 option 3 option 6 option 8 option 7 option S option R option G option 2 option E option E option U option U option shift option shift option O option 5 shift option option option option Y option M option D option W
13. shift option P option P option B option 9 option 0 option Z option option O shift option option 1 option L option V Character Codes A 7 dec oct hex Times Symbol Zapf dingbats keyboard sequence 196 304 c4 f option F 197 305 c5 option X 198 306 c6 A option J 199 307 c7 A option 200 310 c8 U shift option 201 311 c9 P D gt option 202 312 ca option space 203 313 cb A t 2 option shift A 204 314 cc A Cc option N shift A 205 315 cd c 4 option N shift O 206 316 ce shift option Q 207 317 cf ce option Q 208 320 do Zz 7 option 209 321 d1 V shift option 210 322 d2 7 option 211 323 d3 g shift option 212 324 d4 t TM gt option 213 325 d5 Il gt shift option 214 326 d6 y lt gt option 215 327 d7 gt t shift option V 216 330 d8 a option U Y 217 331 d9 Y A gt shift option 218 332 da v 7 shift option 1 219 333 db a lt gt shift option 2 220 334 dc lt lt gt shift option 3 221 335 dd gt T gt shift option 4 222 336 de fi gt gt shift option 5 223 337 df fl U shift option 6 224 340 e0 kn Q gt shift option 7 225 341 el shift option 9 226 342 e2 gt shift option 0 227 343 e3 5 gt shift option W 228 344 e4 o gt shift option E 229 345 65 L shift option R 230 346 E ad shift option T 231 347 e7 shift option Y 232 350 8 N gt shift option U 233
14. values are sorted in order of the time of their creation with the oldest last Chapter 7 Procedures Page 69 Scope Declarations The reserved word dynamic which was synonymous with local is no longer available Page 73 Procedures with a Variable Number of Arguments A proce dure can be made to accept a variable number of arguments by append ing to the last or only parameter in the parameter list An example is procedure sum a b c total a b i 0 while total c i 1 return total end If called as sum 1 2 3 4 5 the parameters have the following values a 1 b 2 c 3 4 5 The last parameter always contains a list This list consists of the arguments not used by the previous parameters If the previous param eters use up all the arguments the list is empty If there are not enough 9 6 Version 8 of Icon arguments to satisfy the previous parameters the null value is used for the remaining ones but the last parameter still contains the empty list Page 74 Invocation with a List of Values The operation p L invokes p with the arguments in the list L The example p 1 2 3 is equivalent to p 1 2 3 The operation p L has high precedence and associates to the left Chapter 9 Input and Output Page 93 Values Returned by Output Functions The last argument written is returned by write and writes but it is not converted to a string Page 93 Random Access Input and Output There are t
15. 10 7 11 55 mmout s 9 15 11 55a mmpause s 9 15 11 55b mmshow x s 9 15 11 55c Functions cont move i 8 7 8 8 11 55d name x 9 9 11 56 numeric x 11 57 open s1 s2 11 58 ord s 9 2 11 59 pop L 8 9 11 60 pos i 11 61 proc x i 9 8 11 62 pull L 11 63 push L x 8 9 11 64 put L x 11 65 putfile s1 s2 s3 10 8 11 66 read f 8 2 11 67 reads f i 11 68 real x 11 69 remove s 9 7 11 70 rename s1 s2 9 7 11 71 repl s i 11 72 reverse s 11 73 right s1 i s2 11 74 rtod r 9 2 11 75 runerr i x 9 13 9 14 11 76 seek f i 9 7 11 77 seq i1 i2 9 9 11 78 set L 8 10 9 2 11 79 sin r 9 2 11 80 sort X i 8 11 9 4 9 5 11 81 sqrt r 9 2 11 82 stop x1 x2 xn 11 83 string x 11 84 tab i 8 7 8 8 11 85 table x 8 10 11 86 tan r 9 2 11 87 trim s1 c 11 88 type x 11 89 upto c s i1 i2 8 4 11 90 variable s 11 90a warrange i 10 5 10 6 11 91 wclose i s 10 4 11 92 wfont i s 10 6 11 93 wfontsize i1 i2 10 6 11 94 wget i1 i2 10 4 11 95 wgoto i1 i2 i3 10 6 11 96 where f 9 7 11 97 wlimit it i2 10 6 11 98 wmove it i2 i3 10 5 11 99 wopen s1 S2 10 3 10 4 11 100 woprint it i2 i3 10 6 11 101 write x1 x2 xn 8 2 9 7 11 102 writes x1 x2 xn 9 7 11 103 wselect i1 i2 i3 10 6 11 104 wset i1 i2 10 4 10 5 11 105 wsize i1 i2 i3 10 5 11 106 wtextwidth i1 s 10 6 11 107 G Garbage collecti
16. 11 126 augmented 11 151 amp conjunction 11 135 amp augmented amp 11 151 product 9 3 11 124 augmented 11 151 xx intersection 9 4 11 130 augmented 11 151 sum 11 122 augmented 11 151 union 8 3 9 4 11 128 augmented 11 151 numeric difference 11 123 augmented 11 151 cset or set difference 8 3 9 4 11 129 augmented 11 151 quotient 11 125 field reference 11 133 augmented 11 151 assignment 11 150 exchange 11 152 lt reversible assignment 11 153 lt gt reversible exchange 11 154 Index I 7 O perations infix cont lt numeric less than 11 139 lt augmented lt 11 151 lt lt string lessthan 11 145 lt lt augmented lt lt 11 151 string less than or equal 11 146 lt lt augmented lt lt 11 151 lt numeric less than or equal 11 140 ER lt 11 151 n numeric equal 11 138 augmented 11 151 string equal 11 144 augmented 11 151 object equal 11 148 augmented 11 151 gt numeric greater than 11 136 gt augmented gt 11 151 gt numeric greater than or equal 11 137 gt augmented gt 11 151 gt gt string greater than 11 142 augmented gt gt 11 151 gt string greater than or equal 11 143 gt gt augmented gt gt 11 151 trans
17. 11 140 Mini Reference Manual N1 N2 N2 comparenumerically N1 N2 produces N2 if N1 isnot numerically equal to N2 but fails otherwise Error 102 N1 or N2not integer or real See also N1 gt N2 N1 gt N2 N1 N2 N1 lt N2 and N1 lt N2 Mini Reference Manual 11 141 s1 gt gt s2 s2 comparelexically s1 gt gt s2 produces s2ifs1 islexically greater than s2 but fails otherwise Errors 103 s1 or s2 not string 306 inadequatespacein string region See also s1 gt gt 2 s1 2 s1 lt lt 2 s1 lt lt s2 s1 s2 and amp compare 11 142 Mini Reference Manual s1 gt gt S2 s2 comparelexically s1 gt gt s2 produces s2 if s1 islexically greater than or equalto s2 but failsotherwise Errors 103 s1 or s2 not string 306 inadequatespacein string region See also s1 gt gt s2 s1 s2 s1 lt lt 2 s1 lt lt s2 s1 s2 and amp compare Mini Reference Manual 11 143 s1 S2 s2 comparelexically s1 s2 produces s2ifs1 islexicallyequalto s2 but fails otherwise Errors 103 s1 or s2 not string 306 inadequatespacein string region See also s1 gt gt s2 s1 gt gt 2 s1 lt lt 2 s1 lt lt s2 and s1 s2 11 144 Mini Reference Manual s1 lt lt S2 s2 comparelexically 1 lt lt s2 produces s2ifs1 islexicallylessthan s2 but failsotherwise Errors 103 s1ors2not string 306 inadequatespacein string region See also s1 gt gt s2 s1 gt gt
18. 4 16 Persistent Settings 4 17 Launching Executable Files 4 17 Stopping Prolcon 4 17 MultiFinder 4 17 Online Help 5 1 Entering and Editing Text 6 1 The Editor 6 1 The Interactive Window 6 11 Window Management 6 12 Startup Options 6 13 Menu Reference 7 1 Keyboard Shortcuts 7 6 Window Shortcuts 7 8 The Icon Programming Language Icon Language Overview 8 1 Introduction 8 1 Strings 8 2 Character Sets 8 3 Expression Evaluation 8 4 String Scanning 8 7 Structures 8 8 Procedures 8 11 An Example 8 12 10 11 Version 8 of icon 9 1 Prolcon Extensions 10 1 String Comparison 10 1 Function Tracing 10 1 Termination Dump 10 2 System Dependent Features 10 3 Window Functions 10 3 Other Functions 10 7 External Functions 10 8 Mini Reference Manual 11 1 Functions 11 3 Prefix Operations 11 108 Infix Operations 11 121 Other Operations 11 155 Keywords 11 164 Control Structures 11 176 vi Appendices and Index Character Codes A 1 Keyboard Chart A 3 String Comparison B 1 Default Comparison B 1 International Comparison B 2 Icon Language Checklists C 1 Operator Precedence C 1 Reserved Words C 3 Generators C 4 Run Time Error Messages C 5 External Functions D 1 Locating External Functions D 1 Managing Resources D 2 Global and Static Data D 2 Accessing QuickDraw D 4 Interfacing XCMDs and XFCNs D 5 Interfacing Other Code Resources D 8 Conclusion D 14 Memory Monitoring E 1 Storage Management E 1 Allocation History Fil
19. C 11 134 Mini Reference Manual x1 amp x2 x2 evaluate in conjunction x1 amp x2 produces x2 It produces a variable if x2 is a variable Mini Reference Manual 11 135 N1 gt N2 N2 comparenumerically N1 gt N2 produces N2 if N1 isnumerically greater than N2 but fails otherwise Error 102 N1 or N2not integer or real See also N1 gt N2 N1 N2 N1 lt N2 N1 lt N2 and N1 N2 11 136 Mini Reference Manual N1 gt N2 N2 comparenumerically N1 gt N2 produces N2 if N1 isnumerically greater than or equalto N2 butfailsotherwise Error 102 N1 or N2 not integer or real See also N1 gt N2 N1 N2 N1 lt N2 N1 lt N2 and N1 N2 Mini Reference Manual 11 137 N1 N2 N2 comparenumerically N1 N2 produces N2ifN1 isnumerically equal to N2 but failsotherwise Error 102 N1 or N2not integer or real See also N1 gt N2 N1 gt N2 N1 lt N2 N1 lt N2 N1 N2 and s 11 138 Mini Reference Manual N1 lt N2 N2 comparenumerically N1 lt N2 produces N2 if N1 isnumericallylessthan N2 but failsotherwise Error 102 N1 or N2 not integer or real See also N1 gt N2 N1 gt N2 N1 N2 N1 lt N2 and N1 N2 Mini Reference Manual 11 139 N1 lt N2 N2 comparenumerically N1 lt N2 produces N2 if N1 isnumerically lessthan or equalto N2 but failsotherwise Error 102 N1 or N2 not integer or real See also N1 gt N2 N1 gt N2 N1 N2 N1 lt N2 and N1 N2
20. Execution File Launches Runtime O Memory Monitoring ems scan Program Defaults Undeclared Program Options Identifiers l l Selecting Program Options from the Options menu lets you turn some program options on and off Icon does not require you to declare local identifiers If an undeclared identifier appears in a procedure and there is no global declaration for it anywhere in your program the identifier is taken to be local This saves having to write a lot of declarations It can be dangerous however You may intend an identifier to be local but there may be a global declaration for it that you don t notice If you Intermediate check Undeclared Identifier Warning ProIcon s linker Files issues a warning message if it finds an undeclared identi fier Such messages are just warnings they don t prevent your program from linking or running Normally when ProIcon compiles and links a program Tracing it deletes the intermediate files produced by the compiler the u1 and u2 files If you want to keep these files to use in a library as described earlier in this chapter for example check Preserve Intermediate Files Prolcon offers two kinds of tracing procedure tracing and function tracing Check the corresponding boxes if you want tracing to be done automatically A word of caution tracing produces a lot of output and it may be 4 4 Compiling and Running Programs Termination Dumps String Comparison
21. Keyboard end of file 4 11 7 3 Keyboard input 4 11 7 3 10 3 A 1 A 2 Keyboard shortcuts 3 5 3 6 4 1 4 11 5 6 6 1 6 13 7 6 7 8 Keyboards 6 2 6 3 A 1 Keyboards extended 6 3 6 6 A 2 Keys table 8 10 9 4 9 5 Keywords 11 164 amp ascii 11 165 amp clock 11 165 l 6 Index amp collections 9 12 11 165 amp compare 10 1 11 165 B 1 B 3 amp cset 11 166 amp current 9 10 11 166 amp date 11 166 amp dateline 11 166 amp digits 9 2 11 167 amp dump 4 5 10 4 11 167 amp error 9 12 9 13 11 167 amp errornumber 9 13 11 167 amp errortext 9 13 11 168 amp errorvalue 9 13 11 168 amp errout 4 9 11 168 amp fail 11 168 amp features 9 12 11 169 amp file 9 13 11 169 amp ftrace 4 5 10 2 11 169 amp host 11 170 amp input 4 9 11 170 amp lcase 8 3 11 170 amp letters 9 2 11 170 amp level 11 170 amp line 9 13 11 171 amp main 9 9 11 171 amp null 11 171 amp output 4 9 11 171 amp pos 9 10 11 172 amp random 11 172 amp regions 9 12 11 172 amp screen 10 6 11 173 amp source 11 173 amp storage 9 12 11 173 amp subject 9 10 11 174 amp time 11 174 amp trace 4 5 11 174 amp ucase 8 3 11 174 amp version 11 175 L launch s1 s2 i 4 17 10 8 11 47 Launching executablefiles 4 5 4 17 LaunchingProlcon 6 13 left s1 i s2 11 48 Libraries 4 2 4 7 4 9 Library Folders 4 7 4 9 7 4 Ligatures B 4 B 7 Link afte
22. Positions are one based and start at the beginning of the window If begin and end are the same a vertical cursor is placed before the beginning character The function wprint window setup job prints the contents of the specified window If setup is nonzero a Page Setup dialog is displayed If job is nonzero a Print Job dialog is displayed If Cancel is selected from the Print Job dialog the contents of the window are not printed and the function fails Pausing Dialog Boxes Current Working Folder File Names File Signatures File Dialogs Other Functions The function delay i delays program execution for i milliseconds Clock resolution is 1 60th of a second The function gettext name okay cancel text presents a dialog box with the message name The OKbutton in this box hasthe name okay and cancel is the title for its Cancel button The string text is presented and can be edited by the user The value returned by the function is the edited text The function fails if the user selects Cancel The function message name okay cancel is Smilar to gettext except that there is no editable text The function currentf returns the name of the current working folder as a full path name with a suffix The function changef name changes the current working folder to name It fails if name is not the name of a folder The function file name generates the names of the files and subfolders in folder name It fai
23. Program Output dialog Mini Reference Manual 11 171 amp pos i scanning position The value of amp pos isthe position of scanning in amp subject The scanning position may be changed by assignment to amp pos Such an assignment fails if it would be out of range of amp subject amp pos is a variable amp random i random seed The value of amp random is the seed for the pseudo random sequence The seed may be changed by assignment to amp random amp random is zero initially amp random is a variable amp regions i1 i2 i3 storage region amp region generates the current sizes of the static string and block regions respectively The size of the static region is always given as zero 11 172 Mini Reference Manual amp screen L screen dimensions The value of amp screen is list of eight values that give the boundaries of the main screen and the gray region enclosing all screens The first four values are the x y coordinates of the upper left and lower right corners of the main screen in pixels The last four are the corresponding values for the gray region The gray region excludes the menu bar which is 20 pixels high amp source C source co expression The value of amp source is the co expression for the activator of the current co expression amp storage i1 i2 i3 storage utilization amp storage generates the current amount of space used in the static string and block regions respe
24. a dialog box is presented to allow you to decide what to do If you select Cancel in this case the window is not closed and the function fails The function wget window type returns information about the specified window The type of information desired is specified by the value of type left position of window in global coordinates top position of window in global coordinates width of window in pixels height of window in pixels position of start of selection position of end of selection length of text in window line number of start of selection character number of start of selection contents of clipboard 10 selected text from window 11 horizontal coordinate of mouse in window 12 vertical coordinate of mouse in window 13 mouse button state if down fail if up 14 window number of the frontmost window 15 height of text line in pixels OANA UBWNF OO Line and character positions in selections are one based wget fails for type 11 12 and 13 if the mouse is outside the specified window s text display region which excludes the scroll and title bars The function wset window type text sets an aspect of the specified window T he aspect is specified by the value of type Sizing and Moving a Window Arranging the Screen 0 hide window 1 show window with no change in front to back ordering 2 show window and bring to front 3 zoomin 4 zoom out 5 discard window contents 6 move cursor left one char
25. can t find theoperationsyou relooking for trythe index Mini Reference Manual 11 121 N1 N2 N3 computesum N1 N2 producesthesum of N1 and N2 Errors 102 N1 or N2 not integer or real 203 integeroverflow 204 realoverflow or underflow Seealso N 11 122 Mini Reference Manual N1 N2 N3 computedifference N1 N2 producesthe difference of N1 and N2 Errors 102 N1 or N2not integer or real 203 integeroverflow 204 real overflow orunderflow See also N Mini Reference Manual 11 123 N1 N2 N3 compute product N1 N2 produces the product of N1 and N2 Errors 102 N1 or N2 not integer or real 203 integer overflow 204 real overflow or underflow Seealso x 11 124 Mini Reference Manual N1 N2 N3 N1 N2 produces the quotient of N1 and N2 Errors 102 N1 or N2 not integer or real 201 N2 0 204 real overflow or underflow See also x compute quotient Mini Reference Manual 11 125 N1 N2 N3 compute remainder N1 N2 produces the remainder of N1 divided by N2 The sign of the result isthe sign of N1 Errors 102 N1 or N2 not integer or real 202 N2 0 204 real overflow or underflow 11 126 Mini Reference Manual N1 N2 N3 compute exponential N1 N2 produces N1 raised to the power N2 Errors 102 N1 or N2 not integer or real 204 real overflow underflow or N1 0 and N2 lt 0 206 N1 lt 0 and N2 real See also C exp and sqrt Mini Reference Manual 11 127 x1 x2 x3 compute
26. correct Icon programs This is just a start there s more information in the chapters that follow icon Start Prolcon by double clicking on its icon You ll see the uo Si Prolcon menu bar and an open window waiting for a new program Fraoleon File Edit Search Options Run Windows Untitled 1 icn The name Untitled 1 icn identifies a window that hasn t yet been given a name and saved ina file Before you go any further it s a good idea to name the window and connect it to a file that will be saved Pull down the File menu and select Save as A Quick Tour 3 1 3 2 A Quick Tour A Edit Search Page Setup Transfer Quit You ll get a file dialog box that lets you navigate to the folder in which you want tosave your program and specify itsname Preicen ID Prai gon Heip ch Profcaen Run tire is HE REME O Samples Rgne Cancel The file name for an Icon program must end in icn Suppose you want to name your program hello icn Enter hello icn in the box and select Save amp FPratcon Ih Praofioen Help Sh Prgin Run tige Lp REREME HEERES O Samples Cancel The title of your program window changes accordingly hello icn Now you re ready to enter a program Keep it simple to start with suchas hello icn procedure maint 3 weitec Hello world 3 end A Quick Tour 3 3 When you enter this program you re using the Prolcon editor It s a program editor s
27. cset or set difference 8 3 9 4 11 129 i augmented 11 151 dereferencing 11 120 field reference 11 133 nulltest 11 118 quotient 11 125 augmented 11 151 assignment 11 150 exchange 11 152 lt numericlessthan 11 139 lt reversibleassignment 11 153 lt gt reversibleexchange 11 154 lt augmented lt 11 151 lt lt string lessthan 11 145 lt lt augmented lt lt 11 151 ai at lt lt string lessthan or equal 11 146 lt lt augmented lt lt 11 151 lt numericlessthan or equal 11 140 lt augmented lt 11 151 Index l 1 matchandtab 11 112 numericequal 11 138 augmented 11 151 string equal 11 144 augmented 11 151 object equal 11 148 augmented 11 151 gt numeric greater than 11 136 gt augmented gt 11 151 gt numeric greater than or equal 11 137 gt augmented gt 11 151 gt gt string greater than 11 142 gt gt augmented gt gt 11 151 gt gt string greater than or equal 11 143 gt gt augmented gt gt 11 151 random value 9 4 11 116 2 scanning 9 10 11 193 augmented 11 151 activation 11 113 transmission 11 134 augmented 11 151 limitation 11 192 non nulltest 11 119 exponentiation 11 127 refreshing 11 114 augmented
28. different folders and arrange for Prolcon to find 4 2 Compiling and Running Programs ori ron oot icon hello them automatically without having to specify the paths The way to do this is discussed later in this chapter Icon Applications Executable files produced by the linker have names corresponding to the Icon program files from which they are produced but without the icn suffix For example the executable file that results from compiling and linking hello icn is named hello You can run an executable file without having to recompile the program Select Run File from the Run menu You get a file dialog showing the available executable files When you select one and complete the dialog it runs So far you ve been working inside the Prolcon applica tion You don t have to be in the Prolcon application to run an executable file Just launch it from the desktop This lets you build applications in Prolcon and run them as you wish You can also give such applications to others It is necessary to include the file Prolcon Runtime because it s needed to support executable files It s another file to remember but there s a good side to it all executable files use the same Prolcon Runtime and hence executable files are small Compiling and Running Programs 4 3 EJ Undeclared Identifier Warning L Preserve Intermediate Files L Procedure Trace L Function Trace L Dump CL International Comparison O
29. examine the callback result code for errors Fortunately there is an ever growing number of XCM Dsand XFCNsthat anticipate that they may not be called from H yperC ard XCMD and XFCN Globals N ote that the callbacks that get and set global values refer to globals maintained by Prolcon s XCM D XFCN interface They do not refer to global variables in your con program They provide a method by which XCM Dsand XFCN s can save persistent data between function calls N ew globals are created with the SetGlobal callback A GetGlobal reference to an undefined global returns a handle to an empty string All globals are deleted when an Icon program terminates there is no persistence be tween program runs Global names are not case sensitive External Functions D 7 Some XCM Dsand XFCNs may require the user to set up certain global values prior to calling the external function This can be done from your Icon program using the GetGlobal and SetGlobal procedures provided in Globals icn located in folder External Functions XCMDs XFCNs link Globals SetGlobal s1 s2 where s1 is astring containing the global name and s2 is a string contain ing the global value Each string must be less than 256 characters in length XCM D XFCN globals can be copied into an Icon program with gvalue GetGlobal s where s is the global name Interfacing Other Code Resources Code resources other than XCM Dsand XFCN scan be used as external funct
30. expr fails but fails if expr succeeds 11 184 Mini Reference Manual repeat expr repeat evaluation repeat expr evaluates expr repeatedly Mini Reference Manual 11 185 return expr return from procedure return expr returns from the current procedure producing the outcome of expr Default expr amp null See also fail and suspend 11 186 Mini Reference Manual suspend expr1 do expr2 suspend from procedure suspend expr1 do expr2 suspends from the current procedure producing each result produced by resuming exprl If resumed expr2 is evaluated before resuming expr1 Thedo clause is optional Default expr1 amp null only if do clause is omitted See also fail and return Mini Reference Manual 11 187 until expr1 do expr2 loop until result until expr1 do expr2 evaluates expr2 each time expr fails it fails when expr1 succeeds The doclauseis optional See also while expr1 do expr2 11 188 Mini Reference Manual while expr1 do expr2 loop while result while expr1 do expr2 evaluates expr2 each time expr1 succeeds it fails when expr1 fails The do clause is optional See also until exprl do expr2 Mini Reference Manual 11 189 exprl expr2 x1 x2 evaluate alternatives expr1 expr2 generates the results for expr followed by the results for expr2 See also expr 11 190 Mini Reference Manual lexpr x1 x2 evaluate repeatedly expr generates the results for expr repeatedly terminati
31. from the legend Click on an object and the corresponding legend box blinks twice This feature is especially useful if you are using a black and white monitor When you re ready to watch the garbage collection press the space bar The block region is marked first followed by the string region You ll see each object turn black as it s marked indicating that it is to be saved The display pauses again after all the objects to be saved have been marked The unmarked objects are garbage and they will be collected When you press the space bar again you ll see the same display but with marked objects in their original colors and the unmarked objects in black Press the space bar once again and you ll see the results of compacting the saved objects toward the beginning of the storage regions Press the space bar one more time and you ll see allocation begin again as the program continues after the garbage collection That s the basic idea in running M emM on But there are several more things you can do Snapshots Anytime there isa M emM on display on the screen even when the display is running you can take a snapshot of the display The result is a color PICT file that you can view separately import into a document and so forth Thekeyboard sequence 3 T takesasnapshot When you take the first snapshot a dialog box is presented to allow you to specify the location and name of the file to hold the snapshot T
32. h contains structure declarations for each block type For example the b_real structure shows that a real value is stored in a block consisting of the title word followed by the real number Function results are returned by creating a descriptor for the result value For results other than integers and the null value the descriptor s value word contains a pointer to a string or data block The string or data block must be allocated in Prolcon s string or block region respectively A callback mechanism is provided to accomplish this Function Skeleton External functions are called with a Pascal style subroutine jump to the first location of the external function Pascal style means that arguments are pushed left to right and the external function removes its calling arguments from the stack Begin your external function with this sequence shown here in LightspeedC External Functions D 9 include Prolcon h pascal dptr main dargv argc ip callback struct descrip dargv short int argc short int ip pointer callback This skeleton specifies that main is a Pascal style function returning a pointer to a descriptor dptr It takes four arguments dargv is a pointer to an array of descriptors containing the con argu ments to the callout function Consider this call callout CODE myResourceName 123 test string 54 9 The descriptorsin the dargv array contain the following dargv 0 d
33. i1 i2 x2 produce substring or list section If x1 isastring x1 i1 i2 produces the substring of x1 between i1 and i2 i1 and i2 may be nonpositive x1 i1 i2 produces a variable if x1 is a variable If x1 is alist x1 i1 i2 produces a list consisting of the valuesof x1 in the given range In either case it fails if out of range Errors 101 il or i2 not integer 114 x1 not string or list 307 inadequate space in block region if x1 list See also x1 x2 x i1 i2 and x i1 i2 Sa Mini Reference Manual 11 159 x1 i1 i2 x2 produce substring or list section If x1 isastring x1 i1 i2 produces the substring of x1 between i1 andil i2 i1 and i2 may benonpositive x1 i1 i2 produces a variable if x1 isa variable If x1 is alist x1 i1 i2 produces a list consisting of the valuesof x1 inthe given range In either case it fails if out of range Errors 101 il or i2 not integer 114 x1 not string or list 307 inadequate space in block region if x1 list See also x1 x2 x i1 i2 and x i1 i2 11 160 Mini Reference Manual x1 i1 i2 x2 producesubstring or list section If x1 isastring x1 i1 i2 produces the substring of x1 between i1 and i1 i2 i1 and i2 may benonpositive x1 i1 i2 producesavariableif x1isa variable If x1 isalist x1 i1 i2 produces alist consisting of thevaluesof x1 in the given range In either case it failsif out of range Errors 101 ilor i2 not integer 114 x1 not
34. if the user selects Cancel The selected file is not created or opened only its path name is returned The function launch application file type launches the named application with the specified file as its argument If type is 0 the file is opened as if the file were click launched from the desktop If type is 1 the file is printed asif Print were selected from Finder s File menu If M ultiF inder is active the application is sub launched and program execu tion continues The function fails if the launch fails External Functions Prolcon allows programs to load and execute external functions written in other programming languages T hese functions can provide services that are inefficient or impos sible to perform in the Icon language For example special ized system calls for communications or screen graphics are accessible to external functions written in C Pascal or assembly language External functions are separately compiled code resources that are loaded dynamically as your program is executed There are two types of external functions e Functions conforming to H yperC ard s XCM D XFCN interface specification Version 1 Arguments to such functions are converted to strings and the functions return strings Writing such a function is relatively straightforward and requires no knowledge of Icon sinternal structure Stand alone functions that receive data in Prol con s internal descriptor format and re
35. indicated by the radio button in the Program Options box the options you specify normally just apply to the current program If you want them to apply to all pro grams click on the Compiler Defaults radio button You also can copy from one to the other by clicking on the Copy button Argument to main procedure Compiling and Running Programs 4 5 Parameter Strings Parameters can be communicated to a Prolcon program by means of a blank separated string that provides a list as the argument to the main procedure This string is entered Argument to main procedure cyan yellow magenta black using the Parameter String entry from the Options menu For example if you enter the string cyan yellow magenta black giving then in procedure main args every write args end Argument to main procedure cyan yellow magenta black OK Cancel the values written are cyan yellow magenta 4 6 Compiling and Running Programs Full Path Names Partial Path Names black You can include blanks in an argument by enclosing the argument in quotation marks as in for which the values written are cyan yellow magenta black Path Names For simple file names in link declarations Prolcon searches the folder where your program resides If you want to look in other folders you may specify files by full or partial path names A full path contains several elements each separa
36. ins An example of the use of many is in locating words Suppose for example that a word is defined to consist of a string of letters The expression write line 1 many letters line writes a word at the beginning of line Note the use of the position re turned by astring analysis function to specify the end ofa substring Expression Evaluation Conditional Expressions In Icon there are conditional expressions that may succeed and produce a result or may fail and not produce any result An example is the compari son operation i gt j which succeeds and produces the value of j provided that the value of i is greater than the value of j but fails otherwise Similarly i gt j gt k succeeds if jis between i and k The success or failure of conditional operations is used instead of Boolean values to drive control structures in Icon An example is if i gt j then k i else k j which assigns the value ofi to k if the value of i is greater than the value of j but assigns the value of j to k otherwise 8 4 Icon Language Overview The usefulness of the concepts of success and failure is illustrated by find s1 s2 which fails if s1 does not occur as a substring of s2 Thus if i find or line then write i writes the position at which or occurs in line if it occurs but does not write anything if it does not occur Many expressions in Icon are conditional An example is read which produces the next line from t
37. is 2 the lists are in the sorted order of the corresponding values If i is omitted 1 is assumed If i is 3 or 4 the size of the sorted list is twice the size of the table and the values in the list are successive keys and corresponding values for the elements in the table If i is 3 the values are in the sorted order of the keys If i is 4 the values are in the sorted order of the corresponding values For example the following program prints a count of word occurrences in the input file using a procedure tabwords that produces a table of words and their counts procedure main wlist sort tabwords 3 get sorted list while write get wlist get wlist end In this example get obtains the key first and then its corresponding value The list is consumed in the process but it is not needed for anything else Chapter 6 Data Types Page 62 Type Codes The initial letter of a type name is used to indicate its type in this manual In cases where two types begin with the same letter uppercase letters are used to avoid ambiguity Uppercase letters are also used for structure types Version 8 of Icon 9 5 co expression cset file integer list null procedure real set string table numeric record any structure any type 3S TT gt on 0 xe XxxXDZAY D Page 67 Sorting Sets sort after lists but before tables Csets like strings sort in nondecreasing lexical order Within one structure type
38. key or by choosing Clear from the Edit menu Prolcon also respondsto the clear key on the extended keyboard Selected text can be copied to the clipboard without removing it from its window by using s amp C or choosing Copy from the Edit menu Typing s V or choosing Paste from the Edit menu inserts the contents of the clipboard at the current position of the cursor If there is highlighted text rather than a simple cursor the paste operation replaces the selected text with the contents of the clipboard Undoing Changes If you make a change that you regret 3 Z undoes the change You can also select Undo in the Edit menu Keep in mind that Undo has a short memory it only remembers the last thing you did You can also use Undo to redo what you just undid In the Edit menu this is reflected in the wording For instance if you just cut a group of several lines the menu choice is Undo Cut If you perform the Undo the previ ously cut lines are restored as well as the old contents of the clipboard The Edit menu choice changesto Redo Cut and choosing that re performs the original cut If you ve got more to undo than Undo can handle a really botched file where you want to begin again from where you started this time usethe Revert command in the File menu Selecting Revert in the dialog that appears takes you back to the last version you saved On the extended keyboard function keys F1
39. like the characters ina string Thus car1 4 2400 changes the last value in car1 to 2400 A reference that is out of the range of the list fails For example write car1 5 fails The values in a list L are generated by L Thus every write L writes all the values inL Lists can be manipulated like stacks and queues The function push L x adds the value of x to the left end of the list L automatically increasing the size of Lby one Similarly pop L removes the leftmost value from L automatically decreasing the size of Lby one and produces the removed value A list value in Icon is a pointer reference to a structure Assignment of a structure in Icon does not copy the structure itself but only the pointer to it Thus demo car1 causes demo and car1 to reference the same list Graphs with loops can be constructed in this way For example node1 a node2 node1 b push node1 node2 constructs a structure that can be pictured as follows 32 Icon Language Overview 8 9 Sets Sets are collections of values A set is obtained from a list by set L where Lisa list that contains the members of the set For example S set 1 abc assigns to S a set that contains the integer 1 the string abc and an empty list An empty set is created by set The operations of union intersection and difference can be performed on sets The function member S x succeeds if x is a member of the
40. management can account for a significant amount of the time spent executing some programs And what goes on behind the scenes is interest ing even fascinating Icon allocates space for objects that are created during program execution in two regions a string region and a Memory Monitoring E 1 E 2 Memory Monitoring block region The string region consists of characters while the block region contains structures and related objects Allocation in the string region is in terms of bytes while allocation in the block region is in terms of 4 byte words Allocation proceeds in the same manner in both main regions The regions initially are empty and bounded by pointers As space is needed it is provided starting at the beginning re free e free space end beginning of the region A free pointer is incremented to mark the boundary between allocated spaceand free space If there is not enough available free space to satisfy an allocation request a garbage collection is performed to reclaim space occupied by objects that are no longer needed The garbage collection process is fairly complicated since it is necessary to locate all objects that may be beginning e free m i free space e i needed for subsequent program execution O bjects that need to be saved typically are scattered throughout the string and block regions beginning e free 9 __ free
41. member S1 member S2 x succeeds if x is a member of both S1 and S2 The function insert S x inserts X into the set S and returns S The function delete S x deletes Version 8 of Icon 9 3 the member x from the set S and returns S The functions insert S x and delete S x always succeed whether or not x is in S This allows their use in loops in which failure may occur for other reasons For example S set while insert S read builds a set that consists of the distinct lines from the standard input file The operations S1 S2 S1 S2 S1 S2 create the union intersection and difference of S1 and S2 respectively In each case the result is a new set These operations apply both to sets and csets There is no automatic type conversion between csets and sets the result of the operation depends on the types of the arguments For example aeiou abcde produces the cset abcdeiou while set 1 2 3 set 2 3 4 produces a set that contains 1 2 3 and 4 The size of a set the number of members in it is given by S S produces a randomly selected member of S and S generates the mem bers of S The function sort S produces a list containing the members of S in sorted order Pages 56 58 Operations on Tables The word key is used in this manual for the value used to subscript a table The first edition of The Icon Programming Language uses the words entry value The two are sy
42. name Version 8 of Icon 9 7 Chapter 10 Miscellaneous Operations Page 97 String Invocation A string valued expression that corresponds to the name of a procedure function or operation can be used in place of the procedure function or operation in an invocation expression For example numeric x produces the same call as numeric x and i j is equivalent to i j In the case of operator symbols with unary and binary forms the number of arguments determines the operation Thus i is equivalent to i Although to by is represented with reserved words itis an operation Itcan be invoked by the string name Thus 1 10 2 is equivalent to 1 to 10 by 2 Similarly range specifications are represented by so that s i j is equivalent to s i j The subscripting operation is available with the string name Thus amp lcase 3 produces c Defaults arenot provided for omitted ornull valued arguments in string invocation Consequently 1 10 results ina run time error Arguments to operators invoked by string names are dereferenced Asa result string invocation for assignment operations is ineffective and results inerror termination String names are not available for control structures suchas alternation Field references of the form expr fieldname also are not operations in the ordinary sense and are not available via string invocation In addition conjunction is not available
43. of these keywords fails if there has not been an error The function errorclear removes the indication of the last error Subse quent references to the keywords above fail until another error occurs The keywords amp file and amp line contain respectively the name of the file and line number in that file for the currently executing expression Error conversion is illustrated by the following procedure which could be used to process potential run time errors procedure ErrorCheck write rRun time error amp errornumber write File amp file Line amp line write amp errortext write offending value image amp errorvalue writes rDo you want to continue n if map read y yes then return else exit end Forexample amp error 1 write s ErrorCheck could be used to check for an error during writing while L sort T 3 ErrorCheck could be used to detect failure to sort a table into a list for lack of adequate storage Arun time error can be forced by the function runerr i x which causes program execution to terminate with error number iasifa corresponding run time error had occurred If iis the number of a standard run time error Version 8 of Icon 9 13 the corresponding error text is printed otherwise no error text is printed The value of x is given as the offending value If x is omitted no offending valueis printed This function makes it possible for l
44. opening 10 5 Windows output limit 7 4 10 7 Windows untitled 3 1 6 1 wlimit i1 i2 10 6 11 98 wmove it i2 i3 10 5 11 99 wopen s1 S2 10 3 10 4 11 100 woprint it i2 i3 10 6 11 101 write x1 x2 xn 8 2 9 7 11 102 writes x1 x2 xn 9 7 11 103 wselect i1 i2 i3 10 6 11 104 wset i1 i2 10 4 10 5 11 105 wsize i1 i2 i3 10 5 11 106 wtextwidth i1 s 10 6 11 107 xX XCM Ds 1 3 1 8 D 1 D 5 D 8 D 14 XFCNs 1 3 1 8 D 1 D 5 D 8 D 14 Z Zoom 6 13 7 5 Index I 11
45. or output select Program Input Program Output or Error Output from the Options menu Suppose you want standard output to go to poems Select Program Output Click on Write to File You get a file dialog Now enter poems Link Error Out of global symbol table space Now click OK If you already had a file named poems you d get an alert box that asks you if you want to over write it Complete the dialog as usual and standard output now goes to poems You can change standard input or error output in a similar fashion Compiling and Running Programs 4 11 Options Font Font Size Tabs Auto Indent Parameter String Library Folders Program Input Program Output Error Output Program Options Window Options Compiler Memory a Code space per procedure Constant table Field table headers Field table record list Global table Identifier table Ipc file name table Ipc line number table Local table Mian labels per procedure Parse tree space String space You can terminate keyboard input to a running Prolcon program by selecting Terminate Input from the Edit menu Compiler Memory Allocation Global table This Program Compiler Default set and Examine OK Cancel 4 12 Compiling and Running Programs Execution Memory or by using the D keyboard shortcut Memory Management The ProIcon compiler uses several tables for
46. output system and thesourceprogram window arenot closed in thelast case Errors 101 inot integer 205 inot0 1 or2 See also wopen Mini Reference Manual 11 91 wclose i s i close window wclose i s closes window i If the window has been written to it is closed according to the options given by s s action mn window contents saved to disk n window contents not saved a user is queried via a dialog box If Cancel is selected in the last case the window is not closed and the function fails Default s ut Errors 101 i not integer 103 snot string 209 invalid option 252 inot window identifier See also wopen 11 92 Mini Reference Manual wfont i s i set window font wfont i s sets the font for window ito the font named s If font s does not exist the font is not changed and the function fails Errors 101 i not integer 103 snot string 252 i not window identifier 306 inadequate space in string region See also wopen Mini Reference Manual 11 93 wfontsize it i2 i1 set font size in wnindow wfontsize i1 i2 sets the size of the font for window i1 to i2 in points Errors 101 il or i2 not integer 205 i2 lt lor gt 127 252 i1 not window identifier See also wopen 11 94 Mini Reference Manual wget i1 i2 x get window information wget i1 i2 returns information about window i1 according to the value of i2 i2 OONAUBWNF OC information left position of window in global coor
47. possible See also numeric and real Mini Reference Manual 11 41 ior i1 i2 i3 compute bit wise inclusive or ior i1 i2 produces the bit wise inclusive orofi1 and i2 Error 101 i1 or i2 not integer See also iand icom ishift and ixor 11 42 Mini Reference Manual ishift i1 i2 i3 shift bits ishift i1 i2 produces the result of shifting the bitsin i1 by i2 positions Positive shift is to the left negative to the right Vacated bit positions are zero filled Error 101 i1 or i2 not integer See also iand icom ior and ixor Mini Reference Manual 11 43 ixor i1 i2 i3 compute bit wise exclusive or ixor i1 i2 produces the bit wise exclusive orofi1 and i2 Error 101 i1 or i2 not integer See also iand icom ior and ishift 11 44 Mini Reference Manual kbhit n check for keyboard character kbhit succeedsif acharacter isavailaoblefor getch or getche but fails otherwise See also getch and getche Mini Reference Manual 11 45 key T x1 x2 xn generate keys from table key T generates the keysin table T Error 120 T not table 11 46 Mini Reference Manual launch s1 s2 i 1 launch application launch s1 s2 i launches the application named s1 with argument s2 Ifi is 0 s2 is opened as if s2 were click launched from the desktop If s2is1 s2 is printed as if Print has been selected from Finder s File menu If M ultiFinder is active s1 iss
48. records the order of generation is from the beginning to the end but for tables it is unpredictable If x1 is aset x1 generates the members of x1 in no predictable order Errors 103 tions 116 212 306 x1 originally string but type changed between resump x1 not string file or structure x1 is file but not open for reading inadequate space in string region if x1 string or file Mini Reference Manual 11 117 IX X check null value x produces x if the value of x is the null value but fails otherwise It produces a variable if x is a variable See also N1 N2 11 118 Mini Reference Manual x 1X check for non null value x produces x if the value of x isnot the null value but fails otherwise It produces a variable if x is a variable See also expr i Mini Reference Manual 11 119 XX dereference variable x produces the value of x See also R f 11 120 Mini Reference Manual Infix Operations In an infix operation an operator symbol standsbetween thetwo operandson which it operates If evaluation of an operand fails the operation isnot performed If an operand generatesasequence of results theoperation may beperformed several times There aremany infix operations and finding theone you re looking for may poseaproblem T hey are listed first by those that perform computations such as N1 N2 and then by thosethat perform comparisons suchas N1 lt N2 Assignment operationsare listed last f you
49. rest of the facilities of SNOBOL4 are not available in pattern matching except by using awkward and contrived constructions Icon approaches the problem of pattern matching ina somewhat different way Instead of having patterns Iconhas matching functions Icon focuses more on the ability to express how the matching is done than it does on the de scription of what is matched This allowsall the features of Icon to be used in pattern matching but at the expense the high level of abstraction that SNOBOL4 patterns allow For example writing out the comma terminated substrings of a string in SNOBOL4 might be done this way P BREAK OUTPUT LEN 1 next S P S next In Icon it might look like this s while write tab upto do move 1 The point is that in SNOBOL4 you think of a pattern that matches the desired string while in Icon you specify how to match the desired string Granted the two methods look similar it s the viewpoint that s different It s worth noting that Icon allows any operation inthe matching process while SNOBOL4 doesn t In SNOBOL4 for example you can t just make an assignment to OUTPUT you have to usea different operation that associates the name OUTPUT witha pattern Actually it s possible to capture SNOBOL4 s concept of patterns in terms of Icon procedures although the method for doing so requires discipline and adds overhead in execu tion time For example you could w
50. s3 s4 map characters map s1 s2 s3 producesastring of size s1 obtained by mapping charac tersof s1 that occurin s2into corresponding charactersin s3 Defaults s2 string amp ucase s3 string amp lcase Errors 103 s1 s2 or s3 not string 208 s2 s3 306 inadequatespacein string region 11 52 Mini Reference Manual match s1 s2 i1 i2 i3 match initial string match s1 s2 i1 i2 produces i1 s1 if s1 s2 i1 s1 but fails other wise Defaults s2 amp subject id amp pos if s2 is defaulted otherwise 1 i2 0 Errors 101 il or i2 not integer 103 s1 or s2 not string See also s Mini Reference Manual 11 53 member X x x test for membership If X isa set member X x produces x if x isa member of X but fails other wise If X isatable member X x produces x ifx isa key of an elementin X but fails otherwise Error 122 X not set or table See also delete and insert 11 54 Mini Reference Manual message s1 S2 S3 s1 present message message s1 S2 S3 presents a dialog box with message s1 s2 istext for the OK button and s3 isthe title for the Cancel button Defaults s1 s s2 OK displayed s3 no Cancel button Error 103 s1 s2 or s3 not string See also gettext Mini Reference Manual 11 55 mmout s n write text to allocation history mmout s writes s to the allocation history file s is given no interpretation Expert knowledge of allocation history files is needed to us
51. same symbols the selection may be ambiguous If it is you get a help window for the infix operator For example if you select the operator as in case typetsymbol gt of string we tescsymbol 3 charset writes symbol chars honterm pending F4defslsymbal name pending i writetBerrout EE undefined nonterminal lt symbol name break if pending limit then uri techerrout HEE excessive symbols remaining break You getthe following help window Online Help Hi H2 HS Hi H2 produces the product of Mi and NZ Errors H1 or Nz not integer or real integer overflow real overflow or underflow See also 5 6 Online Help This isn t what you wanted but it has a cross reference to the prefix operator so you can get help for the prefix operator from there In this case select the operator and its operand as well this is how the online help system distin guishes between the twocases Online Help compute product ay Hi H2 produces the product of M1 and Nz Errors 102 Hi or H2 not integer or real 203 integer overflow 204 real overflow or underflow See also gA The help window for this selection is what you wanted originally Online Help compute size tx produces the size af x Error 112 x not cset string co expression or a structure See also N1 N2 As yousee help windows for prefix operators also contain cross references to i
52. set S but fails otherwise The function insert S x adds x to the set S while delete S x removes x from S A value only can occur once in a set so insert S x has no effect if x is already in S The operator S generates the members of S A simple example of the use of sets is given by the following segment of code which lists all the different words that appear in the input file words set while line read do line while tab upto letters do insert words tab many letters every write words Tables Tables are sets of pairs of values a key and a corresponding value The keys and values may be of any type The value for any key is looked up automatically Thus tables provide associative access in contrast with the positional access to values in lists A table is created by an expression such as symbols table x which assigns to symbols a table that has the default value x The default value is used for new keys Subsequently symbols canbe referenced by any key suchas symbols there 1 which associates the value 1 with the key there in symbols Tables grow automatically asnew keys are added For example the following program segment produces a table containing a count of the words that appear in the input file words table 0 8 10 Icon Language Overview while line read do line while tab upto letters do words tab many letters 1 Here the default value for each word is 0 and
53. the next line Press option when you start to compile or run aprogram to produce a pop up dialog that allows you to make last minute changes to the parameter string memory allocation and input output specifications Press option when launching Prol con from the desktop to reverse the normal startup action If you normally get anew untitled window you get a file dialog instead C onversely if you normally get a file dialog you get anew window Window Shortcuts Press option while clicking in the active window s go away box to close all windows Press option while clicking in its title bar to place a window behind all other windows Press sg whileclicking inthe window stitlebar to drag a window without bringing it to the front 8 icon Language Overview ICON LANGUAGE OVERVIEW The overview of the Icon language that follows is adapted froma techni cal report published by the Icon Project at The University of Arizona If you re new to Icon this overview will get you started If you ve used Icon before you can also use this overview to help you brush up Introduction Iconisa high level programming language with extensive facilities for processing strings and lists Icon has several novel features including expressions that may produce sequences of results goal directed evaluation that automatically searches fora successful result and string scanning that allows operations on strings to be formul
54. the chapters that follow icon Start Prolcon by double clicking on its icon You ll see the uo Si Prolcon menu bar and an open window waiting for a new program Fraoleon File Edit Search Options Run Windows Untitled 1 icn The name Untitled 1 icn identifies a window that hasn t yet been given a name and saved ina file Before you go any further it s a good idea to name the window and connect it to a file that will be saved Pull down the File menu and select Save as A Quick Tour 3 1 3 2 A Quick Tour A Edit Search Page Setup Transfer Quit You ll get a file dialog box that lets you navigate to the folder in which you want tosave your program and specify itsname Preicen ID Prai gon Heip ch Profcaen Run tire is HE REME O Samples Rgne Cancel The file name for an Icon program must end in icn Suppose you want to name your program hello icn Enter hello icn in the box and select Save amp FPratcon Ih Praofioen Help Sh Prgin Run tige Lp REREME HEERES O Samples Cancel The title of your program window changes accordingly hello icn Now you re ready to enter a program Keep it simple to start with suchas hello icn procedure maint 3 weitec Hello world 3 end A Quick Tour 3 3 When you enter this program you re using the Prolcon editor It s a program editor so you type return at the end of every line of the program Prolcon s editor
55. the preceding example suggests Icon uses the SNOBOL4 concepts of success and failure to control program flow In this you have an advantage over a person who knows only programming languages like BASIC and Pascal and for whom the idea of failure may be completely new In Icon as inSNOBOL4 the failure of an operation prevents evaluation of other surrounding operations While failure is used to select conditional gotos in SNOBOL4 failure is used to drive control structures in Icon For example a conditional assignment in SNOBOL4 might look like this i LT i j S next i 0 next In Icon it looks like this if i lt j then i j else i O Once you get used to it you ll see how similar the use of success and failure is in SNOBOL4 and Icon In fact as the example above illustrates the control structures of Icon just use implicit gotos and labels you don t have to write them yourself as you do in SNOBOL4 Pattern Matching One of the most distinctive features of SNOBOL4 is pattern matching and its repertoire of built in patterns from which youcan build more complex ones of your own More About Prolcon 2 5 2 6 More About Prolcon Patterns providea high level of abstraction that describes the structure of strings without for the most part the need tospecify how matching is actually done In the strengths of patterns lie their weaknesses It s difficult to specify the matching process if you need to and most of the
56. the primary character of each class Aslong asthe primary charactersmatch the comparison proceeds If the primary charactersdo not match their relationship determinestheordering of thestrings Thus aislessthan b String Comparison B 3 B 4 String Comparison because that is the ordering of their respective primary characters A and B If two strings match completely in their primary ordering the comparison routine considers secondary ordering It remembers the first pair of characters that were different although they yielded the same primary character and considers their positions in their class For example consider two equal length strings that begin with A and A Both produce A as their primary character Consequently they compare equally on the first pass which merely considers primary characters If all primary characters compare equally then the comparison routine examines the secondary ordering of Aand A Here A appears first and so the string containing it is less than the other As another example the following tests all succeed A lt lt a Ab lt lt ab ab lt lt Ac The third case fails under the default comparison system because the character code for a 97 is greater than the code for A 65 and the comparison never looks beyond the first character U nder the international comparison system however a and A are equal using their primary character so the match proceeds comparing b and
57. via string invocation since no operation is actually performed String names for procedures are available through global identifiers The names of functions such as numeric are global identifiers Similarly any procedure valued global identifier may be used as the string name ofa procedure Thus in global q procedure main q p q hi end procedure p s write s end the procedure p is invoked via the global identifier q The function proc x i converts x to a procedure function or operation if possible If x is procedure valued its value is returned unchanged If the 9 8 Version 8 of Icon The function args p produces the number of arguments expected by p The value is 1 for a function that accepts a variable number of arguments Fora procedure declared witha variable number of arguments the value is the negative of that number Page 99 String Images of Co Expressions The image of a co expression includes in parentheses anidentifying number and the number of times it has been activated Identifying numbers start with 1 for amp mainand increase as new co expressions are created For example image amp main produces co expression_1 1 assuming amp main has not been activated since its initial activation to start program execution Page 99 Images of Structures Structures have serial numbers that appear in their string images following the typename and an underscore For example image 1 4 9
58. window Q QuitProlcon ge R Replaceselection 3 S Savewindow in file T Findin next file ag VV Pastefrom clipboard Function Keys return tab Close window Cut selection to clipboard Replace selection and find again U ndo last editing operation Transfer to another application Shift selected lines left one tab stop Shift selected lines right one tab stop Shift selected lines lift one space Shift selected lines right one space Jump to first line in window Jump to last line in window Zoom window in or out Stop program execution Suspend program execution Continue program execution Select window 0 Select window 9 enter literal return in dialog enter literal tab in dialog In addition on the extended keyboard function keys F1 F4 perform undo cut copy and paste respectively On all keyboards that have it the escape key behaves like 36 Menu Reference 7 7 Option Key Manipulating Windows 7 8 Menu Reference H olding down the option key while performing certain actions produces alternatives that may be useful for one time operations Press option when choosing Open in the File menu to suppress TEXT file filtering All files types are displayed Press option return when entering text in a window with auto indentation enabled to suppress auto indentation on
59. x1 x2 11 154 Mini Reference Manual Other Operations T heoperationsonthefollowing pageshave varying typesof syntax Somehave morethan two operands I f evaluation of an operand fails the operation isnot performed If an operand gener atesasequenceof results theoperation may beperformed several times Mini Reference Manual 11 155 i1 to i2 by i3 i1 in generate integersin sequence i1 to i2 by i3 generatesthesequenceofintegersfrom i1 to i2 in increments of i3 Default i3 1 if by clauseisomitted Errors 101 i1 i2 or i3 not integer 211 i3 0 See also seq 11 156 Mini Reference Manual x1 x2 xn L create list x1 x2 xn produces a list containing the values x1 x2 xn produces an empty list Error 307 inadequate space in block region See also list 3 Mini Reference Manual 11 157 X1 x2 x3 subscript If x1 isastring x1 x2 produces a one character string consisting of character x2 of x1 x1 x2 fails if x2 is out of range x1 x2 produces a variable if x1 is a variable If x1 isalist or record x1 x2 produces element x2 ofx1 x1 x2 fails if x2 is out of range If x1 isatable x1 x2 produces the element corresponding to key x2 ofx1 In all cases x2 may be nonpositive Errors 101 x1 isstring list or a record but x2 not integer 114 x1 not string list table or record See also x i1 i2 x i1 i2 and x i1 i2 11 158 Mini Reference Manual x1
60. 0 943518 85 7 Corr Alan D Icon Programming for H umanists E ngle wood Cliffs N ew ersey Prentice H all 1990 ISBN 0 13 450180 2 Griswold M adgeT and Griswold RalphE eds Thelcon Analyst con Project D epartment of Computer Science G ould Simpson Building T heU niversity of Arizona T ucson Arizona 85721 Griswold M adgeT and Griswold RalphE eds Thelcon N ewsletter con Project Department of Computer Science G ould Simpson Building T heU niversity of Arizona T ucson Arizona 85721 Griswold Ralph E and Griswold M adgeT Thelcon Programming Language Second edition E nglewood Cliffs N ew ersey Prentice H all 1990 ISBN 0 13 447889 4 Griswold Ralph E and Griswold M adgeT Thelmplemen tation of the Icon Programming L anguagePrinceton N ew ersey Princeton U niversity Press 1986 I SBN 0 691 08431 9 Griswold R E Poage J F and Polonsky I P The SN OBOL4 Programming Language second edition Englewood Cliffs N ew J ersey Prentice H all 1971 ISBN 13 815373 6 Further Reading F 1 F 2 Further Reading H ockey Susan Snobol Programming for the H umanities Oxford England Clarendon Press 1985 ISBN 0 19 824675 7 Macintosh H yperC ard Script Language Guide The H yperT alk language Reading M assachusetts Addison Wesley Publishing Company Inc 1988 ISBN 0 201 17632 7 index Index menu 5 1 5 8 7 1 amp ascii 11 165 amp clock 11 165 amp collection
61. 04 Mini Reference Manual wset i1 i2 s i1 set window aspect wset i1 i2 s sets an aspect of window i1 according to the value of i2 i2 OONAUBWNF OO Errors See also aspect hide window show window with no change in front to back ordering show window and bring to front zoom in zoom out discard window contents move cursor left one character move cursor right one character move cursor to beginning of line move cursor to end of line move cursor up one line more cursor down one line move cursor and window to beginning of text home move cursor and window to end of text scroll up one page selection not changed scroll down one page selection not changed undo last cut paste clear cut selection to scrap copy selection to scrap paste scrap to selection clear selection copy s to clipboard insert s in front of selection replace selection by s 101 i1 or i2 not integer 252 i1 not window identifier wopen Mini Reference Manual 11 105 wsize i1 i2 i3 i1 resize window wsize i1 i2 i3 changes the size of window i1 to width i2 and height i3 in pixels A minimum size is enforced to allow room for scroll bars Errors 101 i1 i2 or i3 not integer 252 i1 not window identifier See also wopen 11 106 Mini Reference Manual wtextwidth i1 s i2 compute width of text wtextwidth i1 s returns the width in pixels of s using the font and fontsize for window i1 s is limited and truncated
62. 127 130 131 132 133 134 135 136 137 140 141 142 143 144 145 146 147 150 151 152 153 154 155 156 157 160 161 PT TNKK SEK CHAAHVOAZAZMATT A 3 M avon BTA on moacda amp w lt 3 5 2 LON BHM OX KHMVODOZZP RSH H p 7 cPaoc lt traAsor saree MNAR TT Zapf dingbats EEE HH OS KK HK HK OK OK eee ee Se He HK NY iN COUOOMC ex x amp keyboard sequence shift shift J shift K shift L shift M shift N shift O shift P shift Q shift R shift S shift T shift U shift V shift W shift X shift Y shift Z shift 6 shift OVOZEZSFASCT7 TOHMAMVOWSY Character Codes A 5 dec oct hex 114 162 72 115 163 73 116 164 74 117 165 75 118 166 76 119 167 77 120 170 78 121 171 79 122 172 Ta 123 173 7b 124 174 TC 125 175 7d 126 176 7e 127 177 7f 128 200 80 129 201 81 130 202 82 131 203 83 132 204 84 133 205 85 134 206 86 135 207 87 136 210 88 137 211 89 138 212 8a 139 213 8b 140 214 8c 141 215 8d 142 216 8e 143 217 8f 144 220 90 145 221 91 146 222 92 147 223 93 148 224 94 149 225 95 150 226 96 151 227 97 152 230 98 153 231 99 154 232 9a A 6 Character Codes Times Se SR NES PA ot lt hr et a OOO OD RTH Pm HN Oo amp amp AHO Be Mr Bm BY B CLO Arh Do D Symbol lyr AMme me geagqgn Zapf dingbats o A v K Kod segvre y m Om mY ATK Kw RU keyboard sequence N lt xsS lt CHOoD
63. 16 produces a result such as list_10 4 Page 100 Co Expression Tracing Tracing shows co expression activa tion and return as well as procedure activity display i f shows animage of the current co expression in addition to the values of variables Page 102 Variables and Names The function name v returns the string name of the variable v The string name of a variable or keyword is as it appearsin the program The string name ofa subscripted string valued variable consists of the name of the variable and thesubscript asin line 2 3 The string name of a list or table consists of the data type and the subscripting expression as in list 3 The string name of a record field reference consists of the record type and field names separated by a period as in complex r The function variable s produces the variable for the identifier or keyword whose nameis s Chapter 11 Generators Page 110 Integer Sequences The function seq i j generates an infinite sequence of integers starting at i with increments of j i and j default to 1 For example seq generates 1 2 3 Page 116 suspend do A do clause is allowed with suspend suspend expr1 do expr2 Version 8 of Icon 9 9 Ifthe do clause is present expr2 is evaluated if the suspending procedure is resumed Next expr1 is resumed If it produces another result the proce dure suspends again In this sense suspend is very similar to every the difference being th
64. 351 9 gt shift option 234 352 ea o gt shift option S 235 353 eb j L shift option D 236 354 f gt shift option F A 8 Character Codes dec oct hex Times Symbol Zapf dingbats keyboard sequence 237 355 ed I 1 gt shift option G 238 356 L gt shift option H 239 357 f gt shift option J 240 360 f0 shift option K 241 361 fl gt shift option L 242 362 f2 2 shift option 243 363 f3 U B shift option Z 244 364 f4 shift option X 245 365 f5 1 J gt shift option B 246 366 f6 7 shift option N 247 367 f7 E A shift option M 248 370 f8 J J shift option 249 371 f9 5 7 shift option 250 372 fa option H 251 373 fb option K 252 37 4 fc 9 shift option 253 375 fd t 9 shift option 254 376 fe J gt 3 shift option 255 377 ff 9 shift option Character Codes A 9 String Comparison String lexical comparison isperformed bytheoperations s1 gt gt s2 s1 greater than s2 s1 gt gt s2 s1 greater than or equal to s2 s1 s2 s1 equal to s2 s1 lt lt s2 s1 lessthan orequalto s2 s1 lt lt s2 s1lessthan s2 s1 s2 s1 not equal to s2 In each case the operation succeedsifthe specified relation holdsbut failsotherwise String comparison also occurs implicitly during sorting using thefunction _ sort T hisappendix describesthe string comparison using either Prol con sdefault comparison ort
65. 4 9 5 11 20 detab s1 i1 i2 in 9 3 11 21 Dialog boxes 10 8 display i f 9 9 11 22 dtor r 9 2 11 23 Dump 4 5 10 2 Edit menu 6 3 6 6 7 2 7 3 Editing 6 2 6 4 7 2 7 3 Editor 6 1 6 11 Empty sets 8 10 End of file 4 11 7 3 entab s i1 i2 in 9 3 11 24 Enter Selection 6 9 7 3 Entering text 6 2 6 3 Entering text selection 6 9 7 3 Error conversion 9 12 9 14 Error messages 9 12 9 14 C 5 C 6 Error Output 4 9 7 4 Error termination 9 12 9 14 errorclear 9 13 11 25 Errors 4 13 9 12 9 14 11 2 compilation 3 5 Evaluation of arguments 11 3 Evaluation stack 4 15 every do 9 10 11 180 Executable files 4 1 4 3 4 16 Execution Memory 4 13 4 16 7 4 7 5 exit i 11 26 exp r 9 2 11 27 Index l 3 External functions 1 3 10 8 D 1 D 14 stand alone 10 8 D 1 D 8 D 14 XCM Ds 1 3 1 8 D 1 D 5 D 8 D 14 XFCNS 1 3 1 8 D 1 D 5 D 8 D 14 F fail 9 10 11 181 Failure 2 5 8 4 9 12 File menu 3 2 3 3 3 6 6 1 6 2 6 4 6 7 6 8 7 1 7 2 7 8 File signatures 6 2 6 5 7 8 10 9 file s 10 7 11 28 Find 6 8 6 9 7 3 Find Again 6 10 7 3 Find in Next File 6 10 7 3 Finder 4 17 Finding text 6 8 6 9 7 3 find s1 s2 i1 i2 8 5 8 8 11 29 Folders 4 2 4 7 4 9 10 9 Font 6 7 7 4 Font Size 6 7 7 4 Fonts 6 6 6 7 7 4 10 8 Font size 6 7 7 4 10 8 fset s1 s2 s3 10 7 11 30 ftype s 10 7 11 31 Full path name
66. 62 Procedure tracing 4 4 4 5 Procedures 8 11 8 12 9 6 main 4 2 variable number of arguments 9 6 Program character set 6 9 6 8 7 1 7 2 4 5 4 6 7 4 7 8 Program files 3 2 6 2 Program Input 4 9 4 11 7 4 Program options 4 16 Program Options 4 3 4 5 4 16 7 4 B 1 B 3 Program output 4 9 4 11 7 4 Program termination 4 5 10 4 Programmer defined control structures 9 10 Prolcon Help 1 3 Prolcon Profile 4 16 Prolcon Runtime 1 3 4 3 pull L 11 63 push L x 8 9 11 64 put L x 11 65 putfile s1 s2 s3 10 8 11 66 Q Qualifier pointer region 4 15 Queues 8 9 QuickDraw D 4 D 5 Quit 3 6 7 1 7 2 Quitting Prolcon 3 6 7 1 7 2 R RAM 1 2 4 14 4 15 6 1 Random access input and output 9 7 Range specifications 8 2 8 3 read f 8 2 11 67 reads f i 11 68 Real numbers range of 10 1 real x 11 69 remove s 9 7 11 70 rename s1 82 9 7 11 71 repeat 11 185 repl s1 i 11 72 Replace 6 8 6 9 7 3 Replace All 6 9 7 3 Replace and Find Again 6 10 7 3 Replacing text 6 8 6 10 7 3 Reserved words C 3 C 4 return 8 11 9 10 11 186 reverse s 11 73 Revert 6 4 7 1 7 2 right s1 i s2 11 74 rtod r 9 2 11 75 Run after Link 4 1 7 5 Run menu 3 4 3 6 4 1 4 3 4 16 7 5 Run File 4 3 7 5 runerr i x 9 13 9 14 11 76 Running aprogram 4 1 4 3 7 5 9 11 9 14 Run time errors 9 12 9 14 11 2
67. File Edit Search Options Online Help la Assignment Co Expressions Chooser Comparison Operations Control Panel Control Structures Desk2ap Csets Find File Data Types Key Caps Debugging SmartScrap Error Control Super Ruler Input Output The Clipper Miscellaneous Numeric Computation Storage Management String Analysis String Scanning pos String Synthesis subject Structures Type Conversion movel Run Windows About MultiFinder Windows posi tabi 5 2 Online Help Selecting an Now you can select a specific item such as amp subject Item Run Windows File Edit Search Options Online Help a Assignment Co Expressions Chooser Comparison Operations Control Panel Control Structures Desk2 ap Csets Find File Data Types Key Caps Debugging SmartScrap Error Control Super Ruler Input Output The Clipper Miscellaneous Numeric Computation Storage Management String Analysis String Scanning String Synthesis Structures Type Conversion About MultiFinder Windows Online Help 5 3 Help Windows A window with information about amp subject pops up Online Help subject s subject of scanning tiny The value of amp subject is the string being scanned The subject of scanning may be changed by assignment to amp subject amp subject is a variable Help Look up Another way to get help is to select text in the currently active window such as the name of a function ina pro
68. Memory Monitoring Launching Runtime Compiler Defaults hard to find what you want Function tracing produces much more output than procedure tracing in most pro grams While checking these options gives you tracing without having to modify your program you may find it more useful to add code to your program to turn tracing on and off selectively by setting the values of amp trace and amp ftrace If you check Dump you ll get a listing of variables and their values when your program terminates Again this also can be done by setting amp dump in your program If International Comparison is checked ProIcon com pares strings using the Macintosh international compari son system See Appendix B for details Memory Monitoring causes information about storage allocation and garbage collection to be recorded Checking this box brings up an Open dialog when you run the program for a file to hold the information Appendix E describes how to use the results Object File Launches Runtime determines what happens when you launch an executable file from the desktop If this box is not checked launching an executable file starts the ProIcon application If the box is checked only the Prolcon run time system is activated You probably want the ProIcon application to be launched for your own programs but you ll need to have the run time system launched for programs you give to others since they may not have the Prolcon application As
69. Positions are one based Error 105 fnot file See also seek Mini Reference Manual 11 97 wlimit i1 i2 it set window output limit wlimit i1 i2 sets the limit for the number of lines retained in window i1 to i2 If the limit is exceeded lines are discarded from the top of the window If i2 isO or negative there is no limit This is relevant only if i1 is attached for output and written to in that manner Errors 101 il or i2 not integer 252 i1 not window identifier See also wopen 11 98 Mini Reference Manual wmove it i2 i3 i1 move window wmove it i2 i3 moves window i1 so that its upper left corner is at left position i1 and top position i2 in global coordinates N ote that the corner of a window refers to its content region which begins just below its title bar The window may be moved off screen Errors 101 i1 i2 or i3 not integer 252 i1 not window identifier See also wopen Mini Reference Manual 11 99 wopen s1 s2 i Open window wopen s1 s2 opens a window with title s1 and returns an integer that identifies the window If there is an open window on the screen with title 1 its identification is returned O therwise a window is opened according to the options given in s2 If s2 contains f an attempt is made to read file s1 into anew window If this failsand s2 contains n anew window with title s1 is opened O therwise the function fails The Interactive window is identified by 0
70. Prolcon Programming Language for Apple Macintosh Computers Version 2 0 The Prolcon Group Salida Colorado and Tucson Arizona The Prolcon Programming Language for Apple M acintosh C omputers 1989 1990 1994 TheBright Forest Company ISBN 0 939693 08 3 Version 2 0 N o part of this manual may be reproduced in any form by any means without permission in writing from T he Bright Forest Company Appleisatrademark of Apple Computer I nc H yperC ard isa registered trademark of Apple C omputer I nc Lightspeed is a registered trademark of Lightspeed I nc M acintosh is atrademark licensed to AppleC omputer I nc M PW isaregistered trademark of Apple Computer Inc Symantec isa trademark of Symantec C orporation Some material in this manual is adapted from the M axSPIT BOL manual with the permission of C atspaw Inc TheBrightF orest Company P O Box12076 Tucson Arizona A 85732 2076 CONTENTS Getting Started 1 1 Read this First 1 1 Knowing Your Macintosh 1 1 Installing Prolcon 1 2 A Guide to the Manual 1 3 More About Prolcon 2 1 If You re New to Icon 2 1 Icon for SNOBOL4 Programmers 2 4 About the Name Icon 2 10 User s Manual A Quick Tour 3 1 Compiling and Running Programs 4 1 Compilation and Linking 4 1 Libraries 4 2 Icon Applications 4 3 Program Options 4 3 Parameter Strings 4 5 Path Names 4 7 Library Folders 4 7 Input and Output 4 9 Memory Management 4 11 Output Limiter
71. acter 7 move cursor right one character 8 movecursor to beginning of line 9 move cursor to end of line 10 move cursor up one line 11 more cursor down one line 12 move cursor and window to beginning of text home 13 move cursor and window to end of text 14 scroll up one page selection not changed 15 scroll down one page selection not changed 16 undo last cut paste clear 17 cut selection to clipboard 18 copy selection to clipboard 19 paste clipboard to selection 20 cear selection 21 copy text to clipboard 22 insert text in front of selection 23 replace selection by text The function wsize window width height changes the size of the specified window to the given width and height in pixels The size of a window cannot be made smaller than what is needed for scroll bars The function wmove window left top moves the specified window so that its upper left corner is at the specified left and top coordinates The corner of a window refers to its content region which begins just below its title bar A window may be moved off screen The function warrange method arranges the windows on the screen according to the value of method 0 stacked 1 tiled 2 closed Prolcon Extensions 10 5 Screen Limiting Positioning Printing a Window 10 6 Prolcon Extensions Windows in use by the input output system and the source program window are not closed in the last case The value of the keyword amp scre
72. ail with the objects that are collected and those that are saved clearly identified T he display can be stopped at any time and PICT snapshots can be saved for future use Such displays can show the relative cost of using various types of data help locate unnecessary storage allocation and in general give you a feeling for what your program is doing In order to use M emM on to display the details of storage management you first need to create an alloca tion history file To do this select Program Options from the Options menu before running your program In the resulting menu check Memory Monitoring as described in Chapter 4 When you run your program an Open dialog will appear to let you specify the name of a file to receive the allocation history information Once you ve done that your program executes as it normally would and the allocation history file is written Enabling memory monitoring does not affect the computations performed by your program but it does slow it down somewhat and allocation history files can be quite large for programs that allocate a lot of data and that garbage collect frequently Consequently memory monitoring should only be enabled when you want an allocation history file M emM on is separate from Prol con you must leave the Prolcon application to view an allocation history file Memory Displays Before explaining how to run MemM on it will be helpful to know what the displays it
73. all con procedures that serve as con language wrappers for the external functions Alternatively source files can be empty or just contain comment lines but have resources in their resource forks To create such an intermediate file simply uncheck the Link Files menu item in the Run menu and compile the source file Global and Static Data M acintosh applications reference their global and static data using machine register A5 External functions are stand alone code resources and D 2 External Functions have no direct access to the host application s global variables H owever an external function can maintain its own private global and static variables to communicate among the various functions and routines that comprise the external function If you are using assembly language or a Symantec com piler this is a simple operation If you are using M PW tools creating a private global and static environment is more involved Using Symantec Compilers When constructing coderesources private global and staticdataare appended to theend of the code resource Stand alonecoderesourcesare compiled to access thisdataas offsets from register A4 which pointsto the start of the code resource Prol con setsup register A4 properly prior to calling your external func tion so no special action isrequired H owever if you arewriting an XCM D or XFCN that will be used with other systems you should set up and restoreregister A4 when e
74. an chose to have only one displayed by unchecking the box for the other If only one region is selected the height of the display lines is scaled up to fit the window The Pause Snap box controls when the display pauses and when automatic screen snapshots are taken The first four selections refer to the states of garbage collection The fifth selection refers to the Icon function mmpause which can be used to cause the display to pause at times other than the normal ones Click on Never to disable all pauses and snapshots The Granularity box controls the resolution of the display with respect to memory space Normally four Memory Monitoring E 13 bytes of memory are shown as one pixel horizontally on the display You can change this value to get a higher or lower resolution The height of the display lines is scaled to fit the display window The Garbage Collect box lets you specify when the display begins with respect to the number of garbage collections The default is 0 so the display normally starts at the beginning of program execution If you specify a larger number the display does not start until after that many garbage collections If Always Show is checked the marking phase of garbage collection is always displayed If this box is not checked the marking phase is bypassed if noneof the Pause Snap boxes related to marking is checked The Status and Title box determines whether or not the two legend lines are shown T
75. and need not be opened explicitly Errors 103 s1ors2 not string 209 invalid option 306 inadequate space in string region 11 100 Mini Reference Manual woprint i1 i2 i3 i1 print window wprint i1 i2 i3 prints the contents of window i1 Ifi2 is nonzero a Page Setup dialog is displayed If i3 is nonzero a Print Job dialog is displayed The function fails if Cancel is selected in the Print Job dialog Errors 101 i1 i2 or i3 not integer 252 i1 not window identifier See also wopen Mini Reference Manual 11 101 write x1 x2 xn xn write line write x1 x2 xn writes x1 x2 xn with a return added at the end Default xi mn Errors 109 xi not string or file 213 xi file not open for writing See also writes 11 102 Mini Reference Manual writes x1 x2 XN X write string writes x1 x2 xn writes x1 x2 xn without a return added at the end Default xi m Errors 109 xi not string or file 213 xi file not open for writing See also write Mini Reference Manual 11 103 wselect i1 i2 i3 i1 select text in window wselect i1 i2 i3 selects text in window i1 starting at character i2 and ending at character i3 Character positions are one based starting at the beginning of the window The selected text is highlighted If i2 i3 a vertical cursor is placed before character i2 Errors 101 i1 i2 or i3 not integer 252 i1 not window identifier See also wopen 11 1
76. as much Save All as fits for a window connected to a file is displayed in Startup the window s title bar Zoom duplicates the function of the zoom box in the Stack Windows title bar of a window Tile Windows Close All closes all windows Interactive 0 oUntitled 1l icn 1 Save All saves the contents of all windows that are connected to files Startup lets you determine Prolcon s launch behavior Menu Reference 7 5 Command Key Shortcuts 7 6 Menu Reference Stack Windows arrangesall open windowsin acascadeon thescreen Tile Windows reducesthesizesof all windowsso that they do not overlap on thescreen The bottom part of the Windows menu showsall the open windows Select awindow to bring it to thefronton the screen Windowswhosecontentshave changed sincethey were saved are marked at the left with alozenge Keyboard Shortcuts M any menuitemshavecommand key shortcuts asshown on themenus H ere sasummary of theseand other short cutsfor quick reference aA Select all textin window 3 B Balanceparentheses brackets or braces 3 C Copyselectionto clipboard s6 D T erminateinput keyboard end of file 9 E Enterselectionassearchtextin Find dialog 36 F Find text G Find again ge H H elp lookup 3 J Jumpto line ag K Compileprogram in window N O pen new untitled window 3 O O pen fileinto
77. at suspend causes the procedure in which it occurs to returna value Chapter 12 String Scanning Page 130 String Scanning The values of amp subject and amp pos are re stored when a scanning operation is exited by a break next return fail or suspend expression If ascanning expression that is exited by suspend is resumed the values of amp Subject and amp pos are restored to the values they had before the suspension Chapter 13 Co Expressions Page 138 Programmer Defined Control Structures To make program mer defined control operations easier to use there is an alternative syntax for procedure invocation in which the arguments are passed in a list of co expressions This syntax uses braces in place of parentheses plexpr1 expr2 exprn is equivalent to p create expr1 create expr2 create exprn Using this facility a procedure to generate the interleaved results of several generators can be written as follows procedure Inter L suspend L end Forexample Inter 1 to 3 6 to 10 generates 1 6 2 7 3 8 9 and 10 In this form Inter can be called with an arbitrary number of arguments Page 138 Current Co Expression The value of amp current is the currently executing co expression Appendix A Syntax Reserved Words The reserved words dynamic and external are no longer available 9 10 Version 8 of Icon The character pairs lt and gt are equivalent to and
78. ated at a high conceptual level Icon emphasizes high level string processing and a design philosophy that allows ease of programming and short concise programs Storage allocation and garbage collection are automatic and there are few restrictions on the sizes of objects Strings lists and other structures are created during program execution and their sizes do not need to be known when a pro gram is written Values are converted to expected types automatically for example numeral strings read inas input can be used innumerical compu tations without explicit conversion Examples of the kinds of problems for which Icon is well suited are e text analysis editing and formatting e document preparation e symbolicmathematics e text generation e parsing and translation Icon Language Overview 8 1 e datalaundry e eraphmanipulation e rapid prototyping A brief description of some of the representative features of Icon is given in the following sections This description is not rigorous and does not include many features of Icon See the Icon book for a complete description and Chapters 9 11 of this manual for recent changes and additions to the language Strings Strings of characters may be arbitrarily long limited only by the architec ture of the computer on which Icon is implemented A string may be specified literally by enclosing itin double quotation marks as in greeting Hello world which assigns an 11 character stri
79. b stop If you hold down the shift key when selecting one of these the shift is one space instead of Find Enter Selection Find Again Replace Replace and Find Again Replace All Jump to Top Jump to Bottom Jump to Line Help Lookup one tab stop Balance extends the current selection in both directions until it is balanced with respect to parentheses brackets or braces Terminate Input terminates keyboard input to a running program It causes read or reads to fail The Search menu lets you locate and change window text Find displays a dialog box that allows you to specify the text you want to find See Chapter 6 for details Enter Selection places the selected text in the currently active window as the text to be found Find Again searches for the next occurrence of the text specified for Find Replace allows you to replace text that is found and Replace and Find Again follows the replacement with another search Replace All replaces all occurrences of text that is found Warning you cannot undo this Find in Next File goes to the next file in a multi file search See Chapter 6 for more information Jump to Top and Jump to Bottom set the insertion point and window display to the top and bottom of the currently active window respectively Jump to Line prompts you for a line number and then Menu Reference 7 3 Options Font Font Size Tabs Auto Indent Paramet
80. c If two strings are of different lengths the extra characters in the longer string are all considered to be greater in terms of the primary comparison T he following both succeed Nal lt lt Ab A lt lt a Ligatures provide an additional complication These are two letter sequences like that are represented by one character in memory code 174 in this case For comparison purposes the international comparison system does the following e Primary comparison T he ligature is expanded to the two component characters e Secondary comparison T he ligature is greater than the two character sequence Character Ordering U nder this system FEC lt lt AEg succeeds because AE matches AE under their primary order ing and the comparison is based upon d and g Beginning with system 6 0 4 ligatures fi fl and B sort immediately after their expanded counterparts fi fl and ss Thefollowing table showsthe primary and secondary orderingsunder theU S English Roman writing system Each row representsaprimary class with thosetoward the top of thetablecollating beforelater entries Within aclass the secondary ordering appearsfrom left to right The first character in each classisits primary character tsdecimal codeisalso provided 0 nul 31 32 space non breaking space 202 33 34 ey 35 36 37 38 amp 39 ei 40 64 65 AAAAAAAaaa aaa 66 B b f 67 C Ge letter pairs 69 E
81. ce gt 5 then write i Icon Language Overview 8 5 The first result produced by the generator 3 is assigned to i but this value is not greater than 5 and the comparison operation fails At this point the generator is resumed and produces the second position 23 whichis greater than 5 The comparison operation then succeeds and the value 23 is written Because of the inheritance of failure and the fact that comparison operations return the value of their right argument this expression can be written in the following more compact form write 5 lt find or sentence Goal directed evaluation is inherentin the expression evaluation mecha nism of Icon and can be used in arbitrarily complicated situations For example find or sentence1 find and sentence2 succeeds if or occurs insentence1 at the same position as and occurs in sentence2 A generator canbe resumed repeatedly to produce all its results by using the every do control structure An example is every i find or sentence do write i which writes all the positions at which or occurs in sentence For the example above these are 3 23 and 33 Generation is inherited like failure and this expression canbe written more concisely by omitting the optional do clause every write find or sentence There are several built in generators in Icon One of the most frequently used of these is i to j which generates the integers from ito j This generator ca
82. ch waits until a character has been entered from the keyboard and then produces the corresponding one character string The character is not displayed in the Interactive window It fails on an end of file See also getche and kbhit Mini Reference Manual 11 33 getche s get and echo character getche waits until a character has been entered from the keyboard and then produces the corresponding one character string The character is displayed in the Interactive window It failson an end of file See also getch and kbhit 11 34 Mini Reference Manual getfile s1 s2 s3 s4 get file name gettfile s1 s2 s3 performs a Get File Dialog for the folder s3 with s1 displayed asa user prompt s2 isa0 4 8 12 or 16 character string that is used to filter the files displayed in the dialog O nly files with matching type signatures are displayed getfile s1 s2 s3 returns the the full path name of the file selected by the user If the signature is the one character string f only folders are displayed The function returns the path name of the folder selected The function fails if the user selects Cancel The selected file is not opened only its path name is returned Defaults s2 no file filtering s3 current working folder Error 103 s1 s2 or s3 not string 306 inadequate space in string region See also putfile Mini Reference Manual 11 35 gettext s1 s2 s3 s4 s5 get text gettext s1 s2 s3 s4 presents a dia
83. codes A 1 A 9 Character sets 8 3 8 4 9 2 Clear 6 3 6 4 7 2 Clipboard 6 3 6 4 10 4 10 5 Close 6 5 6 12 7 1 Close All 6 5 7 5 close f 11 13 Closing files 6 4 6 5 7 1 Closing windows 6 5 6 12 7 5 Co expressions 4 15 4 16 9 9 9 10 9 15 collect i1 i2 11 14 Compilation 4 1 4 2 7 5 Compilation errors 3 5 3 6 Compile File 7 5 Compile Window 3 4 7 5 Compiler defaults 4 5 Compiler Memory 4 11 4 13 7 4 Concatenation 8 2 Conditional expressions 8 4 8 5 Configuration requirements 1 2 Continue 4 16 7 5 Continuing program execution 7 5 Control structures 11 176 scanning 9 10 11 193 augmented 11 151 limitation 11 192 alternation 11 190 repeated alternation 11 191 break 9 10 11 177 case of 11 178 create 9 15 11 179 every do 9 10 11 180 fail 9 10 11 181 if then else 11 182 next 9 10 11 183 not 11 184 repeat 11 185 return 8 11 9 10 11 186 suspend do 8 11 9 10 11 187 until do 11 188 while do 11 189 Conversion data type automatic 11 2 Copy 6 4 7 2 copy x 11 15 cos r 9 2 11 16 create 9 15 11 179 Creating files 6 1 cset x 11 17 Csets 8 3 8 4 9 2 currentf 10 7 11 18 Cursor 3 4 6 2 Cut 6 3 7 2 D Data structures 2 8 Data types 9 5 9 6 11 1 11 2 Data types conversion of 11 2 Data types notation 9 5 9 6 11 1 Default values 11 2 delay i 10 7 11 19 delete X x 8 10 9 3 9
84. con You ll want to use some of these facilities as a regular part of your work with Prolcon You may need other facilities only in special situations This chapter starts with a description of facili ties that you will probably use a lot Facilities for special situations are near the end of this chapter Compilation and Linking When you compile a Prolcon program using for example 3 K three processes normally take place first compilation proper then linking and finally execution The compilation phase converts your program into an intermediate form Linking converts the intermediate files to an executable file The executable file is then run You ll notice the Run menu has two options that are checked by default Link after Compile and Run after Link As long as these options are checked all three processes take place one after another You can however stop after any process For example if you uncheck Link after Compile by clicking on it in the Run menu Prolcon stops after compiling your program and you get two intermedi ate files as a result they are deleted if you link after compiling These intermediate files have the suffixes u1 and u2 in place of the suffix icn in the name of your Compiling and Running Programs 4 1 program Libraries You might ask What good are intermediate files The answer to this question is suggested by the linking process mentioned above The Prolcon linker can combine inte
85. criptor containing the result value The descriptor present at ArgO dargv 0 should be used for this purpose After building a result descriptor in ArgO the function should return by executing return amp Arg0 The Return macro provided in Prolcon h performs this return Signaling Errors External functions are provided with a pointer to ashort integer argu ment ip that can be used to signal an error condition T he integer is initialized to 1 prior to each call signaling no error Setting it to a positive value triggers Prol con s runtime error mechanism A list of sup ported error numbers is contained in the Prolcon h file External Functions D 11 In addition to setting an error number the function still has the option of returning either a pointer to a descriptor or a null pointer If a descriptor is returned the value it contains is displayed after the error message T his is most useful for providing diagnostics about improper input arguments Prolcon h contains a macro named RunErr that encapsulates the process For example RunErr Err101 amp Arg1 displays error number 101 integer expected and displays the first true argument to the function Definitions Macros and Typedefs Numerous definitions macros and typedefs are provided in Prolcon h to allow you to write functions more conveniently A list of the more impor tant ones is provided here consult the Prolcon h file for a complete li
86. cset or set union x1 x2 produces the cset or set union of x1 and x2 Errors 120 x1 or x2 not both cset or both set 307 inadequate space in block region 11 128 Mini Reference Manual x1 x2 x3 compute cset or set difference x1 x2 produces the cset or set differenceof x1 and x2 Errors 120 x1 or x2 not both cset or both set 307 inadequate space in block region Mini Reference Manual 11 129 x1 x2 x3 cset or set intersection x1 x2 produces the cset or set intersection of x1 and x2 Errors 120 x1 or x2 not both csetor both set 307 inadequate space in block region 11 130 Mini Reference Manual 1 s2 s3 concatenate strings s1 s2 produces a string consisting of s1 followed by s2 Errors 103 s1ors2 not string 306 inadequate space in string region See also L1 L2 Mini Reference Manual 11 131 L1 L2 L3 concatenate lists L1 L2 produces a list containing the valuesin L1 followed by the values in L2 Errors 108 L1 or L2 not list 307 inadequate space in block region Seealso s1 s2 11 132 Mini Reference Manual R f x get field of record R f producesavariablefor the f field of record R Errors 107 MRnotarecord type 207 Rdoesnothavefield f See also x Mini Reference Manual 11 133 x1 C x2 transmit value to co expression x1 C activates C transmitting the value of x1 to it It produces the outcome of activating C Error 118 C not co expression See also
87. ct the Find button the Prolcon editor searches each of the files for the desired text If a file containing the text is found the file is displayed and the matching text highlighted After a successful search the normal search continuation Find in choices are available Find Again Replace Replace and Next File Find Again and Replace All All of these are restricted to the file just displayed You can continue the search into other files on your list by entering 36 T or by choosing Find in Next File in the Search menu 6 10 Entering and Editing Programs Wildcards Path Files Terminal Input Shortcuts exceed that limit If twelve windows are open when a multi file search is initiated or continued Prol con asks you to close at least one window before proceeding with the search Rather than specifying individual files your multi file list may include classes of file names T o do this use wildcard characters in the names as described in Chapter 4 If you want avoid retyping the search paths every time you gart up Prol con you can record them in a text file and load the search dialog with Use File as described in Chapter 4 The Interactive Window The Interactive window is used when your program requires interactive input from the keyboard As characters are entered they are echoed to this window All of the normal M acintosh window editing operations such as text selection cut copy and paste are a
88. ctively The space used in the static region is always given as zero Mini Reference Manual 11 173 amp subject s subject scanning The value of amp subject is the string being scanned T he subject of scanning may be changed by assignment to amp subject amp subject is variable amp time i elapsed time The value of amp time is the integer number of milliseconds since the begin ning of program execution amp trace i procedure tracing If the value of amp trace is nonzero a trace message is produced when a procedure is called returns suspends is resumed or fails amp trace is decre mented for each message produced amp trace is zero initially amp trace isa variable amp ucase c uppercase letters The value of amp ucase is a cst containing the 26 uppercase letters 11 174 Mini Reference Manual amp version s Icon version The value of amp version isa string identifying the version of Icon For the current release of Prolcon thisis Prolcon Version 2 0 Mini Reference Manual 11 175 Control Structures T heway that operandsof acontrol structureareevaluated depends onthecontrol structure in fact that swhat distinguishesacontrol structurefrom afunction or operation M ostcontrol structuresareidentified by reserved words T heyare arranged alphabetically on thefollowing pages with thefew control structuresthat use operator symbolsappearing at theend 11 176 Mini Reference Manual break ex
89. d alone code can reference any desired QuickD raw global indirectly The following Q uickD raw variables are affected thePort white black gray ItGray dkGray arrow screenBits and randSeed The following C code shows how stand alone code can obtain a pointer to the Q uickD raw globals U sing this pointer the globals can be referenced via a structure reference struct QDVarRec long randSeed BitMap screenBits Cursor arrow Pattern dkGray D 4 External Functions Pattern ItGray Pattern gray Pattern black Pattern white GrafPtr thePort pQDGlobals Pointer to QuickDraw Globals Develop pointer to Quick Draw Globals pQDGlobals struct QDVarRec long CurrentA5 sizeof struct QDVarRec sizeof thePort Given this pointer in pQDGlobals reference the needed variables as follows pQDGlobals gt thePort pQDGlobals gt screenBits etc For additional information see M acintosh T echnical N ote 256 Stand Alone Code Interfacing XCMDs and XFCNs H yperC ard scripts can invoke external commands XCM Ds and external functions XFCN s Although H yperC ard uses different syntaxes to invoke the two Prol con makes no such distinction Both accept string arguments or arguments that can be converted to strings and return astring result Prol con loads and calls XCM D s and XFCNsvialcon s function callout which takes the form callout type resource_name arg1 ar
90. ded by H yperC ard Because H yperC ard is not present Prol con emulates these callbacks For 20 of these callbacks the emulation exactly mirrors H yperC ard s behavior The remaining nine callbacks are H yperC ard specific and fail gracefully by returning an xresFail result code The 20 callbacks that are fully implemented are BoolToStr Boolean to true false string conversion ExtToStr extended 80 bit real to string conversion GetGlobal get global value LongToStr unsigned long to string conversion NumToHex long to hexadecimal conversion NumToStr signed long to string conversion PasToZero Pascal string to C string with handle ReturnToPas copy up to return character or end of C string ScanToReturn scan to return character or end of C string ScanToZero scan to end of C string SetGlobal set global value StringEqual case insensitive string equal compare StringLength C string length StringMatch case insensitive string search StrToBool true false string to Boolean conversion StrToExt string to extended real 80 bit conversion StrToLong string to unsigned long conversion StrToNum string to signed long conversion ZeroBytes zero bytes in memory ZeroToPas C string to Pascal string The following nine callbacks are H yperC ard specific and are not emu lated All return xresFail integer 1 as a result code In addition the D 6 External Functions GetFieldBy callbacks return a handle to an empty string mimicking H yperC ard
91. dinates top position of window in global coordinates width of window in pixels height of window in pixels position of start of selection position of end of selection length of text in window line number of start of selection character number of start of selection contents of clipboard selected text from window horizontal coordinate of mouse in window vertical coordinate of mouse in window mouse button state if down fail if up window number of the frontmost window height of text line in pixels Line and character positions in selections areone based wget fails for i1 11 12 and 13 if the mouse is outside the specified window s text display region which excludes the scroll and title bars Errors 101 i1 or i2 not integer 252 i1 not window identifier See also wopen Mini Reference Manual 11 95 wgoto i1 i2 i3 i4 go to position in window wgoto i1 i2 i3 positions the cursor at line i2 and character i3 in window i1 The positions are one based If i2 is greater than the number of lines in the window the cursor is set to the last line If i3 is greater than the number of characters on the line the cursor is set to the end of the line The function returns the resulting character position of the cursor Errors 101 i1 i2 or i3 not integer 252 i1 not window identifier See also wopen 11 96 Mini Reference Manual where f i produce postion in file where f produces the current byte postion in f
92. dure max i j if i gt j then i else j end The execution of this program produces the following output Run time error 102 File max icn Line 6 numeric expected offending value a Trace back main max a 1 from line 2 in max icn a gt 1 from line 6 in max icn A complete list of run time error messages is contained in AppendixC Error Conversion Most run time errors can be converted to expression failure rather than causing termination of program execution If the value of amp error is zero its initial value errors cause program termination as shown above If the value of amp error is nonzero errors are treated as failure of expression evaluation and amp erroris decremented For example if the value of amp error had been nonzero when the expression gt wasexecuted in the example above the expression simply would have failed 9 12 Version 8 of Icon There are a few errors that cannot be converted to failure floating point overflow and underflow stack overflow and errors during program initiali zation When an error is converted to failure the value of amp error is decremented and the values of three other keywords are set e amp errornumber is the number of the error for example 101 e amp errortext is the error message for example integer expected e amp errorvalue is the offending value Reference to amp errorvalue fails if there isno specific offending value A reference to any
93. e makes programming tedious It s also difficult to write SNOBOL4 programs that are well structured programs that are easy to understand and modify and that are free from sneaky bugs in control flow SNOBOL4 programs also are monolithic Despite the facility to define functions all the statements are really part of the whole program An Icon program by contrast consists of a set of modules procedures that are logically and physically distinct from each other Thus a program to be divided into its logical components and even be kept ina number of different files AnIcon procedure consists of expressions Expressions unlike statements are made up of other expressions there areno sharp demarcationsas there are with statements Icon hasseveral control structures that allow common forms of expression evaluation to be cast in standard understandable and well structured ways Icon doesn t have labels and gotos It doesn t need them If youare familiar with a language like Pascal or C you ll probably not have muchtrouble phrasing your programs in terms of Icon s syntax Otherwise you ll need to spend some time learning how to write programs using control structures without labels and gotos Copying a file provides a compari son In SNOBOL4 it is read OUTPUT INPUT S read while in Icon it is while write read Both are short and the logic is the same they just look different Success and Failure As
94. e the window named Compilation Error to get rid of it Notice A Quick Tour 3 5 3 6 A Quick Tour that the cursor is positioned at the line of your program window where the compiler found the error Generally speaking the line where an error is detected is not exactly where you made the mistake the compiler can t find an error untilsomething actually syntactically incorrect occurs you could have had the missing parenthesis atthe beginning of line 4 for example Correct your program and run it again to be sure it s right When you re finished save your program if you want by selecting Save from the File menu If you close the program window without saving changes you ll be asked if you want to save your modified program When you re finished witha Prolconsession leave the application by selecting Quit from the File menu or use the Q keyboard shortcut That s the basic idea Enter a program or bring in an existing one using Open from the File menu run it make corrections and re runit as necessary and save your program when you re finished Of course there s a lot more to Prolcon The next chapter describes more features of Prolcon Read on Ds E icon hello u1 Compiling and Running Programs In the last chapter you saw the basic ideas for compiling running and modifying ProIcon programs Prolcon is a powerful tool that provides many facilities to help you build applications written in ProI
95. e this function Error 103 snot string See also mmpause and mmshow 11 55a Mini Reference Manual mmpause s n write pause to allocation history mmpause s writes s to the allocation history file as a pause point with identification s Default s programmed pause Error 103 snotstring See also mmout and mmshow Mini Reference Manual 11 55b mmshow x s n redraw in allocation history mmshow x s specifies redrawing of x in the allocation history file The color is defined by s as follows b Ww h r black gray white highlight also white normal color If xisnotin an allocated dataregion mmshow has no effect Seealso mmout and mmpause 11 55 c Mini Reference Manual move i s move in amp subect move i produces amp subject amp pos amp pos i and assigns i amp pos to amp pos but fails if i is out of range It reverses the assignment to amp pos if itis resumed Error 101 i not integer See also tab Mini Reference Manual 11 55d name x s produce name name x producesthe name of the variable x If x isan identifier or a keyword that isavariable the name of theidentifier or keyword is pro duced If x isarecord field reference the record type and field nameare produced with aseparating period If x isastring thenameof thestring and thesubscript rangeareshown If xiSasubscripted list or table thetype name followed bythe subscripting expression is
96. e value of amp ftrace is nonzero a trace message is produced when a function is called returns suspends is resumed or fails amp ftrace is decre mented for each message produced amp ftrace is zero initially amp ftrace isa variable Mini Reference Manual 11 169 amp host s host system The value of amp host is a string that identifies the host system on which I con is running For Prolcon thisis Prolcon for the Macintosh amp input f standard input The value of amp input is standard input Standard input defaults to the keyboard but it may be redirected elsewhere using the Program Input dialog amp letters c letters The value of amp letters is a cst containing the 52 upper and lowercase letters amp lcase c lowercase letters The value of amp lcase is a cset containing the 26 lowercase letters amp level i procedure level The value of amp level isthe integer level of the current procedure call 11 170 Mini Reference Manual amp line i source line number The value of amp line is the number of the source program line in which it appears amp main C main co expression The value of amp main is the co expression for the main program amp null n null value The value of amp null is the null value amp output f standard output The value of amp output is standard output Standard output defaults to the Interactive window but it may be redirected elsewhere using the
97. elect the file to load it can open anew untitled window or it can remain neutral doing neither Entering and Editing Programs 6 13 7 Menu Reference About Prolcon Online Help Save as Revert Page Setup Transfer Quit Menu Reference Thischapter summarizes Prol con smenus T hecom mand shortcuts shown on the menus can save you alot of time if you use Prol con frequently They are summarized at the end of this chapter Thetop of the menu has two selections for Prolcon Select About Prolcon if you want to know more about the application Online Help opens the door to information about Prol con that you may need when you reusing Prol con Online help is discussed in Chapter 5 The File menu is similar to the file menus of most Macintosh applications Select New to open anew window for entering a program or other text Select Open to get a dialog box that allows you to open an existing text file Close closes the currently active window If it has not been saved or if it has been changed since it was last saved you ll be asked if you want to save it Save saves the currently active window under its current name while Save as lets you save it under a different name Menu Reference 7 1 Undo Typing Copy Paste Shift Left Shift Right Balance Terminate Input 7 2 Menu Reference Revert goes back to the last saved version of a file and updates the curre
98. ell asstand alone functionsthat work directly with Prol con sinternal data Locating External Functions External functionsexist asindependent coderesourcesresiding inthe resource fork of afile R esourcesare identified by afour character type string and aresourcename Someexamplesare type resource name XCMD Eject Disk XFCN Play Sound CODE My External Function When your program callsan external function it must specify there sourcetype and theresourcename Prol con then searchestheresource forksofall open filesfor the appropriateresource T he search beginswith the resource fork of your executable con file If itisnot found there the resourcefork oftheP rol con application isexamined I fit still isnot found your System fileissearched Your program can open additional filesfor resources prior to invoking an external function Such files move to the head of thelist of open files and are searched beforeall others T wo external functionsthat open and close filesfor resourcesarepresent in Prol con making them always accessible T o open afilefor resources use resFile callout CODE OpenResFile name External Functions D 1 where nameis the string name of the file This call fails if the file cannot be opened The file is closed with callout CODE CloseResFile resFile Managing Resources Code and other resources can be copied from file to file using Apple s ResE dit program Alternately develo
99. en isa list containing eight values The first four values give the x y coordinates in pixels of the upper left and lower right corners of the main screen The remaining four values give the coordinates of the gray region enclosing all screens in the case of multiple monitors The gray region begins below the menu bar which is 20 pixels high The function wlimit window lines limits the number of lines that are retained in the specified window If the limit is exceeded lines are discarded from the top of the window The function wgoto window line character moves the cursor in the specified window to the given line and charac ter If the specified line is greater than the number of lines in the window the cursor is moved to the last line If the specified character is greater than the number of characters on the line the cursor is moved to the end of the line The function wfont window fontname sets the font in the specified window If the font does not exist the window s font is unchanged and the function fails The function wfontsize window points sets the font size in the specified window to the given number of points The function wtextwidth window string returns the width of the specified string in pixels for the font and font size of the specified window The function wselect window begin end selects text in the specified window with the given begin and end character positions T he selected text is highlighted
100. er and numeric Mini Reference Manual 11 69 remove s n remove file remove s removes deletes the file named s but fails if s cannot bere moved Error 103 snot string See also rename 11 70 Mini Reference Manual rename s1 s2 n rename file rename s1 s2 renames the file named s1 to be s2 but fails if the renaming cannot be done Error 103 s1 or s2 not string See also remove Mini Reference Manual 11 71 repl s1 i s2 replicate string repl s1 i produces a string consisting of i concatenationsof s1 Errors 101 i not integer 103 s1 not string 205 i lt 0 306 inadequate space in string region 11 72 Mini Reference Manual reverse s1 s2 reverse string reverse s1 produces a string consisting of the reversal of s1 Errors 103 s1 not string 306 inadequate space in string region Mini Reference Manual 11 73 right s1 i s2 s3 position string at right right s1 i s2 produces a string of size iin which s1 is positioned at the right with s2 used for padding at the left as necessary Defaults i s2 Errors 101 103 205 306 1 i not integer s1 or s2 not string i lt 0O inadequate space in string region See also center and left 11 74 Mini Reference Manual rtod r1 r2 convert radians to degrees rtod r1 produces the degree equivalent of r1 given in radians Error 102 ri not real See also dtor Mini Reference Manual 11 75 runerr i x terminate with r
101. er String Library Folders Program Input Program Output Error Output Program Options Window Options Compiler Memory Execution Memory 7 4 Menu Reference moves the insertion point and window display to that line Help Lookup produces a help window for the cur rently selected text The Options menu lets you change aspects of the currently active window and also lets you specify options for compiling linking and running con programs Select Font or Font Size to get a hierarchical menu from which you can specify the font or font size for the currently active window Select Tabs to specify the number of spaces per tab stop If Auto Indent is checked each new line typed is indented as much as the preceding line Parameter String lets you specify arguments for the main procedure of your Icon program See Chapter 5 for details Library Folders allows you to specify which folders the linker searches for intermediate files that are specified in link declarations See Chapter 5 for details If you want to specify where your Icon program gets standard input select Program Input You get a dialog box that allows you to chose between the keyboard the currently active window or afile in which case you get a file dialog box that allows you to chose a file Program Output is similar to Program Input except it lets you chose where program output goes to the Interactive
102. error conditions and so forth String Comparison Thevalueofthekeyword amp compare determinesthe method of string comparison If amp compare is0 comparison isonacharacter by character basis fthevalueof amp compare isnonzero theM acintosh international comparison method isused See Appendix B for moreinformation Function Tracing Prol con providestracing for built in functionsaswell as for programmer defined procedures F unction tracing is Prolcon Extensions 10 1 10 2 Prolcon Extensions controlled by amp ftrace Theinitial valueof amp ftraceisO Ifthe value of amp ftrace isnonzero when afunctioniscalled amp ftrace isdecremented and atracemessageisproduced in the same style asthat used for proceduretracing Function return failure suspension and resumption also aretraced in the styleof procedures Suppose for example that hello icn contains procedure main args amp ftrace 1 every upto amp lcase Hello world end Theoutputis hello icn 3 upto amp lcase Hello world amp null amp null hello icn 3 upto suspended 2 hello icn 3 upto resumed hello icn 3 upto suspended 3 hello icn 3 upto resumed hello icn 3 upto suspended 4 hello icn 3 upto resumed hello icn 3 upto suspended 5 hello icn 3 upto resumed hello icn 3 upto suspended 7 hello icn 3 upto resumed hello icn 3 upto suspended 8 hello icn 3 upto resumed hello icn 3 upto suspended 9 hello icn 3 upto res
103. ers Code resources constructed using M PW tools expect register A5 to point to the global and static variables But register A5 points to Prol con s global variables and these cannot be used by the stand alone code resource To use global variables and static data these steps must be taken 1 Save Prolcon s register A5 2 Allocate memory for the global and static data the A5 world 3 Initialize the memory C allows globals and static variables to have initial values 4 Deallocate the memory and restore register A5 prior to returning The methods for doing these things are non trivial and beyond the scope of this document Consult the August 1990 revision of M acintosh T echni cal N ote 256 Stand Alone Code for more information Accessing QuickDraw An external function often needs to access the Q uickD raw globals of the Prol con application for which it is performing a service Q uickD raw s drawing operations assume a properly initialized Q uickD raw world which is provided by Prol con M ost QuickD raw calls are supported and no special effort is required O ne limitation however is that explicit references to QuickD raw globals like thePort and screenBits are not allowed A linker cannot resolve the offsets to these variables because it does not process a stand alone module along with Prolcon Since the structure of the Q uickD raw global data is known and there isa pointer to it in the A5 world stan
104. es Error 102 ri not real See also rtod Mini Reference Manual 11 23 entab s1 i1 i2 in s2 inserttabs entab s1 i1 i2 in producesastring basedon s1 in which runs of blanks are replaced by tabs Tab stopsareat 1 i2 in with additional stops obtained by repeating the last interval Default i1 Errors 101 103 210 306 9 i1 i2 in not integer s1 not string i1 i2 in not positive or in increasing sequence inadequate spacein string region See also detab 11 24 Mini Reference Manual errorclear n clear error indication errorclear clears the indications of the last error See also amp error Mini Reference Manual 11 25 exit i exit program exit i terminates program execution with exit status i If the program was run from the desktop and i isnot 0 the user is left in Prol con rather than returning to the desktop Default i 0 normal exit status Error 101 i not integer See also stop 11 26 Mini Reference Manual exp r1 r2 compute exponential exp r1 produces eraised to the power r1 Errors 102 r1 not real 204 overflow See also log and N1 N2 Mini Reference Manual 11 27 file s1 s2 3 sn generate file names file s1 generates the names of the files and subfolders in the folder s1 It fails if s1 is not the name of a folder File names are given as partial path names with a prefix Default s1 current working folde
105. es E 3 Memory Displays E 5 Running MemMon E 9 Further Reading F 1 Index l 1 l Getting Started Backing Up Your Prolcon Getting Started Read this First Welcometo Prolcon a powerful programming language that s packed with features to help you solve complex problems quickly Prolconisahigh level general purpose programming language that s rich in string and list processing capabilities Prolcon snovelexpression evaluation mechanism produces quick neat solutions to even your most complex problems Prolcon is an enchanced version of the Icon programming language that was developed at the University of Arizona Prolcon sadded features were designed and implemented by Mark Emmerand RalphGriswold Before You Do Anything Else First make backup copies of your original Prolcon disks Then install Prolcon on your Macintosh You ll find complete installation instructions starting on page 1 2 After that read A Guide to the Manual starting on page 1 3 Knowing Your Macintosh You should know generally how to operate your Apple Macintosh computer how to use the mouse and the menus and how to open documents copy files and install applica tions on your hard disk If you need help consult the manuals that came with your Macintosh Getting Started 1 1 Installing Prolcon Configuration Prolcon requires System Version 6 0 1 or higher and at least 400 KB of free memory we recommend 1MB RAM The memor
106. escriptor used to return result dargv 1 the integer 123 dargv 2 the string test string dargv 3 the real number 54 9 N otice that the first true user argument alwaysis dargv 1 argc is a count of the number of user argumentsin the dargv array In this example its value is 3 ArgO Arg1 Arg6 are definitions in Prolcon h for dargv 0 dargv 1 dargv 6 respectively ip isa pointer to a short integer that is used to signal error conditions Its usage is described later in this appendix Finally callback is the entry point of aC function within Prol con that can be called to provide utility functions T hese callback routines are readily accessed through the definitions provided in Prolcon h Allocating Memory Returning a result other than an integer or null value requires the alloca tion of memory This is a two step process 1 A request for memory is made specifying the number of bytes needed No memory is allocated at this time but a garbage col lection may occur to assure that the requested amount of space is available when it is needed All references to Icon data must be in argument descriptors at this time Specifically pointers to Icon string or block data may not be in C variables since the data may D 10 External Functions move but C variables are not changed If a garbage collection occurs pointers in the input argument list are adjusted accordingly 2 When storage is actually needed a
107. eter String Library Folders Program Input Program Output Error Output Program Options Window Options Compiler Memory TTC ee Block region String region Evaluation stack Co expression blocks Qualifier pointer region other by clicking on the Copy button You can navigate to the previous or next compiler Execution Memory Allocation bytes 65000 String region This Program Compiler Default Set and Examine memory allocation setting by clicking on Prev or Next When you re satisfied click on OK to have the changes take effect You may also click on Cancel if you decide not to make the changes 4 14 Compiling and Running Programs Blocks and Strings Evaluation Stack Co Expressions Qualifiers Prolcon manages execution memory automatically It keeps track of values your program no longer needs and collects them when it needs space to create new values Consequently you can process a large amount of data as long as it doesn t all have to be kept around at one time Some programs however need to keep a lot of strings and structures such as tables of words and their counts Such programs may need larger regions for storage than are provided by default If this happens you get an error message such as You can increase the size of the offending region to give your program more room Select Execution Memory from the Options menu Proceed as described for compiler me
108. f the window None of these actions alters the insertion point To quickly reposition the file at the insertion point after scrolling and examining another part of the file press the enter key not the return key Arrow The arrow keys on the M acintosh Plus M acintosh SE Keys and M acintosh II keyboards move the insertion point one character or one line at atime Holding down the s amp key with the up down left or right arrow key moves the insertion point to the beginning of the file end of the file start of a line or end of a line respectively The Search menu has several options for moving through a window Jumps Jump to Top Jump to Bottom Jump to Line T hese have shortcuts ae goes to the top of the window like 95 goes to the bottom of the window like 3 J asks for a line number and when you supply it moves the insertion point and the display to that line 6 6 Entering and Editing Programs Fonts and Tabs You can select afont using the Options menu The font selected applies to the currently open window The font size is also selected under Options Those that are outlined are displayed in better quality than those that aren t The default is 9 point M onaco Under Options Tabs you can select the number of spaces per tab stop The default is 4 Only one font font size and tab setting can be used in a window although different
109. face Window The box in the left corner of the title bar closes the Regions window If the text contained in the terminal window has been modified since it was last saved Prol con prompts you to save or discard the new contents or to cancel the Close operation H olding down the option key while clicking in the Close box closes all windows Closing the Interactive window does not discard it but merely hides it You can make it visible again from the Win dow menu described below The box in the right corner of the title bar is the zoom box Clicking in this box enlarges the window to full screen size or returnsit to its former size The scroll bars and window resizing region in the lower right corner are entirely conventional They let you position the file within the window and change the size of window If the file name ends with the suffix icn the window is considered runnable and contains a small status display in the lower left corner It informs you that your program is available for editing is being compiled is running has paused or is awaiting input from the keyboard Window Clicking anywhere in a window or its title bar places the Selection window in front of all other windows on the desktop Clicking and dragging in the title bar allows you to position the window on the desktop H olding down thes key when clicking in the title bar allows you to move the window without bringing it to the front When se
110. follows the Apple Human Interface guidelines If you re familiar with other Macintosh editors ProIcon s editor should seem very natural to you Chapter 6 contains detailed information about the Prolcon editor For now just do what comes naturally Now you re ready to run your first Prolcon program Pull down the Run menu and select Compile Window Tee Windows Finn PRSE ClaEyEd BVELEG Link after Compile Run after Link Compile File Link File Run File The cursor changes toa spinning beachball while Prolcon e compiles and links your program Your program then executes and the output pops up ina window named Inter active E pteractive EE EE 3 4 A Quick Tour Now youcanchange your program Suppose you want to know what version of ProIcon you re running Add two lines so that you have hello icn procedure maint wep tec Hello world 3 we tecavers ion wei ted Goodbye 3 end To run this program use the K shortcut that you saw in the Run menu Oops there was a mistake in the program Compilation Error Missing right parenthesis In file hello icn The error and location also are noted in the Interactive window following the previous output Interactive Hello world File Ad hello icn Line 4 missing right parenthesis The compiler finds the error in line 4 when it s looking for a parenthesis to complete line 3 and does not find it Clos
111. g2 arg16 where type is the 4 character string XCMD or XFCN resource_name isa string used to specify the function s resource by name arg1 arg16 are optional arguments to be converted to strings and passed to the function The H yperC ard interface imposes a limit of 16 arguments callout succeeds and returns a string result which may be the empty string There is no way for an XCM D or XFCN to Signal failure or to suspend Prol con produces an error message if the external function cannot External Functions D 5 be found if insufficient memory is available to convert arguments or return the result string or if the XCM D or XFCN setsthe passFlag truein the XCmaBlockrecord structure described below After loading the external function callout performs a Pascal style subroutine call to the first memory location of the external function A single parameter is on the stack a pointer to an XCmdBlock record struc ture This structure contains a count of the number of arguments an array of handles pointing to null terminated strings for the input arguments and a place to return a handle to a null terminated result string The C language form of the XCmdBlock structure is contained in file IconXCmd h on the distribution disk in folder External Functions XCMDs XFCNs C Sources The XCmaBlock structure also defines a callback mechanism by which external functions can obtain access to 29 different services provi
112. gram on which you re working Suppose for example you re working on the program shown below and you want to know more about the function put Select put by dragging over it or double clicking on it process alternatives procedure altsidefn local alist alist defn while Mikal ist symsitabiuptod 0339 do moveti break return alist end look for comment procedure commenti ine if line i then return end 5 4 Online Help Now select Help Lookup from the Search menu Mits Options Run Find Enter Selection Find Again Replace Replace and Find Again Replace All Jump to Top Jump to Bottom Jump to Line Help Lookup A help window for put pops up Online Help puteL 3 L puteL x produces L and adds x to the right end of L Errors 108 L not list 307 inadequate space in block region See also gett popes pull 3 and pushes Online Help 5 5 Keyboard Youcan get online help in this way by selecting text from Shortcuts any window including a help window Thisis useful for example for following cross references such as the one for put in the window on the previous page As indicated in the Search menu H is a keyboard shortcut for getting help The help key on the extended keyboard does the same thing Help for To get help for an Icon operator select the symbol or Operators symbols for the operator Since some prefix and infix opera tors use the
113. grams that don t need lots of memory However the kinds of applications for which Prolcon is best do require lots of memory It s impractical to try such applications without enough memory and while Prolcon can work over a wide range of memory if there really is not enough memory it will work poorly or 4 16 Compiling and Running Programs not at all Output Limiter Because window data is held in memory writing a large amount of data to a window may exhaust memory Prolcon provides a way of limiting the number of text lines that are retained in a window The limit can be controlled from your program by selecting Window Options from the Options menu which gives you this dialog box You can turn output limiting on or off as indicated and also specify the number of lines retained when it is on For example suppose you set the limit to 350 lines and your program begins writing output to the window Untitled 3 icn As new lines appear at the bottom of that window the window contents scroll up and are available for review by moving the thumb in the vertical scroll bar When the 350th line is output Prolcon silently discards the top one eighth of the lines in the memory file The file now contains 306 lines of data and the process is repeated each time the 350 line limit is reached Persistent Settings Most options you set apply only during a session in the Prolcon application Once you quit Prolcon they are discarded
114. hapter 4 Appendix E describes how anallocation history file can be viewed interac tively 9 14 Version 8 of Icon The function mmpause s causes a pause in the interactive display giving s as the reason for the pause The default for s is programmed pause The function mmshow x s redraws the display for object x as specified by s See Appendix E for more information The function mmout s writes s as a separate line in the allocation history file Bugs and Limitations in Version 8 e Linenumbers sometimes are wrong in diagnostic messages related to lines with continued quoted literals e Large integer arithmetic is not supported in i to j and seq Large integers cannotbe assigned to keywords e Large integer literals are constructed at run time Consequently they should not be used in loops where they would be constructed repeatedly e Conversion of a large integer to a string is quadratic in the length of the integer Conversion of a very large integer to a string may take a very long time and give the appearance of an endless loop e Integer overflow on exponentiation may not be detected during execution Such overflow may occur during type conversion e Insome cases trace messages may show the return of subscripted values suchas amp null 2 that would be erroneous if they were dereferenced e Stack overflow is checked using a heuristic that may not always be effective e If an expression suchas x create exp
115. he input file but fails when the end of the file is reached The following expression is typical of programming inIconand illustrates the integration of conditional expressions and conventional control structures while line read do write line This expression copies the input file to the output file If an argument of a function fails the function is not called and the function call fails as well This inheritance of failure allows the concise formulation of many programming tasks Omitting the optional do clause inwhile do the previous expression can be rewritten as while write read Generators Insome situations an expression may be capable of producing more than one result Consider sentence Store it in the neighboring harbor find or sentence Here or occurs in sentence at positions 3 23 and 33 Most program ming languages treat this situation by selecting one of the positions such as the first as the result of the expression In Icon such an expression is a generator and is capable of producing all three positions The results that a generator produces depend on context Ina situation where only one result is needed the firstis produced as in i find or sentence which assigns the value 3 toi If the result produced by a generator does not lead to the success of an enclosing expression however the generator is resumed to produce another value Anexampleis if i find or senten
116. he normal file name suffix is 001 for the first snapshot You are not prompted for names of subsequent snapshots the suffix on your original choice is incremented automatically to produce 002 003 and so forth You can also arrange to have snapshots taken automati cally at specified points in a display See the Options specifications in the description of the Display menu that follows Menus The File menu lets you close the current allocation history file open another one and quit Some of the options in this menu are grayed out and unavailable For example you can t print from M emM on There also are options related to palettes that are reserved for future use itm Edit Display Open pipis fdgadd DAGE aperee EleEHeEE 4 Bipa Daigre BELa Heart Epiprs Gad hafinn Ga aggre ofni Ca Paap Reda All the itemsin the Edit menu are grayed out you can t do things like cutting and pasting in MemM on The Display menu lets you control the display and set options Memory Monitoring E 11 E 12 Memory Monitoring Display Run Stop Pause Continue vee Options Take Srann T Annotate Snaps Play Continuously Pose Emphasize Strings The top five menu items refer to running the display If you launch M emM on by opening an allocation history file the display starts running automatically If you launch the M emM on application directly and then open an allocation history file you l
117. he screen of the Macin tosh and other computers Naming aprogramming language is more difficultthan you might think Should the name be an acronym derived from a descriptive phrase like FORTRAN Should it try to connote some salient property of the language like EASy Should it honor some important person like Ada Should it be clever and catchy like Spitbol Or what There are other considerations Is the name easy to remember What kind of images does it evoke Isit easy to spell Easy to pronounce Distinctive Pleasant The name Icon for this programming language is not an acronym you might be able to dream up a suitable phrase though and it has no special meaning but you might well conjure one up It was chosen to be short crisp and uncomplicated And because the designers had run out of other ideas Had they foreseen the use of the word icon for those little pictograms they certainly would have picked anothername Granted the name for the language may evoke the wrong image and be taken for something it isn t Unfortunately a name once chosen published and put into use is not easily changed In the end such names really mean nothing in themselves and you ll quickly forget the confusion However you may find yourself having to explain the problem to your fellow Macintosh users more than once 3 A Quick Tour A Quick Tour In this chapter you ll see how Prolcon works and how to create run and
118. he size of line changes automatically There are many functions for analyzing strings Anexampleis find s1 s2 which produces the position in 2 at which 1 occurs as a substring For example if the value of greeting is as given earlier find or greeting produces the value 8 Character Sets While strings are sequences of characters csets are sets of characters in whichmembership rather than order is significant Csets are represented literally using single enclosing quotation marks as in vowels aeiouUAEIOU Two useful built in csets are amp lcase and amp ucase which consist of the lowercase and uppercase letters respectively Set operations are provided for csets Forexample letters amp lcase amp ucase forms the cset union of the lowercase and uppercase letters and assigns the resulting cset to letters while consonants letters aeiouAEIOU Icon Language Overview 8 3 forms the cset difference of the letters and the vowels and assigns the resulting cset to consonants Csets are useful in situations in which any one of anumber of characters is significant Anexample isthe string analysis function upto c s which produces the position in s at which any character inc occurs For example upto vowels greeting produces 2 Another string analysis function that uses csets is many c s which produces the position ins after an initial substring consisting only of characters that occur
119. he128 ASCII characters amp clock s time of day Thevalueof amp clock isastring consisting of the current time of day asin 16 30 00 amp collections i1 i2 i3 i4 garbage collections amp collections generatesthetotal number of garbage collectionsfollowed by thenumber caused by allocation in thestatic string and block regions respectively amp compare i string comparison fthevalueof amp compare isnonzero string comparison isdoneusing the M acintosh international comparison routines fthevalueof amp compareis zero comparisonisdonebyASCII collating value amp compareiszero initially amp compare isavariable Mini Reference Manual 11 165 amp cset c all characters The value of amp cset is a cset consisting of all 256 characters amp current C current co expression The value of amp current is the currently active co expression amp date s date The value of amp date isthe current date asin 1989 12 31 amp dateline s date and time of day The value of amp dateline is the current date and time of day asin December 31 1989 6 53 am 11 166 Mini Reference Manual amp digits c digits The value of amp digits is a cset containing the ten digits amp dump i termination dump If the value of amp dump is nonzero when an Icon program terminates a listing of all variables and their values is produced amp dump is zero initially amp dump is a variable amp error
120. heM acintosh international string comparison system T heselection of thesetwo systemsiscontrolledby amp compare or by checking International Comparison in the Program Options dialog Default Comparison Prol con sdefault method of string comparison isquite fast tisselected by setting keyword amp compareto zero the default Stringsarecompared leftto right on acharacter by character basis fthe two stringsaredifferent at some position theinternal ASCII character codesof thediffering charactersdeterminesthe ordering of thestrings Appendix A listsall charactersand their internal codes Thus the String Comparison B 1 System B 2 String Comparison string Ac islessthan ab because the code for A 65 is less than the code for a 97 If the strings are of different lengths and all characters in the shorter string match corresponding characters in the longer string then the shorter string is less than the longer one Thus ABC islessthan ABCD Strings are equal only if they have the same length and all characters are the same While this comparison system works for most applications the ordering implicit in the ASCII character set may be inappropriate at times For example under the default system the uppercase letters collate ahead of all lowercase letters Characters with diacritical marks like and ligatures such as are placed after all normal letters in the collat ing sequence This is n
121. hey can be omitted from displays by unchecking that box The title which appears in the middle of the first legend line normally is the name of the allocation history file to be displayed The title can be changed by editing the text box Selecting Take Snapshot is equivalent to 38 T and produces a PICT snapshot of the current display Checking Annotate Snaps causes a text box to be Pd Annotate Skip Annotation displayed before each snapshot is taken allowing you to provide about 100 characters of identifying information After you have entered the annotation click Annotate and the annotated snapshot will be taken If you want to annotate some pictures in a run but not others don t change the status of Annotate Snaps from picture to picture Instead leave it checked and click on Skip Annotation when the annotation box is presented for a picture you do not wish to annotate E 14 Memory Monitoring Play Continuously causes the display to start over after the end of the allocation history file is reached Pose changes the screen background to black so that the display can be seen without the usual underlying desktop in the background Emphasize Strings changes the method by which strings in the allocated string region are displayed to make them more obvious Memory Monitoring E 15 i Further Reading Further Reading Bond Gary XCM D sforH yperC ard Portland O regon M IS Press 1988 1SBN
122. hings together For example to write out all the different words ina file using Icon the following will do words set every insert words nextword f every write sort words Here nextword f isa procedure that generates the words from the file f The last line of this program segment may look mysterious It hints at the power of Icon What s New with Icon In addition to the features mentioned above Icon has many features SNOBOL4 doesn thave Perhaps the most exciting and useful feature is the ability of an Iconexpression to generate a sequence of values While a SNOBOL4 expression can only fail or succeed an Icon expression may fail produce a single result succeed or generate many results Generation is particularly useful for operations that naturally have several results suchas the position at which one string occurs as a substring of another You may sense the germ of this idea in the few SNOBOL4 patterns that can match in more than one way Generators lead to all kinds of interesting possibilities and give Icon s expression evaluation atwo dimensional charac ter as opposed to programming languages in whichevery expression produces exactly one result It s here that you ll find the most interesting aspects of Icon and discover how they can be used to cast complex operations in natural and concise ways Here sjusta hint The following example writes all the common positions where s1 is a substring in s2 a
123. hisformat you ll beableto find thingsquickly Datatypes areimportant in con you ll often need to know what types of data afunction or operation expects and what typeit returns T ypes are indicated by lettersasfollows c cset C co expression f file L list i integer N numeric ior r n null R record any record type p procedure S Set r real T table s string x any structure type L R S or T xX anytype N umeric suffixesare used to distinguish different argumentsof thesame type For example Mini Reference Manual 11 1 center s1 i s2 indicates that center has three arguments The first and third are strings the second isan integer The type of result produced by a function follows the function with a separating colon For example center s1 i s2 s3 indicates that center produces a sring The format of entries for operators and keywords is similar The results for generators are indicated by a sequence as in ls s1 s2 Sn Some operations such as s i produce variables to which values can be assigned Icon attempts type conversion automatically when an argument does not have the expected type so the types of arguments may be different from the expected type and still be acceptable For example center s1 10 s2 and center s1 10 s2 produce the same result since the string 10 iscon verted to the integer 10 D efault values are provided automatically in some cases when an argu ment is o
124. ibrary procedures to terminate in the same fashion as built in operations Itis advisable to use error numbers for programmer defined errors that are well outside the range of numbers used by Icon itself Error number 500 has the predefined text program malfunc tion for use with runerr This number is not used by Icon itself A call of runerr is subject to conversion to failure like any other run time error Implementation Features Different implementations of Icon support different features The keyword amp features provides information showing the features that are supported It generates the name of the computer system followed by the features of the implementation on which the current program is running For example for Prolcon every write amp features produces Macintosh ASCII co expressions error trace back external functions fixed regions large integers math functions memory monitoring string invocation Prolcon extensions Ordinarily implementation features are of interest only for writing programs that are to be run on different computer systems For example a program that uses co expressions can check for their presence as follows if not amp features co expressions then stop co expressions not available Memory Monitoring Storage allocation and garbage collection are instrumented and detailed information about these processes can be written to an allocation history file See Program Options in C
125. ice Hall by Ralph E Griswold and Madge T Griswold The first edition of this book 1983 describes Version 5 of Icon while the second edition 1990 describes Version 8 Version 2 0 of ProIcon corre sponds to Version 8 of Icon This chapter describes briefly the changes in Icon between Versions 5 and 8 and is provided for persons who have the first edition of the book but not the second If you have the second edition of the book you can skip this chapter although you may wish to check the list of known bugs and limitations in Version 8 of Icon that are listed at the end of this chapter The descriptions that follow are keyed to the first edition its chapter and page numbers Chapter 3 Numbers Page 22 Large Integer Arithmetic There is no limit on the magnitude of integers produced by integer arithmetic Page 23 Bit Operations and Mathematical Functions There are five functions that operate on integers at the bit level iand i j Produces the bit wise and of i and j ior i j Produces the bit wise inclusive or of i and j ixor i j Produces the bit wise exclusive or of i and j icom i Produces the bit wise one s complement of i ishift i j Produces the result of shifting i by j posi tions Ifj is positive the shift is left while if j is Version 8 of Icon 9 1 negative the shift is right Vacated bit posi tions are filled with zeros Page 23 Mathematical Functions The following functions perform trigonomet
126. if necessary to 32K characters and the width is limited to 32K pixels Errors 101 il not integer 103 snot string 306 inadequate space in string region See also wopen Mini Reference Manual 11 107 Prefix Operations In aprefix operation an operator symbol appearsbeforethe operand on which it operates f evaluation of theoperand fails the operation isnot performed ftheoperand generatesasequenceof results theoperation may beperformed several times T herearecomparatively few prefix operations T hey arelisted in theorder of thetypesof operands numeric cset string co expres sion and then thosethat apply to operandsof several different types 11 108 Mini Reference Manual N N N producesthenumericvalueof N Errors 102 N not integer or real 203 integeroverflow See also N1 N2 computepositive Mini Reference Manual 11 109 N N compute negative N produces the negative of N Errors 102 N not integer or real 203 integer overflow Seealso N1 N2 11 110 Mini Reference Manual c1 c2 compute cset complement c1 produces the cset complement of c1 with respect to amp cset Errors 104 c1notcset 307 inadequate space in block region Mini Reference Manual 11 111 1 s2 match string in scanning s1 is equivalent to tab match s1 Error 103 s1 not string Seealso match tab and N1 N2 11 112 Mini Reference Manual C x activate co expression C produces the outcome
127. ifies the type of data represented and the value word contains either a pointer to the data or the data itself Flag bits in the type word provide additional information In the following discussion you may wish to have a copy of the file Prolcon h available for reference found in the ExternalFunctions Samples folder Argument descriptors are in one of four forms depending upon the data represented The null value The type word containsthe T_Null type code and the F_Nqual flag bit The value word is zero Strings String descriptors are called qualifiers The type word contains the length of the string The value word points to the first character of the string T here are no flag bits set in the type word and the string is notnull terminated The absence of the F Nqual flag bit distinguishes this qualifier from all other descriptors and indicates that the type field contains a length not atype code Integers The type word contains the value D_Integer which is a combi nation of the T_Integer type code and the _F_Nqual flag bit The value word contains the integer Reals and all other data types T he type word contains the type code and the F_Ptr and F_Nqual flag bits O ther flag bits may be present as well The value word points to a block of memory that contains the actual data The size and layout of this block depends on the data type although all blocks begin with a title word containing the type code The file Prolcon
128. in string region See also left and right 11 10 Mini Reference Manual bal c1 c2 c3 s i1 i2 i3 i4 in locate balanced characters bal c1 c2 c3 s i1 i2 generates the sequence of integer positionsin s preceding a character of c1 in s i1 i2 that is balanced with respect to characters in c2 and c3 but fails if there is no such position Defaults c1 amp cset c2 0S S s amp subject i1 amp pos ifs is defaulted otherwise 1 i2 0 Errors 101 il or i2 not integer 103 snot string 104 c1 c2 or c3 not cset See also find and upto Mini Reference Manual 11 9 center s1 i s2 s3 center string center s1 i s2 produces a string of size iin which s1 iscentered with s2 used for padding at left and right as necessary D efaults i s2 Errors 101 103 205 306 1 i not integer s1 or s2 not string i lt 0 inadequate space in string region See also left and right 11 10a Mini Reference Manual changef s s change current working folder changef s changes the current working folder to s It fails if s isnot the name of a folder Error 306 inadequate space in string region Mini Reference Manual 11 11 char i s produce character char i produces a one character string whose internal representation is i Errors 101 ji not integer 205 i not between 0 and 255 inclusive 306 inadequate space in string region See also ord 11 12 Mini Reference Manual close f f close file c
129. in the Replace with part of the Find dialog box When the editor finds the search string you can skip it and go to the next one with 9 G If you want to replace 3 R does the job 3 Y performs Replace and Find Again which can speed your work Thereis also Replace All in the Search menu which does exactly that If the Replace with field is empty you delete every occurrence of what sin the Find field Warning Although you can undo a single search and replace you can t undo a Replace All As a shortcut you can enter text that is selected in a window into the Find dialog by selecting Enter Selection in the Search menu keyboard equivalent s E With this method you can initiate a search without ever bringing up the Find dialog J ust select the text you want to search for enter E and enter 36 G to find it The Search dialog lets you proceed the Find button and pretend you never started Cancel The other button is Don t Find It keeps the current settings but does not initiate a search A good time to use this is when you realize that the insertion point isn t where you want it but you ve already entered the search and replace information Just Don t Find move the insertion point then Find Again Since Prol con uses printable ASCII characters for its source files you won t need nonprinting characters often If you do you can en
130. inder is active your Prolcon program continues to run 4 18 Compiling and Running Programs 5 Online Help Online Help Prolcon provides an online help facility that allows you to getinformation about functions operations and other aspects of Prolcon without leaving the Prolcon application Online help is not a substitute for this manual or the Icon book but it can give you quick answers to many questions that come up while writing and debugging programs Help Menu There are several ways that you can get online help One is to select Online Help from the top of the menu This gives youatwo levelheirarchical menu efile Edit Search Options Run Windows About Prolcon E Proicon String Analysis String Scanning String Synthesis Structures Type Conversion Windows About MultiFinder Online Help N Assignment D o Wectoteareesaeted Co Expressions b Chooser Comparison Operations gt Control Panel Control Structures DeskzZap Csets b Find File Data Types Key Caps Debugging d SmartScrap Error Control b Super Ruler Input Output b The Clipper Miscellaneous b PERAR EAI IOE IN AAAS ASE Numeric Computation b H Finder Storage Management a b p b Online Help 5 1 lectin The first level shown on the previous page lists the cate Selecting a gories for which help is available The next level lists specific items Suppose for example that you select String Scan ning Category
131. internal computations The default sizes for these tables are adequate for most programs but if you have a very large program or one with unusual characteristics the compiler may run out of space in one of its tables If this happens you get an error message such as This message means that you have more global identifi ers than fit in the compiler s global table While you might be able to reorganize your program to work around this limit you also can make the table larger Select Compiler Memory from the Options menu and pull down the hierarchical menu it points to As you see there are a lot of sizes you can change Select Global table as indicated by the error message The current size of the global table is highlighted You can edit this text to change the size The size to use de pends on your program and the specific table involved You could count the number of global identifiers in your program but you might just as well double the current value which probably will be enough with some to spare As indicated by the radio button in this box the size you Execution Error Run time error 306 inadequate space in string region In file hello icn specify normally just applies to the current program If you want it to apply to all programs click on the Compiler Default radio button You also can copy from one to the Compiling and Running Programs 4 13 Options Font Font Size Tabs Auto Indent Param
132. ions Access is through the callout function but the string conver sion of arguments required by the XCM D XFCN interface is not done Arguments are delivered in con s internal formats and the function result is constructed in con s string or block region Prol con recognizes this style of function call when the resource type string isnot XCMD or XFCN The resource is identified with a resource name string T he methods of locating and managing resources described earlier in this appendix remain the same Because there is no data conversion this form of external function is more efficient than the XCM D and XFCN forms T he drawback is that you must have some knowledge of Prol con s internal organization to write functions that behave properly Prolcon s internal structures mirror the structures described in The Implementation of the con Programming L anguag amp see Appendix F A full discussion of these structures is beyond the scope of this manual H owever some basic concepts and simple data types such as strings integers and real numbers are described here Together with the sample programs provided in the folder External Functions Samples you should be able to construct useful functions Implementation Fundamentals Arguments are passed to a function asan array of descriptorsn memory Each descriptor consists of two long 4 byte words atype word and a D 8 External Functions value word The type word ident
133. ions called generators can produce sequences of values Goal directed evaluation causes generators to pro duce results to reach combinations that satisfy larger require ments Inshort Icon is a powerful high level programming language The things it allows you to do quickly and easily make programming more fun and less of a chore And being able to do complex things so easily may encourage you to try tasks you ve always wanted to do but couldn t face in other programming languages Iconmay well expand your pro gramming horizons More About Prolcon 2 3 2 4 More About Prolcon Icon for SNOBOL4 Programmers If you re a SNOBOL4 programmer you ll find that Icon has many of the familiar features of SNOBOL4 Some of these features are cast in somewhat different ways in Icon Since Icon evolved from SNOBOLL it has a lot of features that SNOBOL4 doesn t It also lacks some of the more esoteric features of SNOBOL4 The main differences between the two languages are described in the following sections Syntax As you probably know SNOBOL4 has a syntax all its own Ithas several different statement types that focus ona subject on which operations are performed suchas assignment and pattern matching SNOBOL4 has no control structures for expressing looping or selection itrelies on conditional operations and gotos to control the sequence of execution Although this mechanism is very general the need to fabricate loops for exampl
134. it s looking for a parenthesis to complete line 3 and does not find it Close the window named Compilation Error to get rid of it Notice A Quick Tour 3 5 3 6 A Quick Tour that the cursor is positioned at the line of your program window where the compiler found the error Generally speaking the line where an error is detected is not exactly where you made the mistake the compiler can t find an error untilsomething actually syntactically incorrect occurs you could have had the missing parenthesis atthe beginning of line 4 for example Correct your program and run it again to be sure it s right When you re finished save your program if you want by selecting Save from the File menu If you close the program window without saving changes you ll be asked if you want to save your modified program When you re finished witha Prolconsession leave the application by selecting Quit from the File menu or use the Q keyboard shortcut That s the basic idea Enter a program or bring in an existing one using Open from the File menu run it make corrections and re runit as necessary and save your program when you re finished Of course there s a lot more to Prolcon The next chapter describes more features of Prolcon Read on 3 A Quick Tour A Quick Tour In this chapter you ll see how Prolcon works and how to create run and correct Icon programs This is just a start there s more information in
135. k contains sample Icon programs and some interesting data The External Fucntions folder on that disk contains HyperCard XCMD and XFCN material as well as samples for Prolcon 2 0 s external func tion interface see Appendix D The MemMon 2 0 folder on the second disk contains a separate application for viewing memory managementin Prolcon see Appendix E There also are sample files A Guide to the Manual This manual is divided into four parts e The introduction that you re reading e A User s Manual that describes the Prolcon applica tion for the Macintosh e Supplementary material on Icon which goes beyond the basic reference The Icon Programming Lan guage e Appendices and an index The remainder of this part tells you more about Prolcon in a general way including its relationship to the Icon program ming language and a special introduction to Icon for readers familiar with the SNOBOL4 programming language Getting Started 1 3 1 4 Getting Started The User s Manual begins with a quick tour of Prolcon then introduces you to compiling and running programs the online help facility entering and editing text and menu reference Part three contains a guide to the most current version of the Icon programming languageand special features of Prolcon as well as a mini reference manual The appendices cover character codes international string comparison Icon language checklists external functions memory mo
136. l need to select Run or use the keyboard shortcut 3 R to start the display You also can use Run to start the display over after it s finished You can stop the display at any time by selecting Stop from the Display menu It s faster and usally more convenient to use the keyboard shortcut tea If you want to stop the display temporarily select Pause or use 38 To go on select Continue or use If you want to see each step in the allocation or marking process select Step or use the key in combination with the space bar The Options menu lets you control the display and snapshots Important note options must be specified before a display starts to run changing them in mid Regions EJ String EJ Block Granularity bytes pixel Garbage Collect fo initial skip EJ Always show stream has no effect on the current display Pause _ _ _ _ _ __ Snap gt Start of garbage collection C J After garbage after marking EJ Show active data after marking J End of garbage collection L E Explicit mmpause calls Status and Title gt Display status and legend lines The default values are as shown above You can change any of them The Regions box specifies which allocated data regions are displayed Normally both the string and block regions are displayed but you c
137. like this to mathematical formulas Text files on computers are just strings Icon s repertoire for string processing provides many ways toanalyze and synthesize strings Analysis operations make it easy to find patterns in text things like words and parenthesized expressions Synthesis operations make it easy to build up complex strings out of simpler ones and to format them in any desired way The key to managing complex data is organization Structures provide this facility Different situations and different kinds of dataneed different kinds of organizations Icon offers several kinds of structures for diverse needs Lists allow values of any kind notjust characters to be arranged in sequence and accessed by position Lists also can be accessed like stacks and queues for programs that need to handle data in these ways Icon also provides sets which are unordered collections of values Operations on sets like union and intersection provide easy ways to handle problems that deal with common attributes and properties Icon has more including tables that provide associative lookup using keys of any type Icon also lets you build up complicated structures of your own There is no end to the possibilities Many real world problems have more than one solution Sometimes it s necessary to select among those solutions to satisfy a constraint or to get a solution to a larger problem Icon providesa very powerful method for doing this Express
138. log box with message s1 and editable text s4 s2 is text for the OK button and s3 is the title for the Cancel button The function returns the editable text which may have been modified The function fails if the user selectsthe Cancel button Defaults s1 s2 s3 s4 Error 103 OK displayed no Cancel button s1 s2 s3 or s4 not string See also message 11 36 Mini Reference Manual iand i1 i2 i3 computebit wise and iand i1 i2 produces an integer consisting of the bit wise and ofi1 and i2 Error 101 i1 or i2 not integer See also icom ior ishift and ixor Mini Reference Manual 11 37 icom i1 i2 compute bit wise complement icom i1 produces the bit wise complement of i1 Error 101 i1 not integer See also iand ior ishift and ixor 11 38 Mini Reference Manual image x s produce string image image x produces a string image of x Error 306 inadequate space in string region Mini Reference Manual 11 39 insert X x1 x2 X insert element If Xisatable insert X x1 x2 inserts key x1 with value x2 into X If X isa set insert X x1 inserts x1 into X insert X x1 x2 produces X Default x2 amp null Errors 122 X not set or table 307 inadequate space in block region See also delete and member 11 40 Mini Reference Manual integer x i convert to integer integer x produces the integer resulting from converting x but fails if the conversion is not
139. lose f closes f Error 105 fnot file See also open Mini Reference Manual 11 13 collect i i2 n perform garbage collection collect i1 i2 causes a garbage collection in region i1 assuring at least i2 bytes of storage are available in that region but fails if the requested space is not available The regions are identified as follows i1 region 1 gatic 2 sring 3 block If i1 isO acollection isdone but no region isidentifiedand i2 has no effect D efaults i1 0 i2 0 Errors 101 ilor i2 not integer 205 i1 not between 0 and 3 inclusiveor i2 lt 0 11 14 Mini Reference Manual copy x1 x2 copy value copy x1 produces a copy of x1 ifx1 isa structure otherwise it produces xi Error 307 inadequate space in block region Mini Reference Manual 11 15 cos r1 r2 compute cosine cos r1 produces the cosine of r1 in radians Error 102 r1 not real See also cos 11 16 Mini Reference Manual cset x c convert to cset cset x produces a cset resulting from converting x but fails if the conver sion is not possible Error 307 inadequate space in block region Mini Reference Manual 11 17 currentf s get current working folder currentf returns the name of the current working folder as a full path name with suffix Error 214 input output error 11 18 Mini Reference Manual delay i i delay delay i delays program execution for i milliseconds Clock resolution is 1 60
140. ls if name isnot the name of a folder The file names are given as partial paths with prefix The function ftype name returns an 8 character string that consists of the type and creator signatures for the file name fname isa folder it returns the empty string The function fails if name is neither a file nor a folder The function fset name type creator sets the type and creator signatures for name to the specified strings If type or creator is the empty string the corresponding signature is not changed The function failsif mame is not the name of a file The function getfile text signature name performs a Get File Dialog for the folder name with text displayed T he string signature is used to filter file types It may be 0 4 8 12 or 16 characters long Only files with matching signa tures are displayed The function returns the full path name of the file selected by the user If the signature is the one character string f only folders are displayed The function returns the path name of the folder selected This function fails if the user selects Cancel The selected file is not opened only its path name is returned Prolcon Extensions 10 7 Launching an Application 10 8 Prolcon Extensions The function putfile text orompt name performs a Put File Dialog in folder name with text displayed and prompt as the suggested file name The function returns the full path name of the file selected by the user It fails
141. mission 11 134 augmented 11 151 exponentiation 11 127 augmented 11 151 string concatenation 8 2 11 131 augmented 11 151 list concatenation 11 132 augmented 11 151 numeric not equal 11 141 augmented 11 151 ung not equal 11 147 augmented 11 151 se object not equal 11 149 augmented 11 151 Operations prefix 11 108 element generation 9 4 11 117 list invocation 9 6 11 163a size 9 4 11 115 positive 11 109 negative 11 110 l 8 Index dereference 11 120 null test 11 118 match and tab 11 112 random value 9 4 11 116 activation 11 113 non null test 11 119 refresh 11 114 complement 11 111 Options menu 4 3 4 16 6 6 6 7 7 4 7 5 ord s 9 2 11 59 Output 4 9 4 11 9 5 9 6 Output files 4 9 4 11 Output limiter 4 16 Output standard 4 9 Output standard error 4 9 P Page Setup Parameter String Parentheses C 1 Partial path names 4 7 Partition size 4 17 Paste 6 3 6 4 7 2 Path files 4 9 6 11 Path names 4 7 Pattern matching 2 5 2 7 Pause 4 16 7 5 Persistent settings 4 16 Pointers 8 9 pop L 8 9 11 60 pos i 11 61 Precedence of operators C 1 C 3 Prefix operations SeeO perations prefix Print 6 8 7 1 7 2 Printing 6 7 6 8 7 2 wprint 10 6 11 101 Printing characters 9 3 proc x i 9 8 11
142. mitted or has the null value For example the second argument of center defaults to 1 while the third argument defaults to a single blank Thus center s1 is equivalent to center s1 1 Refer to the entry for center to see how this information is shown Errors may occur for a variety of reasons T he possible errors and their causes are listed for each function and operation Again see the entry for center for examples In particular note that a phrase such as s not string means s is neither a string nor a type that can be converted to a sring 7 In addition to the errors listed in the entries that follow an error also can occur if there is not enough space to convert an argument to the expected type For example converting avery long string to anumber for usein a numerical computation conceiveably could run out of memory space Such errors are unlikely Cross references among entries have two forms M ost cross references refer to functions and operations that perform related computations such as center left and right There also are cross references among operators and control strcutures with similar syntax suchas xand N1 N2 even though thecomputationsperformsarenot related 11 2 Mini Reference Manual Functions T heargumentsof functionsare evaluated from left to right Ifthe evaluation of an argument fails thefunction isnot called Somefunctionsmay generatea sequenceofresultsfor agiven set of argume
143. mory in this case select String region from the hierarchical menu The current default size is shown Deciding on a new size may take some thought and possibly experimentation If you have a lot of RAM you can set the value consider ably larger and not worry about it If you don t have a lot of RAM you may need to search for a value that works possibly reducing the sizes of other regions Windows also require memory You may need to close unnecessary windows if the total amount of RAM is a problem If you re running under MultiFinder you may need to adjust Prolcon s partition size see the section on MultiFinder later in this chapter In any event it s neces sary to know something about how Prolcon uses memory The block and string regions are where the values your program produces are kept The other sizes refer to other aspects of program execution The evaluation stack is used to hold temporary values during generation and recursive procedure calls Overflow of the evaluation stack usually indicates runaway recur sion You should look for a problem in your program if this happens If the stack really needs to be larger you can increase its size as for other regions If the problem is runaway recursion however increasing the stack size only increases the time until overflow occurs Every co expression contains its own evaluation stack Co expression stacks normally are smaller than the main Compiling and Running Pr
144. n R 9 shift option S shift option T Shift option U shift option V shift option W shift option X shift option Y 9 shift option Z 9 shift option s shift option shift option e shift option 6 T e shift option 1 Character Codes A 3 dec oct hex Times Symbol Zapf dingbats keyboard sequence 32 040 20 space 33 041 21 oe shift 1 34 042 22 y lt shift 35 043 23 ag shift 3 36 044 24 4 shift 4 37 045 25 T shift 5 38 046 26 amp amp shift 7 39 047 27 i 3 40 050 28 a shift 9 41 051 29 shift 0 42 052 2a C shift 8 43 053 2b i shift 44 054 2c y amp 45 055 2d Z 46 056 2e i amp a 47 057 2f gt 48 060 30 0 0 2 0 49 061 31 1 1 co 1 50 062 32 2 2 e gt 2 51 063 33 3 3 v 3 52 064 34 4 4 Vv 4 53 065 35 5 5 x 5 54 066 36 6 6 x 6 55 067 37 7 7 x 7 56 070 38 8 8 x 8 57 071 39 9 9 a 9 58 072 3a shift 59 073 3b 60 074 3c lt lt Ga shift 61 075 3d t 62 076 3e gt gt shift 63 077 3f t shift 64 100 40 b9 shift 2 65 101 41 A 36 xX shift A 66 102 42 B B shift B 67 103 43 X G shift C 68 104 44 D A os shift D 69 105 45 E E shift E 70 106 46 F shift F 71 107 47 G Tr shift G 72 110 48 H H shift H A 4 Character Codes 109 110 111 112 113 oct 111 112 113 114 115 116 117 120 121 122 123 124 125 126
145. n allocation request is made to actually allocate memory in the string or block region If an external function performs several allocations to build a composite result such asa list it must perform a reques for all memory needed prior to doing any of the actual allocations For examples of functions allocating memory for specific data types csets external blocks large integers reals and strings examine the programs in the folder External Functions Samples N ote that in the case of real values the memory request and allocation steps have been combined within one function makereal External Data Blocks An external function may allocate external data blocks These are memory blocks of arbitrary size whose contents are entirely up to the external function Prolcon never looks at the contents of the external block You should not store a relocatable pointer a pointer to a block or string within Prolcon s block or string region within an external block because it will not be adjusted by Prol con during a garbage collection External blocks can be assigned to an Icon variable or stored in an element of an con structure They may be duplicated with thelcon copy function Since external blocks reside in the block region they may be moved as the result of a garbage collection Like other con objects their space is released when it is no longer referenced Returning Results The external function returns a pointer to a des
146. n be combined with every do to formulate the traditional for style control structure every k i to j do square k This expression can be written more compactly as every square i to j There are several other control structures related to generation One is alternation 8 6 Icon Language Overview expr 1 expr2 which generates the results of expr1 followed by the results of expr2 Thus every write find or sentence1 find or sentence2 writes the positions of or insentence1 followed by the positions of or in sentence2 Again this sentence can be written more compactly by using alternation in the second argument of find every write find or sentence1 sentence2 Another use of alternation is illustrated by i j 1k 0 1 which succeeds if any of i j or k has the value 0 or 1 String Scanning The string analysis and synthesis operations described earlier work best for relatively simple operations on strings For complicated operations the bookkeeping involved in keeping track of positions in strings becomes burdensome and error prone In such cases Icon has a string scanning facility that is analogous in many respects to pattern matching in SNO BOLA In string scanning positions are managed automatically and atten tion is focused on a current position in a string as it is examined by a sequence of operations The string scanning operation has the form S expr where s is the subject string t
147. n block specified by descriptor d RunErr n dp return error number n with value in descriptor pointed to by dp Qual d test if descriptor d isa qualifier refers to a string StrLen q length of string specified by qualifier q StrLoc q location of first character of string Type d type code of descriptor Callback Functions and Values The callback argument provided to your function offers a way to obtain values and services from Prolcon A complete list of values and services provided isfound in Prolcon h The veallback function provides the version number of the callback interface which currently is 1 This number is incremented in each Prol con release that adds new callbacks Before using these new callbacks an external function should test that it is executing with a version of Prol con that provides these new functions The following list shows the more common callbacks veallback return a word value providing the version number of the interface alccset allocate a cset block alcextrnl n allocate an external data block of n words alcreal val allocate real block and store val in it alcstr s slen allocate string space of size slen characters and store string s in it External Functions D 13 blkreq n request n bytes will be needed in the block region Returns Success or Error cvint dp convert descriptor pointed to by dp to an integer Returns T_Integer or CvtFail cvreal dp convert descriptor pointed to b
148. n of an Icon program and garbage collection is performed auto matically to reclaim storage for subsequent reallocation AnIcon program mer normally need not worry about storage management However in applications that require a large amount of storage or that must operate ina limited amount of memory some knowledge of the storage management process may be useful Version 8 of Icon 9 11 Icon has three storage regions static string and block Some imple mentations including Prolcon do not havea static region The keyword amp collections generates four values associated with garbage collection the total number since program initiation the number triggered by static allocation the number triggered by string allocation and the number triggered by block allocation The keyword amp regions generates the current sizes of the static string and block regions The keyword amp storage gener ates the current amount of space used in the static string and block regions The value given for the static region presently isnot meaningful Run Time Errors When a run time error occurs a diagnostic message is produced indicating the nature of the error where in the program the error occurred and when possible the offending value Next a trace back of procedure calls is given followed by the offending expression For example suppose the following program is contained in the file max icn procedure main i max a 1 end proce
149. nd s3 every write find s1 s2 find s1 s3 What s Missing in Icon Icon lacks some of SNOBOL4 s most powerful features the ability to modify a program during execution the ability to compile and execute strings on the fly and the ability to redefine functions and operators dynamically These features of SNOBOL4 while very powerful in terms of what youcan do during program execution are also expensive in terms of theimplementation and the kind of program structure needed to make them feasible If you re used to these esoteric features of SNOBOL4 you may be disappointed initially when programming in Icon In most cases the same results can be achieved in Icon by using different techniques For those things that can t be recast in Icon you may want to continue using SNOBOL4 How ever there also are things you can do easily in Icon that have no natural counterpart in SNOBOL4 Most programmers who know both SNOBOL4 and Icon do most of their pro gramming inIcon More About Prolcon 2 9 2 10 More About Prolcon About the Name Icon Asa Macintosh user you may think that using the name Icon fora programming language is misleading or possibly a subtle pun Actually the choice of Icon as the name for the programming language you are about to use has nothing to do with the Macintosh The name was chosen in 1976 before the word came into use to describe the pictograms that identify files and functions on t
150. nfix operators so you cannavigate as you wish You may have noticed that the last item on the first level of the help menus is Index If you select it you get a window that lists all the help entries Help Index Online Help 5 7 Online Help chars 3 return e closet reversed collect 3 right 3 copys rtod 3 cost J runerr 3 c lock create e s Pe collections csetco a4 52 SCompare del agg 3 tis S ecset deleteca s2 amp current detabt gt gt P s date displayt3 PRS S date ine dtorc gt s1 s2 digits eyil z1 s dump el e2 seek error entabe 3 segt errornumber errore learg 3 seti ferror text every 1 do e Sine3 Berrorvd ue exitii sorti This window isa handy way to find something if you re not quite sure what it is or if you don t know its category You can of course select any help entry from the index 5 8 Online Help 6 Entering and Editing Text Untitled Windows Entering and Editing Text This chapter explains text editing and window manage ment You ll read about e Editing text in windows e Additional editing shortcuts available when your program is reading input from the keyboard e Managing windows on the desktop Prolcon follows the Apple human interface guidelines with a few extensions If you re familiar with other text editors on the Macintosh you ll feel right at home with the Prolcon editor The Editor The Prol con editor can be used to crea
151. ng if expr fails See also expr1 expr2 Mini Reference Manual 11 191 expr i x1 x2 xi limit generator expr i generates at most i results from the outcome for expr Errors 101 i not integer 205 i lt 0 See also x 11 192 Mini Reference Manual s expr x scan string s expr sets amp subject to s amp pos to 1 and then evaluates expr The out come isthe outcome of expr Error 103 snot string See also x Mini Reference Manual 11 193 A Character Codes 2 8 OnNoaNBWNF CO oct 000 001 002 003 004 005 006 007 010 011 012 013 014 015 016 017 020 021 022 023 024 025 026 027 030 031 032 033 034 035 036 037 Keyboard Chart Times Symbol Zapf dingbats keyboard sequence p p p p p p p p p p p p p p p p p p amp shift option 2 shift option A home amp shift option B s shift option C enter amp shift option D end amp shift option E amp shift option F shift option G shift option H delete 9 shift option l tab s shift option J s shift option K page up shift option L page down shift option M return shift option N shift option O shift option P 3 shift option Q 9 shift optio
152. ng to greeting and address which assigns the zero length empty string to address The number of characters ina string s its size is given by s For example greeting is 11 and address is 0 Icon uses all 256 characters of the extended ASCII character set There are escape conventions similar to those of C forrepresenting characters that cannot be keyboarded Strings also can be read in and written out asin line read and write line Strings can be constructed by concatenation as in element read If the concatenation of a number of strings is to be written out the write function canbe used with several arguments to avoid actual concatenation write read Substrings canbe formed by subscripting strings with range specifications that indicate by position the desired range of characters For example 8 2 Icon Language Overview middle line 10 20 assigns to middle the string of characters of line between positions 10 and 20 Similarly write line 2 writes the second character of line The value 0 refers to the position after the last character of a string Thus write line 2 0 writes the substring of line from the second character to the end thus omitting the first character Anassignment can be made to the substring of string valued variable to change its value For example line 2 replaces the second character of line by three dots Note that t
153. ni Reference Manual pos i1 i2 test scanning position pos i1 produces amp pos if amp pos i1 but fails otherwise Error 101 i1 not integer See also amp pos and amp subject Mini Reference Manual 11 61 proc x i p convert to procedure proc x i produces a procedure corresponding to the value of x but fails if x does not correspond to a procedure If x isthe string name of an operator i is used to distinguish between prefix and infix operators with the same symbols i 1 designates unary prefix operators i 2 designates binary infix operators and i 3 designates ternary distributed operators Default i 1 Errors 101 i not integer 205 inotl 2 or3 See also args 11 62 Mini Reference Manual pull L x pull from list pull L produces the rightmost element of L and removesit from L but fails if L is empty Error 108 L not list See also get pop push and put Mini Reference Manual 11 63 push L x L push onto list push L x adds x to the left end of L and produces L Errors 108 L not list 307 inadequate space in block region See also get pop pull and put 11 64 Mini Reference Manual put L x L put onto list put L x produces L and adds x to the right end of Land produces L Errors 108 L not list 307 inadequate space in block region See also get pop pull and push Mini Reference Manual 11 65 putfile s1 s2 s3 s4 get file name
154. nitoring and references 2 More About Prolcon More About Prolcon If You re New to Icon Iconisanexciting high level general purpose program ming language that has unusual features like high level operations on strings and structures pattern matching goal directed evaluation dynamic typing and run time creation of data structures Icon s rich set of operations and control structures and its powerful expression evaluationmechanism give you the ability to write concise solutions to complex problemseasily and quickly You can use Icon for rapid prototyping of large systems or for quick reformatting of data for problems in artificial intelligence for text analysis or for quickly changing com plex files Icon was developed at The University of Arizona It s the most recent language resulting froma long line of research that produced languages like SNOBOL4 On the surface Icon looks a lot like many other modern programming languages It has a syntax similar to that of C and Pascal and ithas many of the traditional control structures you ve come to expect but Icon is much more powerful It has genera tors expressions that may produce more than one result and ithas goal directed evaluation which allows many complex computations to be expressed in concise and natural ways searching for solutions is done automatically Icon is a rich language It has an extensive repertoire of operations on strings of charac
155. nonymous The function key T generates the keys in table T Without this func tion the only way to find the keys in a table is to sort the table and pick the keys out of the resulting list For example every write key T writes all the keys in T Given the keys it is possible to get the corresponding values as in every x key T do 9 4 Version 8 of Icon write image x image T x which writes the keys in T and their corresponding values The functions member insert and delete apply to tables as well as sets The function member T x succeeds if x is a key for an element in the table T but fails otherwise The function insert T x y inserts into table T an element with key x and value y If there already was a key x in T its corresponding value is changed Note that insert has three arguments when used with tables as compared to two when used with sets An omitted third argument defaults to the null value The function delete T x removes the element with key value x from T If x is not a key in T no operation is performed delete succeeds in either case There are several options for sort T i The form of the result produced and the sorting order depends on the value of i If iis 1 or 2 the size of the sorted list is the same as the size of the table Each value in the list is itself a list of two values a key and the corre sponding value If i is 1 these lists are in the sorted order of the keys If i
156. nother example of the use of string analysis functions in scanning is line while tab upto letters do write tab many letters which writes all the words in line As illustrated in the examples above any expression may occur in the scanning expression Unlike SNOBOL4 in which the operations that are allowed in pattern matching are limited and idiosyncratic string scanning is completely integrated with the rest of the operation repertoire of Icon Structures Icon supports several kinds of structures that consist of aggregates of values with different organizations and access methods Lists are linear structures that can be accessed both by position and by stack and queue functions Sets are collections of arbitrary values withno implied ordering Tables provide anassociative lookup mechanism Lists Lists in Icon are sequences of values of arbitrary types Lists are created by enclosing the lists of values in brackets An example is car1 buick skylark 1978 2450 in which the list car1 has four values two of which are strings and two of which are integers Note that the values in a list need not all be of the same type In fact any kind of value can occur in a list even another list as in 8 8 Icon Language Overview inventory car1 car2 car3 car4 Lists also can be created by list i x which creates a list of i values each of which has the value x The values ina list can be referenced by position much
157. ntered there is no set for it tested by words word In this case a new set is created The current line number is appended to the set for the word inany event After the input file has been read the table of words is sorted the corresponding values are sets of line numbers For each word its set is sorted and the word and linenumbers where it occurs are written out For example if the input file is On the Future how it tells Of the rapture that impells To the swinging and the ringing Of the bells bells bells Of the bells bells bells bells Bells bells bells To the rhyming and the chiming of the bells the output is 1 On the Future how it tells 2 Of the rapture that impells 3 To the swinging and the ringing 4 Of the bells bells bells 5 Of the bells bells bells bells 6 Bells bells bells 7 To the rhyming and the chiming of the bells and bells chiming future how impells 37 4 5 7 1 1 2 rapture 2 7 3 3 1 2 1 6 7 rhyming ringing swinging tells that the 2 3 4 5 7 Icon Language Overview 8 13 Itis easy to make this program more sophisticated For example a dictionary of words to be ignored could be added as a set With a little more work the output format could be made more attractive and so on 8 14 Icon Language Overview 9 Version 8 of Icon Version 8 of Icon A complete description of Icon is contained in The Icon Programming Language Prent
158. ntering and leaving your function For example using LightspeedC upon function entry execute RememberA0 save code resource address found in AO SetUpA4 save entry A4 load with saved AO value J ust prior to returning from thefunction execute RestoreA4 Remember if you are creating external functionsother than XC M Dsand XFCNs thereisno need to usethiscode becauseP rol con takes care of thingsfor you Global and static data placed within the coderesourcearenot guaranteed to persist between function callsbecausethe external function could be purged from memory and then reloaded If persistenceisrequired mark the coderesourcenon purgeable You can do thiswhen you createit set project type attrs in LightspeedC or afterwards by using ResE dit Coderesourcesarealways purged from memory when theprogram terminatesbecauseP rol con closesall open resourcefilesother than itself To maintain persistence acrossruns install the resourcein theProl con application proper Using Assembly Language Ifyou arewriting in assembly language usethe method described above for Symantec compilers T hat is placeyour global and static data at the end of your code resource and referenceit asarelative offset from the start of the code resource U pon function entry registersA0 and A4 point to the External Functions D 3 start of the code resource and they can be used as base pointers for address ing Using MPW Compil
159. nterval between tab stops The remaining tab stops are at 1 i2 in Additional tab stops if necessary are obtained by repeating the last interval If you do not specify the tab stops the interval is 8 with the first tab stop at 9 For the purposes of determining positions printing characters have a width of 1 b has a width of 1 and r and n restart the counting of positions Nonprinting characters decimal codes 0 31 and 127 for Prolcon have zero width A lone space is never replaced by a tab character but a tab character may replace a single space that is part of a longer run The function detab s i1 i2 in produces a string obtained by replac ing each tab character in s by one or more spaces Tab stops are specified in the same way as for entab Chapter 5 Structures Page 48 Sets A set is an unordered collection of values Sets have many of the properties normally associated with sets in the mathematical sense The function set L creates a set that contains the distinct elements of the list L For example set abc 3 creates a set with two members abc and 3 If the argument to set is omitted an empty set is created Any specific value can occur only once in a set For example set 1 2 3 3 1 creates a set with the three members 1 2 and 3 There are several operations on sets The function member S x succeeds and returns x if x is a member of the set S but fails otherwise Therefore
160. ntly active window accordingly Page Setup displays a dialog box that lets you determine how the contents of windows are printed Print displays a dialog box that allows you to print the contents of the currently active window Transfer allows you to transfer to another application directly from Prolcon It displays a dialog box that lets you select the application you want Finally Quit terminates the Prolcon application If you have any windows that have been modified but not saved you are prompted to save or discard the contents The Edit menu lets you do the usual M acintosh operations with the clipboard and also provides some extra facili ties for use with the Prolcon editor See Chapter 6 for detailed information The Undo selection lets you undo the last cut paste or editing operation you did What appears in that selection depends on what you did last In the selection shown here the last operation was the typing of text Cut copies the current selection to the clipboard and deletes it Copy does the same but it does not delete the selection from the currently active window Paste copies the contents of the clipboard into the currently active window at its selection point Clear deletes the current selection but does not change the contents of the clipboard Select All selects the entire contents of the currently active window Shift Left and Shift Right move the selected text left or right one ta
161. nts fan argument generates more than onevalue the function may becalled repeatedly with different sets of values Mini Reference Manual 11 3 abs N N computeabsolutevalue abs N producestheabsolutevalueof N Error 102 Nnotnumeric 11 4 Mini Reference Manual acos r1 r2 compute arc cosine acos r1 producesthe arc cosineof r1intherangeofOto x Errors 102 ri not real 205 r1 greater than 1 See also cos Mini Reference Manual 11 5 any c s i1 i2 i3 locate initial character any c s i1 i2 succeeds and produces i1 1 provided s i1 isin c and i2 is greater than i1 It fails otherwise Defaults s amp subject i1 amp pos ifs is defaulted otherwise 1 i2 0 Errors 101 il or i2 not integer 103 snot string 104 cnotcset See also many and match 11 6 Mini Reference Manual args p i get number of procedurearguments args p producesthenumber ofargumentsforprocedure p Forbuilt in procedureswith avariable number of arguments the valueproduced is 1 For declared procedureswith avariable number of arguments the value returned isthenegative of thenumber of formal parameters Error 106 pnotprocedure See also proc Mini Reference Manual 11 7 asin r1 r2 compute arc sine asin r1 producesthearcsineof r1intherangeof n 2 to n 2 Errors 102 ri not real 205 r1 greater than 1 See also sin 11 8 Mini Reference Manual atan r1 r2 r3 compute arc tangent atan r1 r2 prod
162. o be examined and expr is an expression that performs the examination A position in the subject which starts at 1 is the focus of examination Matching functions change this position The matching function move i moves the position by i and produces the substring of the subject between the previous and new positions If the position cannot be moved by the specified amount because the subject is not long enough move fails A simple example is line while write move 2 whichwrites successive two character substrings of line stopping when there are no more characters Another matching function is tab i which sets the position in the subject Icon Language Overview 8 7 toiand also returns the substring of the subject between the previous and new positions Forexample line if tab 10 then write tab 0 first sets the position in the subject to 10 and then to the end of the subject writing line 10 0 Note that no value is written if the subject is not long enough String analysis functions such asfind can be used in string scanning In this context the string that they operate on is not specified and is taken to be the subject For example line while write tab find or do move 2 writes all the substrings of line prior to occurrences of or Note that find produces a position which is then used by tab to change the position and produce the desired substring The move 2 skips the or that is found A
163. o the beginnings of the regions The space in the string region is shown as a single string Since overlapping substrings may be created after strings are allocated the identification of the ends of strings after garbage collection is somewhat problem atical and is not shown N otice that in the legend a garbage collection is now attributed to the need for space in the block region The string region was collected too but not charged for it O bserve that garbage collection has freed a considerable amount of space for subsequent allocation E 8 Memory Monitoring Running MemMon By now you should be ready to run M emM on so that you can see displays like these in real life These displays will be much more interesting than the pictures here especially if you have a color monitor There are two ways to start M emM on opening it as an application or opening an allocation history file which launches M emM on automatically Start by opening the concord mem file in the MemMon Samples folder from the Prolcon distribution disk You ll see a display that is similar to the ones given here but instead of just a snapshot you ll see each object as it is allocated T he display pauses when a garbage collection is needed This gives you a chance to look at the whole display in detail Memory Monitoring E 9 E 10 Memory Monitoring Look at the individual objects that have been allocated and see if you can identify their types
164. o you type return at the end of every line of the program Prolcon s editor follows the Apple Human Interface guidelines If you re familiar with other Macintosh editors ProIcon s editor should seem very natural to you Chapter 6 contains detailed information about the Prolcon editor For now just do what comes naturally Now you re ready to run your first Prolcon program Pull down the Run menu and select Compile Window Tee Windows Finn PRSE ClaEyEd BVELEG Link after Compile Run after Link Compile File Link File Run File The cursor changes toa spinning beachball while Prolcon e compiles and links your program Your program then executes and the output pops up ina window named Inter active E pteractive EE EE 3 4 A Quick Tour Now youcanchange your program Suppose you want to know what version of ProIcon you re running Add two lines so that you have hello icn procedure maint wep tec Hello world 3 we tecavers ion wei ted Goodbye 3 end To run this program use the K shortcut that you saw in the Run menu Oops there was a mistake in the program Compilation Error Missing right parenthesis In file hello icn The error and location also are noted in the Interactive window following the previous output Interactive Hello world File Ad hello icn Line 4 missing right parenthesis The compiler finds the error in line 4 when
165. of activating C Error 118 C not co expression See also x C Mini Reference Manual 11 113 4C1 C2 create refreshed co expression C1 produces a refreshed copy of C1 Errors 118 C1 not co expression 305 inadequate space in static region Seealso N1 N2 11 114 Mini Reference Manual X II compute size x produces the size of x Error 112 x notcset string co expression or a structure See also N1 N2 Mini Reference Manual 11 115 2x1 x2 generate random value If x1 isan integer x1 produces a number from a pseudo random se quence If x1 gt 0 it produces an integer in rangel to x1 inclusive If x1 0 it produces a real number in range 0 0 to 1 0 Ifx1 isastring x1 produces a randomly selected one character substring of x1 that isa variable if x1 isa variable If x1 isa list table or record x1 produces a randomly selected element which is a variable from x1 If x1 isaset 2x1 produces a randomly selected member of x1 Errors 113 x1 notinteger string or structure 205 x1 lt 0 306 inadequate space in string region if x1 string See also s expr 11 116 Mini Reference Manual Ix1 x2 XS x XN generate values If x1 isafile x1 generates the remaining linesof x1 If x1 isastring x1 generates the one character substrings of x1 and produces variables if x1 isa variable If x1 isalist table or record x1 generates the elements which are vari ables of x1 For lists and
166. ograms 4 15 evaluation stack If overflow occurs in a co expression it may be necessary to increase the size of co expression blocks Most of the size of a co expression block is de voted to its stack Since stack overflow in a co expression may not be detected it can cause other program malfunc tions If you re using co expressions that perform recursive procedure calls or deeply nested generation and your program has problems suspect such overflow The qualifier pointer region is used only during garbage collection to keep track of strings in your program that need to be saved If you get an error message that indicates that this region is not large enough increase the size You should check your program to see if it really needs to have a lot of different strings at the same time There is another side to all this If you have only a small amount of RAM the default region sizes may be too large to even get started and you may have to reduce the default sizes to be able to run Prolcon programs at all If this is the Output limiter On CO ines Off case start with a small program and reduce the string and block region sizes to smaller values until your program runs You also can decrease the size of the evaluation stack and qualifier pointer regions if necessary Reducing the size of co expression blocks only has an effect if you use co expressions You can reduce all sizes substantially and still be able to run small pro
167. ollection may discover problems caused by your function before they are allowed to propagate further through the system The external function interface is an evolving one Look fora README file in the External Functions folder for new features and information that became available after this manual was published D 14 External Functions Memory Monitoring Memory Monitoring Icon has a large repertoire of data types including strings csets lists sets tables and records T hese data types and operations on them provide much of the richness of the language and make it possible to repre sent and process complex data with relative ease Storage Management Behind the scenes as your program runs Icon manages data allocating space as it is needed and collecting unused data that is no longer in use garbage when space runsout Such complex storage management operations are of course far removed from the simple computational operations of a programming language like Fortran in which most operations closely mimic the instructions of the computer on which it runs In fact the vast difference between the language operations of con and the machine instructions that ultimately carry them out is what makes Icon so useful for complicated problems Although you generally aren t aware of storage manage ment when you write or run an Icon program storage management often is important since memory is a scarce commodity and storage
168. on 4 13 8 1 9 11 9 12 E 2 E 3 E 7 E 8 E 14 Generators 2 1 2 3 2 8 8 1 8 5 8 7 8 11 9 9 9 10 11 2 C 4 get L 11 32 getch 9 7 11 33 getche 9 7 11 34 getfile s1 s2 s3 10 7 11 35 gettext s1 s2 s3 s4 10 7 11 36 Goal directed evaluation 2 1 2 3 8 1 8 5 8 6 H H elp online 5 1 5 8 7 1 7 3 H elp index 5 7 5 8 Help Lookup 5 4 5 7 7 3 Help menu 5 1 5 3 H elp windows 5 4 H yperC ard 1 3 XCM Ds 1 3 1 8 D 1 D 5 D 8 D 14 XFCNS 1 3 1 8 D 1 D 5 D 8 D 14 i to j 8 6 11 156 iand i1 i2 9 1 11 37 icom i 9 1 11 38 Icon applications 4 3 Identifiers C 3 undeclared 4 4 Index l 5 If then else 11 182 image x 9 9 11 39 Implementation features 9 12 Indenting text 6 7 Infixoperations SeeO perations infix Input 4 9 4 11 9 5 9 6 9 9 Input and output 4 9 4 11 9 5 9 6 Input files 4 9 Input standard 4 9 insert X x1 x2 8 10 9 3 9 5 11 40 Insertion point in text 6 2 6 6 7 3 Installation 1 2 1 3 integer x 11 41 Integers 9 1 9 9 10 1 Interactive window 3 4 3 5 6 11 6 12 10 5 Intermediatefiles 4 1 4 4 International comparison 4 5 B 2 B 7 ior i1 i2 9 1 11 42 ishift i1 i2 9 1 9 2 11 43 ixor i1 i2 9 1 11 44 J Jump to Bottom 6 6 7 3 Jump to Line 6 6 7 3 Jump to Top 6 6 7 3 Jumpsin text 6 6 7 3 K kbhit 9 7 11 45 key T 9 4 11 46 Keysequences A 1 A 2
169. on 4 16 7 5 Syntactic errors 3 5 3 6 Syntax 2 4 2 5 9 10 9 11 C 1 C 4 System dependent features 9 14 10 4 T tab i 8 7 8 8 11 85 table x 8 10 11 86 Tables 8 10 8 11 9 4 9 5 10 2 10 3 Tabs 6 6 6 7 7 4 Tabular material 9 2 tan r 9 2 11 87 Terminal input shortcuts 6 11 Terminate Input 4 11 7 2 7 3 Termination dumps 4 5 10 2 Text files 6 2 7 8 Tile Windows 6 13 7 5 7 6 to by 11 156 Tracing 4 4 4 5 10 3 10 4 Transfer 7 1 7 2 Trigonometric functions 9 2 trim s1 c 11 88 I 10 Index Type checking 8 1 11 2 Type codes 9 5 9 6 11 1 Type conversion 8 1 11 2 type x 11 89 U U nary operators SeeO perators prefix Undeclared identifiers 4 4 Undo 6 4 6 9 7 2 until do 11 188 Untitled windows 3 1 6 1 upto c s i1 i2 8 4 11 90 V variable s 9 9 11 90a Variable number of arguments 9 6 Variables 11 2 WwW warrange i 10 5 10 6 11 91 wclose i s 10 4 11 92 wfont i s 10 6 11 93 wfontsize i1 i2 10 6 11 94 wget i1 i2 10 4 11 95 wgoto i1 i2 13 10 6 11 96 where f 9 7 11 97 while do 11 189 Wildcards 4 8 6 11 Window arrangement 6 12 7 6 10 7 Window functions 10 3 10 6 Window management 6 12 6 13 Window Options 7 4 Window regions 6 12 Window selection 6 12 Windows 4 15 6 11 6 13 10 3 10 6 Windows closing 6 5 6 12 10 5 Windows menu 6 5 6 12 6 13 7 5 7 6 Windows
170. only within that call of the procedure and are destroyed when the procedure returns This kind of scoping is called static There are advantages and disadvantages to both kinds of scoping Dynamicscoping makesit trivially easy to associate identifiers with patterns asin BREAK OUTPUT and allows such patterns to be used throughout the program You can t do this in Icon since local identifiers come and go and there may be several with the same name However there s no way fora defined function in SNOBOL4 to have an identifier all its own that no other function can change Icon s scoping is more conventional than SNOBOL4 s More than likely you llnot notice the difference although More About Prolcon 2 7 2 8 More About Prolcon with Icon s scoping you re less likely to have obscure bugs thatresult from two procedures accidentally sharing the same identifier Data Structures Some of Icon s data structures are very similar to those of SNOBOL4 For example Icon has tables that are nearly identical to those of SNOBOL4 you should have no trouble using Icon s tables if you are familiar with those of SNO BOL4 Icon s lists are similar to SNOBOL4 s arrays al though Icon s lists have only one dimension Icon s lists however can grow and shrink and be used as stacks and queues Icon also has sets which are just collections of values very handy for cases where you want to keep a collection of t
171. ot correct when working with languages other than English or when attempting to produce a dictionary ordering that ignores capitalization In these cases the M acintosh international comparison system is useful International Comparison The M acintosh provides support for different writing systems or scripts such asRoman Arabic Greek H ebrew and Kanji Prol con only supportsthe left to right Roman based writing system Within theRoman script system Appleofferssystem files localized for the following languages British Canadian French Danish D utch Finnish French German celandic International English Italian Norwegian Portuguese Spanish Swedish SwissF rench SwissG erman T urkish and U S English T hesesystemsdiffer slightly in character orderings Itispossibleto createamixed languagesystem F or example ascholar might want Prol con to useaN orwegian collating sequenceon amachinewith aF rench system file It isalso possibleto createcustom collating sequences Addi tional information is provided at the end of thisappendix Going International Caveats Prior to system version 6 0 4 the M acintosh defined its formal character set as being in the range 0 to 216 decimal and the international comparison routines only performed special actions on those characters Beginning with system 6 0 4 the M acintosh recognises the de facto standard that has emerged for character codes 217 to 255 M any fonts have gra
172. phics in the range 217 to 255 see Appendix A Be aware that the 16 uppercase letters with diacritical marks between 217 and 244 Y i 1 U and as well as the ligatures fi fl and B participatein theinternational collation only if you are running system 6 0 4 or later T he remainder of this appen dixiswritten assuming thissystem fyou areusing system 6 0 3 orearlier thesecharactersdo notsortwhereexpected and instead collate after all other lettersstrictly according to theircharacter codevalues Setting keyword amp compare to 1 or choosing International Comparison from the Program Options dialog tells Prol con to invoketheM acintosh international string comparison system when making string comparisons T hese comparisonsaremarkedly slower than thedefault system typically four timesslower You may wish to changethe typeof comparison selectively by changing the value of amp compare asneeded When international comparison isin effect stringsare compared using asystem of primary and secondary order ings Charactersare assigned to classes n each classthereis aprimary character used for comparisons F or example the characters AAAAAAAaAAAaAaAA4A A are all assigned to oneclass of which A isthe primary character for comparisons Within each class thereisa secondary left to right ordering of characters Theessence of thecomparison algorithm isthat stringsare compared using
173. pment tools such as LightspeedC have the ability to build code resources and merge them into the resource fork of an existing file When copying code resources particularly XCM D s and XFCNs also be sure to copy any other resources present and required by the code resource such as dialogs dialog items and strings Compiling and running con programs is a two stage process con source files are compiled to produce intermediate files O ne or more intermediate files are then linked to produce an executable file In parallel with this process Prolcon copies and merges resources found in the resource forks of the source and intermediate files U nder this system you can install your external function and any associ ated resources in the resource fork of your Icon source file When Prol con compiles the program these resources are copied to the intermediate file which has the suffix u1 During the linking phase resources from all linked files are merged into the executable file Duplicated resources produce this fatal error message Resource duplicates a previously copied resource Type n ID m name s The executable file s resource fork is automatically opened during execu tion making these resources available to your program If you develop an extensive collection of external functions this system encourages you to group them into small intermediate files that are linked by your main source file T hese files can contain sm
174. pr x break out of loop break exprexitsfrom the enclosing loop and producestheoutcomeof expr Default expr amp null See also next Mini Reference Manual 11 177 case exprof x select according to value case expr of produces the outcome of the case clause that is selected by the value of expr expr is limited to at most one result 11 178 Mini Reference Manual create expr C create co expression create expr produces a co expression for expr Error 305 inadequate space in static region See also C Mini Reference Manual 11 179 every exprl1 do expr2 generate every result every expr1 do expr2 evaluates expr2 for each result produced by resuming expr it failswhentheresumption of exprldoesnot produce aresult T he do clauseisoptional 11 180 Mini Reference Manual fail fail from procedure fail returns from the current procedure causing the call to fail See also return and suspend Mini Reference Manual 11 181 if exprl then expr2 else expr3 x select according to outcome if expr1 then expr2 else expr3 produces the outcome of expr2 if expr1 succeeds otherwise the outcome of expr3 expr is limited to at most one result The else clause is optional 11 182 Mini Reference Manual next go to beginning of loop next transfers control to the beginning of the enclosing loop See also break Mini Reference Manual 11 183 not expr n invert failure not expr produces the null value if
175. produced Error 111 xnotavariable Seealso variable 11 56 Mini Reference Manual numeric x N convert to numeric numeric x produces an integer or real number resulting from converting x but fails if the conversion is not possible See also integer and real Mini Reference Manual 11 57 open s1 s2 f open file open s1 s2 produces a file resulting from opening s1 according to options given in s2 but fails if the file cannot be opened The options are character effect open for reading open for writing open for writing in append mode open for reading and writing create translate returnsto linefeeds do nottranslate returnsto linefeeds ct0O OM S75 Thedefault modeisto translate returnsto linefeedson input and to translate linefeeds to returnson output Theuntranslated mode should be used when reading and writing binary files Default s2 r Errors 103 s1 or s2 not string 209 invalid option See also close 11 58 Mini Reference Manual ord s i produce ordinal ord s produces an integer ordinal between 0 and 255 that is the internal representation of the one character string s Errors 103 snot ring 205 snotl See also char Mini Reference Manual 11 59 pop L x pop from list pop L produces the leftmost element of L and removesit from L but fails if L is empty pop isa synonym for get Error 108 L not list See also get pull push and put 11 60 Mi
176. produces look like and what they mean Basically they are refined versions of the schematic representations of memory shown on the preceding pages H ere s an example vii th PE E rare ae cia rls ST SS TT TST nT MIME MELE 1a ILII LO OEE aU LM KUTTI TLT HU LULL mit TLL Maiin e mM PAA HHA in ai avn NUL WH iN A WET HTT HA Wy rt Hike OE Wilk wth itt ALT ENITI Hit i ALULI WAEN ie TRL iT TULL HU ATL HU AULT Aa LT TITI UU Hea KONII Il m UU Hi MALIN DIALANI VO NI bl Tii Ll HHH HH TTT l r mau 0 he alate Hi iI j Hri LAT E Il ia ee i ii a lve TE i 1H Tn Ee th iil NAIMIE A EARMAn 110181 Ill iti ll At the top of the display is a two line legend T he first line shows the program state at the left the name of the allocation history file in the center and storage infor mation at the right The storage information gives the Memory Monitoring E 5 WoL ayy SUIS wor sex 4208 E 6 Memory Monitoring region sizes first with separating plus signs The four values in parentheses are the number of garbage collec tions triggered by allocation in each of these regions followed by the number of garbage collections caused by explicit calls of the function collect The second line of the legend lists the names of all the allocated types Some are abbreviated because of the limited space available The words on the display s second legend line have the following meanings free unused memory coexpr co expres
177. putfile s1 s2 s3 performs a Put File Dialog for folder s3 with s1 displayed s2 is displayed as a user prompt in the file name box as the suggested file name putfile s1 s2 s3 returns the the full path name of the file specified by the user It fails if the user selects Cancel The selected file is not created or opened only its path name is returned Default s3 current working folder Errors 103 s1 s2 or s3 not string 306 inadequate space in string region See also getfile 11 66 Mini Reference Manual read f s read line read f producesthe next linefrom f butfailson end of file D efault f amp input Errors 105 fnot file 212 fnotopen for reading 306 inadequatespacein string region See also reads Mini Reference Manual 11 67 reads f i s read string reads f i produces a string consisting of the next i characters from f or the remaining characters of f if fewer remain on f but fails on end of file In reads unlike read returns have no special significance reads should be used for reading binary data Defaults f amp input i 1 Errors 101 i not integer 105 fnot file 205 i lt 0 212 fnot open for reading 306 inadequate space in string region See also read 11 68 Mini Reference Manual real x r convert to real real x produces a real number resulting from converting x but fails if the conversion is not possible Error 307 inadequate space in block region See also integ
178. r Errors 103 si not string 306 inadequate space in string region 11 28 Mini Reference Manual find s1 s2 i1 i2 13 14 in find string find s1 s2 i1 i2 generates the sequence of integer positionsin s2 at which s1 occurs asa substring in s2 i1 i2 but fails if there is no such position Defaults s2 amp subject i1 amp pos if s2 is defaulted otherwise 1 i2 0 Errors 101 il or i2 not integer 103 s1 or s2 not string See also bal match and upto Mini Reference Manual 11 29 fset s1 s2 s3 s1 set file signatures fset s1 s2 s3 sets the type and creator signatures of s1 tos2 and s3 respectively If s2 ors3 isthe empty string the corresponding signature is not changed fset s1 s2 s3 fails if s1 isnot the name of afile Defaults s2 s3 wee Error 306 inadequate space in string region 11 30 Mini Reference Manual ftype s1 s2 get file type If s1 isafile ftype s1 returns an 8 character string consisting of the type and creator signatures for s1 Ifs1 isa folder ftype s1 returns the empty string It fails if s1 is neither Error 103 s1 not string 306 inadequate space in string region Mini Reference Manual 11 31 get L x get value from list get L produces the leftmost element of L and removesit from L but fails if L is empty get isasynonym for pop Error 108 L not list See also pop pull push and put 11 32 Mini Reference Manual getch s get character get
179. r is used in a loop and xis not a global variable unreferenceable co expres sions are generated by each successive create operation These co expres sions are not garbage collected This problem can be circumvented by making x a global variable or by assigning a value to x before the create operation asin x i amp null x Create expr e Stack overflow ina co expression may not be detected and may cause mysterious program malfunction Version 8 of Icon 9 15 10 Proicon Extensions Prolicon Extensions If you ve used another implementation of con you should haveno difficulty using Prol con Programsfrom other conimplementationsprobably will run under Prol con with littleor no change Forthemost part all recent imple mentationsof Icon havethesamelanguage facilities D iffer encesbetween implementationsgenerally arein userinter facesand specific featuresof differing operating systems M ost implementationsoflconuseacommand line interface wherecommandsaretyped in to invokel con specify the program name and so forth Prol con hasa standard M acintosh interface You ll do most thingsby selecting itemsfrom menuswith amouse Finally thereare featuresthat arespecific to Prol con T heseinclude additional functionsand keywords Thefollowing sectionsdescribeProl con extensions features that are not availablein thestandard version of Icon SeetheM iniReferenceM anual C hapter 11 for detailed information about defaults
180. r mediate files from several programs to produce a single executable file This is useful for making libraries of procedures that can be included in many programs If you want to include intermediate files from a library program you must have a link declaration that names the library in your program For example suppose you have a collection of procedures for doing rational arithmetic and you place them in a file rational icn Compile this file but don t link it as described above Now suppose you want to include this library in a program in approx icn This file should start as follows link rational procedure main When you compile and link approx icn the intermediate files from rational icn are included by the linker so you can use any procedure contained in rational icn within approx icn You ll notice that just the name rational is used in the link declaration no suffix And of course rational icn must not contain a main procedure since only one main procedure is allowed in a program and a pro gram that includes library procedures normally provides it You can link several libraries either with separate link declarations or by using a comma separated list as in link rational input output If the name of a library does not satisfy the syntactic requirements for an Icon identifier it must be enclosed in quotation marks as in link long arith You can also place intermediate files for library proce dures in
181. r return expr suspend expr1 do expr2 until expr1 do expr2 while expr1 do expr2 Reserved Words The following words are reserved for use in declarations and control structures T hey may not be used as identifiers break by case create default do dynamic else end every Icon Language Checklists C 3 fail global if initial link local next not of procedure record repeat return static suspend then to until while Generators A few operations called generators may produce more than one result if the context in which they are evaluated requires it These operations are bal c1 c2 c3 s i1 i2 file s find s1 s2 i1 i2 key T i to jbyk seq i1 i2 upto c s i1 i2 Ix amp collections amp features amp regions amp storage expr expr expr2 C 4 Icon Language Checklists Run Time Error Messages Run time error messages are divided into categories as indicated in the following list 101 integer expected 102 numeric expected 103 string expected 104 cset expected 105 file expected 106 procedure or integer expected 107 record expected 108 list expected 109 string or file expected 110 string or list expected 111 variable expected 112 invalid type to size operation 113 invalid type to random operation 114 invalid type to subscript operation 115 list set or table expected 116 invalid type to element generator 117 missing main procedure 118 co expression expected
182. r Compile 4 1 7 5 Link File 7 5 Link declarations 4 2 4 7 9 11 Linking 4 1 4 2 7 5 9 11 list i x 11 49 Lists 8 8 8 9 8 11 9 9 Literals 8 2 8 3 log r1 r2 9 2 11 50 Loops 8 5 M main procedure 4 2 many c S I1 i2 8 4 11 51 map s1 S2 S3 11 52 match s1 s2 i1 i2 11 53 Matching functions 2 6 8 7 8 8 member X x 8 10 9 3 9 4 11 54 MemMon 1 2 1 3 4 4 4 5 E 4 E 15 Memory management 4 11 4 16 Memory monitoring 1 2 1 3 4 4 4 5 9 14 9 15 E 1 E 15 Memory settings 4 11 4 16 7 8 M enus 5 1 5 8 7 1 Edit 6 3 6 6 7 2 7 3 File 3 2 3 3 3 6 6 1 6 2 6 4 6 7 6 8 7 1 7 2 7 8 Options 4 3 4 16 6 6 6 7 7 4 7 5 Run 3 4 3 6 4 1 4 3 4 16 7 5 Search 5 5 5 6 6 6 6 8 6 11 7 3 Windows 6 5 6 12 6 13 7 5 7 6 message s1 s2 s3 10 7 11 55 mmout s 11 55a mmpause s 11 55b mmshow x s 11 55c Monitors 1 2 M ouse 6 2 10 6 move i 8 7 8 8 11 55d M oving in windows 6 5 6 6 10 4 10 6 M ulti file search 6 9 6 11 7 3 MultiFinder 4 15 4 17 10 8 name x 11 56 New 6 1 7 1 next 9 10 11 183 Nonprinting characters 6 9 9 3 not 11 184 Null valued arguments 11 2 numeric x 11 57 Numerical computation 9 1 9 2 O Omitted arguments 11 2 Online Help 5 1 5 8 7 1 Open 6 2 7 1 open s1 s2 11 58 Opening files 6 2 7 1 Operations infix 11 121 I lit invocation 9 6 11 163a remainder
183. region 11 86 Mini Reference Manual tan r1 r2 tan r1 produces the tangent of r1 in radians Errors 102 ri notreal 204 r1 asingular point of tangent See also atan compute tangent Mini Reference Manual 11 87 trim s1 c s2 trim string trim s1 c produces a string consisting of the charactersof s1 up tothe trailing characters contained in c Default c blank Errors 103 s1 not string 104 cnotcset 306 inadequate space in string region 11 88 Mini Reference Manual type x s produce type type x produces a string corresponding to the typeof x Mini Reference Manual 11 89 upto c s i1 i2 i3 i4 in locate up to characters upto c s i1 i2 generates the sequence of integer positionsin s preceding a character of c in s i1 i2 It fails if there is no such position Defaults s amp subject i1 amp pos ifs is defaulted otherwise 1 i2 0 Errors 101 i1 or i2 not integer 103 snot string 104 cnotcset See also bal and find 11 90 Mini Reference Manual variable s x produce variable Produces the variable for the identifier or keyword named s but fails if there is no such variable Local identifiers override global identifiers Error 103 snot string See also name Mini Reference Manual 11 90a warrange i i arrange windows warrange i arranges the windows on the screen according to the valueof i i arrangement 0 stacked 1 tiled 2 closed Windowsin usebytheinput
184. riable For example i1 i2 producesthesame result as i1 i1 i2 There are augmented assignment operators for all infix opera tionsexcept assignment operations T heerror conditionsfor augmented assignment operationsarethesameasfor the basic operations Error 111 x1 notvariable See also x1 x2 Mini Reference Manual 11 151 x1 i x2 x1 swap values x1 t x2 exchangesthevaluesof x1 and x2 and producesthevariable x1 Errors 101 x1 or x2 requires integer but other argument not integer 103 x1 or x2 requires string but other argument not string 111 x1 or x2 notavariable See also x1 x2 and x1 lt gt x2 11 152 Mini Reference Manual x1 lt x2 x1 assign valuereversibly x1 lt x2 assignsthe valueof x2 to x1 and producesthe variable x1 It reversesthe assignment ifit isresumed Errors 101 x1 or x2 requires integer but other argument not integer 103 x1 or x2 requires string but other argument not string 111 x1 notavariable See also x1 x2 and x1 lt gt x2 Mini Reference Manual 11 153 x1 lt gt x2 x1 swap values reversibly x1 lt gt x2 exchanges the values of x1 and x2 and produces the variable x1 It reverses the exchange if it is resumed Errors 101 x1 orx2 isa keyword that requires an integer value but the other argument is not an integer 103 x1 orx2 issubscripted string or amp subject but other argument not string 111 x1 orx2 not a variable See also x1 lt x2 and
185. ric computations sin r sine of r cos r cosine of r tan r tangent of r asin r arc sine of r acos r arc cosine of r atan r arc tangent of r atan r1 r2 arc tangent of r1 r2 In all cases angles are given in radians There are two forms of argu ments for atan depending on whether or not the second argument is supplied The following functions convert between radians and degrees dtor r the radian equivalent of r given in degrees rtod r the degree equivalent of r given in radians The following functions perform mathematical calculations sqrt r square root of r exp r e raised to the power r log r1 r2 logarithm of r1 to the base r2 default e Chapter 4 Character Sets and Strings Page 25 Csets The keyword amp letters consists of the 52 upper and lowercase letters The keyword amp digits consists of the ten digits It is provided as a convenience 0123456789 works just as well Page 27 Strings The function char i produces the one character string corresponding to i The function ord s produces the integer correspond 9 2 Version 8 of Icon ing to the one character string string s Page 37 Tabular Material Two functions deal with tabs in textual material entab s i1 i2 in detab s i1 i2 in The function entab s i1 i2 in produces a string obtained by replac ing runs of consecutive spaces blanks in s by tab characters There is an implicit tab stop at 1 to establish the i
186. rite an Icon procedure that does the matching shown above procedure p while write tab upto do move 1 end and use it as if it were a pattern s pl Aword of advice here Trying to write pattern matching in Icon the way you would in SNOBOL4 often leads to frustration and awkward programs It s muchbetter to spend the time getting used to the way Icon does pattern matching and to use Icon for its strengths rather than to try to force it to do things the way SNOBOL4 does Scope Scope is a technical term that refers to the portion of a program in whichan identifier is known and in whichits value is accessible At first glance you may notsee the differences in scoping of identifiers in SNOBOL4 and Icon There are significant differences however InSNOBOL4 every identifier is known throughout the entire program There is no distinction between global and local identifiers If an identifier is an argument or is local toa defined function its value is saved when the function is called anew value is assigned and the old value is restored when the function returns The current value of the identi fier however is available to the entire program Thisisa form of dynamic scoping Icon on the other hand has two kinds of identifiers globaland local Globalidentifiers are available to all the procedures in the program Local identifiers however come into existence when a procedure is called are accessible
187. ry search paths for folders select Library Folders As indicated you can specify one or more path names separated by returns For example Once these paths are entered they are used when linking all your ProIcon programs even if you quit the application and then launch it again You can of course change the paths any time you wish Rather than specifying individual folders your search paths may include classes of names This is done by using wildcard characters The wildcard character matches any single character in a name Thus A C matches all three character names whose first letter is A and whose last letter is C such as 4 8 Compiling and Running Programs Path Files AKC or a9c The wildcard character matches zero or more charac ters in a name For example A M matches AM or Alarm If or appear literally in a name precede each with a backslash as in or Here are some folder names as they might appear in the search path dialog Library R d Library If you use complicated search paths or change them from time to time you can record them in text files Open anew window in Prolcon and type in the paths one per line Save the file with a name that ends in paths such as search paths The Library Folders dialog includes a Use File button When you press this button you can specify the name of the file containing your pre specified search paths Prolcon reads in
188. s 4 7 Full Titles 6 13 7 5 Function keys 6 4 Function tracing 4 4 4 5 10 1 10 2 Functions 11 3 abs N 11 4 acos r 9 2 11 5 any c s i1 i2 11 6 args p 9 9 11 7 asin r 9 2 11 8 atan r1 r2 9 2 11 8a bal c1 c2 c3 s i1 i2 11 9 callout s1 s2 x1 x2 xn 10 8 11 10 center s1 i s2 11 10a changef s 10 7 11 11 char i 9 2 11 12 close f 11 13 l 4 Index collect i1 i2 11 14 copy x 11 15 cos r 9 2 11 16 cset x 11 17 currentf 10 7 11 18 delay i 10 7 11 19 delete X x 8 10 9 3 9 4 9 5 11 20 detab s1 i1 i2 in 9 3 11 21 display i f 9 9 11 22 dtor r 9 2 11 23 entab s1 i1 i2 in 9 3 11 24 errorclear i 9 13 11 25 exit i 11 26 exp r 9 2 11 27 file s 10 7 11 28 find s1 s2 i1 i2 8 5 8 8 11 29 fset s1 s2 S3 10 7 11 30 ftype s 10 7 11 31 get L 11 32 getch 9 7 11 33 getche 9 7 11 34 getfile s1 s2 s3 10 7 11 35 gettext s1 s2 s3 s4 10 7 11 36 iand i1 i2 9 1 11 37 icom i 9 1 11 38 image x 9 9 11 39 insert X x1 x2 8 10 9 3 9 5 11 40 integer x 11 41 ior i1 i2 9 1 11 42 ishift i1 i2 9 1 9 2 11 43 ixor i1 i2 9 1 11 44 kbhit 9 7 11 45 key T 9 4 11 46 launch s1 i s2 1 4 17 10 8 11 47 left s1 i s2 11 48 list i x 11 49 log r1 r2 9 2 11 50 many c s i1 i2 8 4 11 51 map s1 S2 S3 11 52 match s1 s2 i1 i2 11 53 member X x 8 10 9 3 9 4 11 54 message s1 S2 s3
189. s 9 12 11 165 amp compare 10 1 11 165 B 1 B 3 amp cset 11 166 amp current 9 10 11 166 amp date 11 166 amp dateline 11 166 amp digits 9 2 11 167 amp dump 4 5 10 4 11 167 amp error 9 12 9 13 11 167 amp errornumber 9 13 11 167 amp errortext 9 13 11 168 amp errorvalue 9 13 11 168 amp errout 4 9 11 168 amp fail 11 168 amp features 9 14 11 169 amp file 9 13 11 169 amp ftrace 4 5 10 2 11 169 amp host 11 170 amp input 4 9 11 170 amp lcase 8 3 11 170 amp letters 9 2 11 170 amp level 11 170 amp line 9 13 11 171 amp null 11 171 amp main 9 9 11 171 amp output 4 9 11 171 amp pos 9 10 11 172 amp random 11 172 amp regions 9 12 11 172 amp screen 10 6 11 173 amp source 11 173 amp storage 9 12 11 173 amp subject 9 10 11 174 amp time 11 174 amp trace 4 5 11 174 amp ucase 8 3 11 174 amp version 11 175 element generation 9 4 11 117 listinvocation 9 6 11 163a remainder 11 126 augmented 11 151 amp conjunction 11 135 amp augmented amp 11 151 size 9 4 11 115 product 11 124 augmented 11 151 intersection 9 4 11 130 augmented 11 151 positive 11 109 sum 11 122 union 8 3 9 4 11 128 augmented 11 151 augmented 11 151 negative 11 110 numeric difference 11 123 augmented 11 151
190. s Sorting is by keys for i odd by values for i even Default i 1 Errors 101 i not integer 115 X not list set or table 205 inotl 2 3 or4 307 inadequate space in block region See also amp compare Mini Reference Manual 11 81 sqrt r1 r2 compute square root sqrt r1 produces the square root of r1 Errors 102 r1 notreal 205 r1 negative See also N1 N2 11 82 Mini Reference Manual stop x1 x2 xn stop execution stop x1 x2 xn terminates program execution with an error exit status after writing x1 x2 xn to the Interactive window If the program was launched directly from the desktop Prol con remains active andthe Interac tive window remains visible Default xi a Errors 109 xi not string or file 213 xi file not open for writing See also exit Mini Reference Manual 11 83 string x s convert to string string x produces a string resulting from converting x but fails if the conversion is not possible Error 306 inadequate space in string region 11 84 Mini Reference Manual tab i s tab in amp subject tab i produces amp subject amp pos i and assigns i to amp pos but fails if i is out of range It reverses the assignment to amp pos if it is resumed Error 101 inot integer See also move Mini Reference Manual 11 85 table x T create table table x produces a table with a default value x Default x amp null Error 307 inadequate space in block
191. s behavior when presented with an unrecognized field name EvalExpr evaluate H yperT alk expression GetFieldByName get contents of card field by name GetFieldByNum get contents of card field by number GetFieldByID get contents of card field by ID SendCardMessage send message to card SendHCMessage _ send message directly to H yperC ard SetFieldByName set card field contents by name SetFieldByNum set card field contents by number SetFieldByID set card field contents by ID XCM Dsand XFCNsreturn aresult string by placing a handle to a null terminated string in the returnValue field of the XCmdBlock Prolcon disposes of the handle after copying the result string T he string is returned as the value of the callout function A complete description of XCM D and XFCN programming is beyond the scope of this manual The interested reader should consult books specifically written on the topic See the references in Appendix F N ote that XCM D s and XFCNs pass data as handles to strings These strings must be converted from Prolcon s internal format to null termi nated strings in the application heap making the interface somewhat inefficient H owever the interface does provide access to a wide range of public domain and commercial XCM Dsand XFCNs XCM Dsand XFCNs that rely upon the nine H yperC ard specific callbacks should not be used with Prolcon Doing so can lead to unpredictable results and may lock up your computer if the function does not
192. s to purchase the M acintosh system software localized for that language and use it to boot your system Done this way the language applies system wide Alternately you can use Apple s ResEdit program to install an itl2 resource into the Prol con application file It should be given the same resource ID number asthe existing _ itl2 resource in the system file When Prolcon runs the local String Comparison B 7 B 8 String Comparison version of itl2 takes precedence and is used instead of the normal system itl2 resource In this manner Prolcon can be configured for one language while the base operating system is configured for another itI2 resources can be obtained from other system files or created from scratch Creating them yourself is not a trivial task and requires considerable knowledge of M acintosh assembly language programming U sers who wish to attempt this should obtain a copy of M acintosh T echnical N ote 178 It is available free from many public sources or from Catspaw Inc C Icon Language Checklists Icon Language Checklists T hisappendix containsseveral lists you mayfind useful when writing con programs Operator Precedence conhasmany operators Precedencedetermineshow different operators in combination group with their oper ands Associativity determineswhether operationsgroup to the left or to the right Thelist that followsgivesoperators by precedencefrom highest to lowest O perators
193. sed For example every word genword do if find or word then write word writes only those words that contain the substring or An Example The following program which produces a concordance of the words from an input file illustrates typical Icon programming techniques Although not all of the features in this program are described in previous sections the general ideashouldbe clear procedure main letters amp lcase amp ucase words table maxword lineno 0 while line read do lineno 1 write right lineno 6 line line map line fold to lowercase line while tab upto letters do word tab many letters if word lt 3 then next skip short words maxword lt word keep track of longest word words word set if it s a new word start set insert words word lineno add the line number write wordlist sort words 3 sort by words while word get wordlist do lines build up line numbers numbers sort get wordlist while lines get numbers write left word maxword 2 lines 1 2 end 8 12 Icon Language Overview The program reads a line writes it out with an identifying line number and then processes every word in the line Words less than three characters long are considered to be noise and are discarded The table words contains sets of line numbers for each word The first time a word is encou
194. sion block ext external block string string subs substring trapped variable file file block refresh co expression refresh block int large integer real real number record record set set header selem set element list list header lelem lit element table table header telem table element tvibl table element trapped variable hash hash header block cset cset In color displays each type has a different color H ere there are just different shades of gray and patterns Although the types can hardly be distinguished in black and white prints they are easily identified in color displays You ll have to use your imagination in the description and displays that follow con s allocated storage regions follow the legend The static region which usually isn t very interesting is not shown The string region is followed by the block region These regions are shown as being contiguous T hey are contiguous in some implementations but not in others Consequently you shouldn t interpret the contiguity of these two regions as being significant The allocated part of the string region shows strings in white with gray bars marking their ends The unallocated portion of the string region is darker gray The block region in the display above is fully allocated and a garbage collection is about to take place This is one of the significant times in storage management at which snapshots are taken As described previously the firs
195. space end e Once the objects to be saved are identified marked they are relocated toward the beginning of their region compressing the allocated space and making more free space available so that allocation can proceed Memory Monitoring E 3 E 4 Memory Monitoring Allocation History Files The implementation of Prol con is instrumented so that the details of storage management can be recorded When this instrumentation is enabled it writesan allocation history filethat contains a record of every data object that is allocated during program execution as well as the details of garbage collection Although an allocation history file contains all the details of storage management during the execution of a program it is virtually incomprehensible simply because it is so detailed Prolcon provides a tool called M emM on that ana lyzes allocation history files and presents con s allo cated data regions in color or in black and white on a gray scale monitor A monitor with at least a four bit color or gray scale video card is required and an eight bit card is preferred M emM on will not run on aone bit black and white system Each different type of data is shown in a different color for easy recognition M emM on animates the allocation process showing each object as it is allo cated how much space it occupies and where it isin memory When a garbage collection occurs the process is shown in det
196. st and further information D 12 External Functions Typedefs word thebasic Prol con memory unit a32 bit integer uword unsigned word dptr pointer to adescriptor pointer generic pointer Definitions ArgO descriptor for result of function Argi descriptor of first argument dargv 1 Arg6 descriptor of sixth argument dargv 6 F_Ptr flag bit in descriptor type word if the valueword is apointer MaxCvtLen maximum string length in conversions T_n type codefor datatype n D_n type code plusflag bits for datatype n Errnnn definition forerrornumber nnn CvtFail attempted conversion failed Cvt attempted conversion succeeded NoCvt attempted conversion wasn t necessary alreadyin correct form Emptydp pointer to descriptor for the empty string Nulldp pointer to descriptor for thenull value Onedp pointer to descriptor containing integer one Eq lDesc d1 d2 Fail Zerodp pointer to descriptor containing integer zero Error error signal Failure failure signal Return return from function with valuein ArgO Success success signal Macros BlkLoc d block pointer in descriptor d BlIkType x type of block pointed at by x ChkNull d test for null valued descriptor test for two descriptors being equivalent return from function signaling failure IntVal d integer in the value field of a descriptor Makelnt i dp build an integer in descriptor pointed to by dp Pointer d test if descriptor d contains a pointer RealVal d real number i
197. string or list 307 inadequatespaceinblockregionif x1 list See also x1 x2 x i1 i2 and x i1 i2 Sa Mini Reference Manual 11 161 x0 x1 x2 xn xm process argument list If xO isa function or procedure x0 x1 x2 xn produces the outcome of calling xO with arguments x1 x2 xn If xO isan integer produces the outcome of xi but fails if i is out of the range 1 n In this case it produces a variable if xi isa variable i may be nonpositive Errors 106 x0 not procedure or integer 117 x0 is main but there is no main procedure start up See also x 11 162 Mini Reference Manual x0 x1 x2 xn xm process argument list as co expressions x0 x1 x2 xn is equivalent to xO create x1 create x2 create xn Error 106 x0 not procedure or integer See also x Mini Reference Manual 11 163 xIL process argument list If x isa function or procedure x L produces the outcome of calling x with the arguments in the list L If X isan integer X L produces L x but fails if x is out of range of L Errors 106 x not procedure or integer 108 Loot list See also x Mini Reference Manual 11 163a Keywords K eywordsarelisted in alphabetical order Somekeywordsare variables valuesmay beassigned to these H owever theallowabletypedependson thekeyword Seethe 11 164 Mini Reference Manual amp ascii c ASCII characters Thevalueof amp asciiisacset consisting oft
198. t phase of garbage collection marks all space that needs to be saved The completion of marking is another significant point in storage management and is shown below The strings and blocks that need to be saved are shown in black Notice that most of the strings that need to be saved are at the beginning of the string region The unmarked strings represent transient allocation and storage throughput in the string region Similarly most of the blocks in the block region are near the beginning the program that produced this allocation history file maintains a large table The rest of the blocks except for acouple near the end that were recently allocated and Memory Monitoring E 7 still in use represent storage throughput in the block region The display below shows the same storage configuration with the coloring reversed the space to be collected is now shown in black Notice the optical illusion that makes some blocks appear to be crooked E a ST ST DST a Set PUTA arin Ue Oat PARE EDUCA Aaa J ii TOO IEI UAL wani Mi i UU Hanh u PLUL OCU LUA LILI PELE ER IHU Aint 11 Me il II PULL TU ITIER ATEETAN TUNAT Hl TY SO MTT it WENN U EEE TNT AEE ATT i iT ll 11S ul si i ial Silt ADDIU U BE EA a ST SET TT STS eT THA TN MME on MEAN ANNIN Hil ae i STAT NTL E TY Tl S ATT ST ST TT iT HL E LT PT OM ULLI I in MINI Finally the display below shows memory after the saved space has been compacted t
199. te or edit any kind of text file on a Macintosh not just program files There is only one restriction The file must fit entirely in RAM Creating New Files To get to the editor launch Prolcon A window appears with thename Untitled 1 icn asshown in Chapter 3 If the default settings have been changed so that an untitled window does not appear then you can select New from the File menu or click on the New button if you were presented with a file dialog Either gives you an untitled window 3 N isa shortcut to open anew untitled window Entering and Editing Programs 6 1 Prolcon can handle up to 12 windows at once Window 0 is always assigned to the terminal U ntitled windows start at 1 and can go up to 11 As soon as an untitled window is open it s ready for you to start typing into it Opening Existing Files To open an existing file select Open from the File menu A list of files appears and you can select one to open through a standard file dialog 3 O is the shortcut here File Normally the dialog is filtered to show only files with Signatures a TEXT signature H olding down the option key displays all files in a given folder Below the scrolling window with the list of files you have a choice of All text files and icn files only The latter choice filters file names so that only those whose names end with the letters icn are displayed If you can t find a file you may have
200. ted by a colon A full path name begins with a disk name then zero or more folder names and ends with the file name Two examples are link hd Prolcon Library rational link Floppy Backup Prolcon test A partial path is relative to the current working folder and begins with a colon as in link Library rational link Prolcon test In both full and partial path names two adjacent colons mean go up one folder in your disk s folder hierarchy Library Folders If you use libraries of intermediate files you ll probably find it convenient to keep them in one or more folders separate from the rest of your Prolcon work While you can specify the paths to such folders in link declarations you ll probably find it more convenient to use Prolcon s library search facility Compiling and Running Programs 4 7 Enter search paths for libraries Use return between paths When Prolcon s linker encounters a link declaration for an intermediate file without a full path name it searches Enter search paths for libraries hd Prolcon Samples Library Use return between paths for the file first in the folder that contains your main program If the linker doesn t find the file there it uses paths specified in the Library Folders selection in the Options menu The specification of paths in the previous section goes to the file level Here it goes to the folder Wildcards level To set up libra
201. ter the Tab and Return characters by holding down the s key as you type them into the Find and Replace with fields Other nonprinting characters can be entered Consult the Keyboard Chart in Appendix A Any character code from 0 through 255 can be entered in this manner Multiple Files The Multi File Search option lets you search for and optionally replace text in more than one file Search paths let you specify the names of the files to be searched Entering and Editing Programs 6 9 text in the Find dialog just as you would for a normal To do this enter your search text and any replacement search of text in a window Then check the Multi File Search box Suppose you want to search for the word confidential in several files Enter the search text Find Replace with confidential O Match Words O Wrap Around J Ignore Case Find Don t Find Cancel O Multi File Search Check the Multi File Search box When you do another dialog appears N ow supply the names of the files to be examined Suppose you want to search the files MyData and Chapter21 Text for confidential Enter both file names using 9 return between them File names are insensitive to upper and lowercase spellings After entering the file names select OK like this Enter search paths MyData Chapter21 Text Use return between paths Return to the original search dialog When you sele
202. ters and supports a variety of sophisticated data structures The way Iconevaluates expres sions allows many programming tasks to be expressed more More About Prolcon 2 1 2 2 More About Prolcon naturally and concisely than they can bein most other programming languages This richness makes it easy to write programs that perform complicated tasks Consequently there s a lot youneed to know inorder to learn to use Icon effectively Fortunately you can get started with just a small part of the entire language Then to use Icon s capabilities to their fullest you ll want to learn more Learning Icon can be fun too Icon has lots of new ideas and is full of exciting features You ll not be bored A few words aboutstrings and structures As everyone knows the first computers were designed tosolve numerical problems the computation of trajectories orbits and so forth It wasn t long before the potential of computers to manipulate symbolic data like equations and natural language was recognized Arranging datain more complex ways like trees and lists followed anda whole new world of compu tation was opened While Icon has the usual capabilities for numerical compu tation its real strengths lie in the manipulation of symbolic data and structures In Icon symbolic data is represented by strings sequences of characters Virtually every kind of data can be represented by strings everything from the text of a manual
203. th of a second Default i 0 Error 101 i not integer Mini Reference Manual 11 19 delete X x X delete element If X isaset delete X x deletes x from X If X isatable delete X x deletes the element for key x from X delete X x produces X Error 122 X not set or table See also insert and member 11 20 Mini Reference Manual detab s1 i1 i2 in s2 remove tabs detab s1 i1 i2 in produces a string based on s1 in which each tab character is replaced by one or more blanks Tab stopsareat i1 i2 in with additional stops obtained by repeating the last interval Default i1 9 Errors 101 11 i2 in not integer 103 s1 not string 210 1 i2 in not positive or in increasing sequence 306 inadequate space in string region See also entab Mini Reference Manual 11 21 display i f n display variables display i f writes the image of the current co expression and the values of the local variables in the current procedure call If i is greater than 0 the local variablesin the i preceding procedure calls are displayed as well After all local variables are displayed the values of global variables are displayed Output is written to f D efaults i amp level f amp errout Errors 101 inotinteger 105 fnot file 205 i lt 0 213 fnot open for writing 11 22 Mini Reference Manual dtor r1 r2 convert degrees to radians dtor r1 produces the radian equivalent of r1 given in degre
204. the original around O pen Original icn and immediately save it as Mycopy icn That becomes the currently open window and you can work there secure in the knowledge that Original icn is still present in unmodified form To save all open windows usethe Save All command in the Windows menu This works the same way as using the Save command on each window The Close All command closes all open windows If any window has been modified you are asked about saving its changes Moving Around The insertion point shows where anything you type is entered You can view other parts of your file without changing the insertion point by using the mouse on the window s scroll bars Drag the scroll bar thumb to display the portion of the file you want to view Click on the arrow box at the end of the scroll bar to Entering and Editing Programs 6 5 move the window display in the indicated direction one line at a time vertical scroll bar or by 10 screen pixels horizontal scroll bar Click in the gray area adjacent to the thumb to move the file up or down one screen at atime vertical scroll bar or left and right one half screen at a time horizon tal scroll bar H old the mouse down in the either area to produce continuous scrolling after a slight delay If you have an extended keyboard the home and end keys move the display to the beginning or end of the file The page up and page down keys scroll the file by the height o
205. the paths and uses them as if you d typed them in directly The paths suffix is mandatory Input and Output You can open any file you want from inside a running Prolcon program Three files that you don t have to open are provided for your convenience standard input standard output and error output Standard input is where input comes from if you don t specify a file when reading Standard output is where output goes if you don t specify a file when writing For example while write read Compiling and Running Programs 4 9 write outputs data to window Interactive Write to Write to Write to Interactive Active Window File copies standard input to standard output Error output is amp Prefcoan ih Profion Hein ch Praicoen Runtime ty HERDME O Samples fipe h Hie amp Froicas ih Praicon Hein ch Profaon Run tine iy HERBME O Samples 4 10 Compiling and Running Programs Keyboard End of File Compiler Memory used for error messages These three files can be specified explicitly in a program as amp input amp output and amp errout Unless you specify otherwise standard input is taken from the keyboard while standard output and error output go to the Interactive window You can change input or output to the currently active window or to a file If you select a file that is also opened as a window your output goes to the window If you want to change program input
206. to click on All text files The listed files are those in the currently selected folder and they re in alphabetical order To open an existing file double click on its name or press the Open button when the file name is highlighted If the file is already open in Prolcon double clicking on itsname brings its window to the front Scrolling through a long list of files can be tedious but there s a shortcut If you type the first letter of a file s name it brings you to that alphabetic section of the file list Typing Text The cursor or insertion point is indicated by a blinking vertical line There is also the mouse pointer a flared vertical line Known as an beam when it s in the text and an arrow when it s outside the text window Typed text is inserted at the current position of the cursor If more than one character of text is selected the typed text replaces the current selection The delete key deletes one character to the left of the 6 2 Entering and Editing Programs Cut Clear Copy and Paste insertion point it backspaces If you have an extended keyboard there is a forward delete key del marked with an X inside an outlined right arrow It deletes characters to the right of the insertion point H olding either key down until it auto repeats removes multiple characters to the left or right This is a programmer s editor not a word processing editor so there is no word wrap If you type past the
207. turn a descriptor result Writing this type of function requires considerable knowl edge of Prolcon s internal structure Loading and executing either form of external function is accomplished through the Icon function callout which specifies the type and name of the function to be loaded and the arguments supplied T he function is loaded into memory from disk if necessary and invoked with the user s arguments Information about writing and using external functions is contained in Appendix D 11 Mini Reference Manual Mini Reference Manual Thismini reference manual summarizesthe built in operationsof Pro Icon Thedescriptionsare brief they reintended for quick referenceonly See Thel con Programming Languagend Chapters 9 and 10 of this manual forcompletedescriptions Theoperationsfall into four main categories functions operations keywords and control structures Functions operations and keywords perform computations while control structuresdeterminethe order of computation F unction namesprovidea vocabulary used with acommon syntax in which computationsare performed on argument lists D ifferent operators ontheother hand havedifferent syntactic forms T hey are divided into prefix operators infix operators and operatorswith different syntax K eywords likefunctions all havecommon syntax but they haveno argument lists Thedescriptionsin the mini referencemanual are stylized O nceyou becomeaccustomed to t
208. u Searching and Replacing If you have intricate searching and replacing to do write a Prolcon program Prolcon is far more versatile and powerful than any text editor For garden variety searches and replacements though the Prolcon editor offers a host of convenient features Search and replace operations are found under the Searchmenu Finding The shortcut for finding text is 9g F You are asked what to look for Type that in and click the Find button or press return The search proceeds forward from the current insertion point The next instance of what you re looking for is highlighted If it can t be found the system beeps You have several options that can be checked Match Words Only entire words match your search text If Match Words is off then searching for the also matches there and bother If on only the matches Wrap Around Searches normally go from the current insertion point to the end of the file and stop If Wrap Around is on the search goes back to the beginning after it reaches the end until it gets to where you started Ignore Case M eans that for example the and tHe both match If Ignore case is off theydon t To repeat a search use G or Find Again in the Search menu 6 8 Entering and Editing Programs Replacdng Don t Find Nonprinting Characters If you want to replace some but not all occurrences of the search string enter a replacement string
209. ub launched and program execution continues otherwise program execution terminates launch s1 s2 i fails if the launch fails Default i 0 Errors 205 inotOorl 306 inadequate space in string region Mini Reference Manual 11 47 left s1 i s2 s3 position string at left left s1 i s2 produces a ring of size iin which s1 is positioned at the left with s2 used for padding at the right as necessary D efaults i s2 Errors 101 103 205 307 il i not integer s1 or s2 not string i lt 0O inadequate space in block region See also center and right 11 48 Mini Reference Manual list i x L create list list i x produces alist of size iin which each valueis x Defaults i 0 xX amp null Errors 101 i not integer 205 i lt 0 307 inadequate space in block region Mini Reference Manual 11 49 log r1 r2 r3 compute logarithm log r1 r2 produces the logarithm of r1 to the base r2 Default r2 e x Errors 102 ri or r2 not real 205 r1 lt 0 or r2 lt 1 See also exp 11 50 Mini Reference Manual many c s i1 i2 i3 locate many characters many c s i1 i2 succeeds and produces the position in s after the longest initial sequence of charactersin c starting at s i1 It fails if s i1 isnotin c Defaults s amp subject i1 amp pos ifs is defaulted otherwise 1 i2 0 Errors 101 il or i2 not integer 103 snot string 104 cnotcset See also any Mini Reference Manual 11 51 map s1 S2
210. uces the arc tangent of r1 r2 in the range of z 2 to n 2 with the sign of rit Default 12 1 0 Error 102 ri orr2 not real See also tan Mini Reference Manual 11 8a bal c1 c2 c3 s i1 i2 i3 i4 in locate balanced characters bal c1 c2 c3 s i1 i2 generates the sequence of integer positionsin s preceding a character of c1 in s i1 i2 that is balanced with respect to characters in c2 and c3 but fails if there is no such position Defaults c1 amp cset c2 0S S s amp subject i1 amp pos ifs is defaulted otherwise 1 i2 0 Errors 101 il or i2 not integer 103 snot string 104 c1 c2 or c3 not cset See also find and upto Mini Reference Manual 11 9 callout s1 s2 x1 x2 xn xm call external function callout s1 s2 x1 x2 xn calls the external function of type s1 and name s2 with the arguments x1 x2 xn The supported values of s1 are XCMD H yperC ard XCM D XFCN H yperC ard XFCN CODE Stand alonefunction Themaximum number of argumentsfor XCM Dsand XFCNsis16 Errors 216 external function not found 352 inadequatespacefor XCM D interface 353 couldnotloadXCM D XFCN 11 10 Mini Reference Manual center s1 i s2 s3 center string center s1 i s2 produces a string of size iin which s1 iscentered with s2 used for padding at left and right as necessary Defaults i s2 Errors 101 103 205 306 1 i not integer s1 or s2 not string i lt 0 inadequate space
211. umed hello icn 3 upto suspended 10 hello icn 3 upto resumed hello icn 3 upto suspended 11 hello icn 3 upto resumed hello icn 3 upto failed Termination Dump fthevalueof amp dump isnonzero when an Icon program terminates the valuesof all current variables areprinted T he form of thedumpisthesameasfor display A dump is produced regardless of whether theprogram terminates normally or because of an error Theinitial valueof amp dump isO so no dump isproduced on termination unlessthe value of amp dump ischanged Opening Windows System Dependent Features Some implementations of Icon have features that depend on the operating system on which I con runs Examples are environment variables execution of system commands and pipes between processes Since the M acintosh does not have these features they are not available in Prol con Prol con on the other hand has several features specifically related to the M acintosh T hese are described in the follow ing sections Window Functions Prolcon provides a package of functions for manipulating windows Windows are identified by numbers The Interac tive window is numbered 0 Window numbers increase as new windows are opened N ewly created windows are not displayed on the screen You can operate on hidden windows as well as on visible ones For example you can write to a hidden window and then make it visible You can do many things with windows using the windo
212. un time error runerr i x terminates program execution with error i and offending value x Default x no offending value 11 76 Mini Reference Manual seek f i f seek to position in file seek f i seeksto position iin f but fails if the seek cannot be performed Positionsareone based seek f 0 seeksto theend of thefile f Errors 101 inot integer 105 fnot file See also where Mini Reference Manual 11 77 seq i1 i2 i3 i4 generate sequence of integers seq i1 i2 generates an endless sequence of integers starting at i1 with increments of i2 Defaults i1 1 i2 1 Errors 101 il or i2 not integer 211 i2is0 See also i1 to i2 by i3 11 78 Mini Reference Manual set L S create set set L produces a set whose members are the distinct values in thelist L D efault L Errors 108 Lnotlist 307 inadequate space in block region Mini Reference Manual 11 79 sin r1 r2 compute sine sin r1 produces the sine of r1 in radians Error 102 ri not real See also asin 11 80 Mini Reference Manual sort X i L sort list or table sort x i produces alist containing valuesfrom x If X isa lis or set sort x i produces the values of X in sorted order If X isatable sort X i produces a list obtained by sorting the elements of X depending on the value of i Fori 1 or 2 the list elements are two element lists of key value pairs For i 3 or 4 the list elements are alternative keys and value
213. vailable to you when input is requested You can highlight and copy text in one window and then paste it into the input line at the end of the Interactive window Asa convenience Prol con offers some additional editing capabilities during and only during program input 1 If the insertion point is anywhere on the last line pressing return causes Prol con to accept that line of input rather than insert a return character The same action applies when there is a highlighted selection Thus after pasting in text you can immediately press return without first having to position the insertion point at the end of line Use s return to enter a literal return character in the input line 2 If the insertion point lies in any of the text preceding the input line being composed pressing return or enter moves the insertion point to the end of the input line and repositions the window accordingly 3 If text is highlighted in any window pressing return appends that text to the end of the input line being com posed It s as if you had selected Copy then positioned the insertion point at the end of the input line and donea Paste Pressing enter instead of return also copies the text but in addition it accepts the line for input asifasecond return had been entered after the text was copied Entering and Editing Programs 6 11 Window Management Prolcon supports all of the window regions of the standard M acintosh inter
214. veral windows are simultaneoudy open windows may become hidden behind other windows The Window menu displays a list of names of all windows and associates a numbered 3 key with the first 10 Selecting the window s name from the Window menu or pressing the associated 36 key brings that window to the front The Interactive window is permanently assigned to 36 0 Window Arrangement 6 12 Entering and Editing Programs Selecting Stack Windows from the Window menu quickly arranges all open windows in an orderly cascade on the screen Tile Windows reduces the size of all windows so that they all fit on the screen without overlap H olding down the option key when clicking in awindow s title bar places it behind all other windows The Full Titles menu item attempts to display the full path name in each window s title bar and inthe Windows menu Long path names are truncated on the right The Zoom menu item duplicates the function of the zoom box in the title bar It is available with a keyboard shortcut as q The size position and current text selection are remem bered with each window T his is automatic for the Interac tive window but only occurs with other windows when they are saved Startup Options The Startup option in the Windows menu allows you to determine Prol con s launch behavior It can start up by presenting you with a file dialog which allows you to s
215. w functions You also can connect windows to files and use Prolcon sinput and output functions on them For example if you have a window named index data you can open it as afile input open index data Then you can read it asin while line read input do processi line The Prol con functions for manipulating windows are described below All window line column and character positions are one based starting at the beginning of the window The function wopen name options opens a window with the title name according to the specified options It returns an integer that identifies the window If there already is a window with the title name its window number is returned and no new window is created Prolcon Extensions 10 3 Closing Windows Getting window Setting Window 10 4 Prolcon Extensions The characters in the string option determine how anew window is opened If options contains f an attempt is made to read the file name into the new window If there is no such fileand n is contained in options an empty window is opened Otherwise wopen fails The function wclose window option closes the specified window If the window has been written to the options determine how it is closed If options isthe empty string or null the window contents are saved to disk in a file corre sponding to the window name If options contains an n the contents of the window are not saved If options contains a
216. window to the currently active window or to a file you chose Error Output lets you chose where error messages go Program Options brings up a dialog box that lets you chose several options related to running Icon programs See Chapter 5 for details Window Options lets you limit output to the currently active window and specify how windows are opened from the desktop Compiler Memory gives you a hierarchical menu from The Run menu allows you to compile and run Prolcon Compile Window 3K programs Compile Window compiles the program in the currently active window Stop terminates the currently executing program while j Pause causes it to suspend execution temporarily You vLink after Compile can continue the execution of a suspended program by Run after Link selecting Continue Compile File Link File Run File If Link after Compile is checked Prol con goes on to link your program after compiling it Uncheck this item if you want to stop after compilation Run after Link goes one step further and runs your pro gram after it has been compiled and linked The last three items on the Run menu allow you to compile link and run existing files If you select one of these items you get an open dialog box from which you can chose a file Windows The Windows menu lets you control several aspects of Full Titles window handling zoom Close All If you check Full Titles the full path name or
217. windows can have different settings T he settings are remembered when the window is saved in a file indenting When checked the Auto Indent option indents each new line typed as much as the preceding line To prevent an auto indent on the next line hold down the option key when you press return You can disable Auto Indent by unchecking it in the Options menu To change the indentation for a range of lines select them then use Shift Left or Shift Right from the Edit menu The keyboard shortcuts are and 39 The selected text is moved one tab stop left or right If you hold down the shift key while using this command text is moved in one space increments instead Balancing The Balance command in the Edit menu 36 B extends the current selection in both directions until it encloses the smallest span of text that is balanced by parentheses brackets or braces Repeat this command to select larger portions of text If the text is out of balance the system beeps Keep in mind that the Balance command just looks for matching characters It won t know if what it finds is relevant program code or material inside a string literal or comment Entering and Editing Programs 6 7 Printing The Prolcon editor uses the standard M acintosh print routines and thus works with an ImageWriter or a Laser Writer Print shortcut s P and Page Setup are in the File men
218. with thesameprecedenceare grouped together dotted linesseparate groups M ost infix operatorsare left associative T hosethat associateto the right aremarked assuch It sdifficult to remember all the precedencesand associa tivities if in doubt use parenthesesto insurethat your expressionsgroup as you expect expr expr1 expr2 expr1 expr2 expr f expr1 expr2 expr1 expr2 expr3 expr1 expr2 expr3 expr expr2 expr3 expr expr1 expra expr0 expr expr2 Icon Language Checklists C 1 C 2 Icon Language Checklists not expr expr expr expr expr expr expr expr expr expr expr expr expr expr expr expr2 expr1 expr2 expr expr2 expr1 expr2 expr1 expr2 exprl expr2 exprl expr2 expr1 expr2 exprl1 expr2 exprl1 expr2 expr expr2 expr1 expr2 exprl lt expr2 exprl lt expr2 exprl expr2 expr gt expr2 exprl gt expr2 exprl expr2 exprl lt lt expr2 expr lt lt expr2 exprl expr2 exprl1 gt gt expr2 exprl1 gt gt expr2 exprl1 expr2 exprl expr2 exprl expr2 expr1 expr2 all right associative expr1 lt expr2 expr expr2 expr lt gt expr2 expr1 op expr2 all augmented assignments break expr case expr0 of exprl1 expr2 expr3 expr4 create expr every expr1 do expr2 fail if expr1 then expr2 else expr3 next repeat exp
219. wo functions related to random access input and output in which data does not have to be read or written in sequential order The function seek f i seeks to position i in file f As with other posi tions in Icon a nonpositive value of i can be used to reference a position relative to the end of f The second argument defaults to 1 Note The Icon form of position identification is used the position of the first character of a file is 1 not 0 as it is in some other random access facilities The function where f returns the current byte position in the file f Page 93 Keyboard Functions There are three functions for reading input from the keyboard getch gets one character from the keyboard getche gets one character and echoes it to the screen kbhit succeeds if there is a keyboard character to read but fails otherwise Page 93 File Manipulation Files can be removed or renamed during program execution The function remove s removes the file named s Subsequent attempts to open the file fail unless it is created anew If the file is open s is not removed remove s fails if it is unsuccessful The function rename s1 s2 causes the file named 1 to be henceforth known by the name s2 The file named s1 is effectively removed If a file named 82 exists prior to the renaming the renaming is not performed rename s1 S2 fails if unsuccessful in which case if the file existed previously it is still known by its original
220. y dp to areal number Returns T_Real or CvtFail cvstr dp sbuf convert data in descriptor pointed to by dp into a string using sbuf of size MaxCvtLen asa buffer if necessary Returns CvtFail ifthe conversion fails Cvt ifdp was not astring but was converted to one and the result isin sbuf in which case it is null terminated and NoCvt if dp was a string makereal r dp allocate real block to hold real value r D escriptor at dp will point to block qtos dp sbuf convert a string pointed to by dp to aC style string Put the C style string in sbuf if it will fit otherwise put it in the string region sbuf must be MaxCvtLen bytes long Returns Success or Error if inadequate memory is available strreq n request n bytes are needed in the string region Returns Success or Error Conclusion External functions provide a mechanism to execute programs written in other programming languages M ost users should consider the XCM D and XFCN form of external functions because it does not require knowledge of Prolcon s internal organization For persons with more demanding requirements the raw descriptor interface offered provides more power at the cost of greater complexity Incorrectly formed data structures are likely to result in system crashes at times far removed from the original function call A useful debugging technique in this regard isto place collect 0 0 function calls on either side of your external function The garbage c
221. y monitoring application MemMon requires an 8 bit color or gray scale monitor MemMon is not needed to write or run Prolcon programs Requirements Installing Prolcon is easy First decide where you want it to reside We suggest that you create a folder named Prolcon just for that purpose When you ve done that copy the contents of the two Prolcon 2 0 disks to this folder The disks look like this Prolcon Disks protcon 2 0 Diski 5 GEEK in disk Fralcon Help icon oo Most Frolcon 2 0 External Functions Samples Proleon Runtime 2 0 MemMon 2 0 1 2 Getting Started If you re short of space you may not want to include everything All that s absolutely necessary is the Prolcon application itself However if you don tinclude Prolcon Help which must be in the same folder as the Prolcon application or in your System folder you won t be able to use online help If you don t include Prolcon Runtime 2 0 you won tbe able torun previously compiled Icon programs directly but instead will have to run them from the Prolcon 2 0 application README is a text file that contains last minute notes about things that didn t get into this manual You can open README with any text editor or Prolcon Be sure to read this file it may contain important information You may wish to print a copy to keep with your Prolcon documentation There also may be important README files in folders The Samples folder on the first dis
Download Pdf Manuals
Related Search
Related Contents
Bedienungsanleitung Infrarot Video Thermometer TA-Nr. 011251 02/06 Änd. Copyright © All rights reserved.
Failed to retrieve file