home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / teachapl.zip / APL2OS2T.ZIP / TEACH43.ATF < prev    next >
Text File  |  1996-06-16  |  68KB  |  834 lines

  1. XNÉIO 0 1                                                                      °
  2. XNÉCT 0 1.000000000000011E²13                                                  °
  3. XCÉFC 1 6 .,*0_²                                                               °
  4. XNÉRL 0 16807                                                                  °
  5. XCÉPR 0                                                                        °
  6. XCÉLX 1 5 TEACH                                                                °
  7.  NATTS 2 3 9 1 1001 1996 6 3 14 23 23 81 1 1001 1996 6 3 14 23 3 22 1          °
  8. X 1001 1996 6 3 14 23 17 78                                                    °
  9. XNC210 0 0                                                                     °
  10. XND210 1 0                                                                     °
  11. XAD211╜('DROP')('FUNCTION')                                                    °
  12. XNDAT 2 3 3 1 2 3 4 5 6 7 8 9                                                  °
  13. *(1991 11 11 8 26 35 408)                                                      °
  14.  FDISPLAY ÉFX 'D╜S DISPLAY A;ÉIO;R;C;HL;HC;HT;HB;VL;VB;V;W;N;B'                °
  15.   'Σ DISPLAY A GENERAL ARRAY IN PICTORIAL FORM'                                °
  16.   'Σ  NORMAL CALL IS MONADIC.  DYADIC CALL USED ONLY IN'                       °
  17.   'Σ    RECURSION TO SPECIFY DISPLAY RANK, SHAPE, AND DEPTH.' 'ÉIO╜0'          °
  18.   '»(0=ÉNC ''S'')/''S╜µA''' 'R╜╞µ,S                   Σ PSEUDO RANK.'          °
  19.   'C╜''┐┌└┘''                 Σ UR, UL, LL, AND LR CORNERS.'                   °
  20.   'HL╜''─''                   Σ HORIZONTAL LINE.'                              °
  21.   'HC╜HL,''Θ╕'',HL,''~+ε''      Σ HORIZONTAL BORDERS.'                         °
  22.   'HT╜HC[(0<R)⌡1+0<╞²1╞,S]' 'ΣW╜,0╧■╞0µΓ(1⌐µA)╞A'                              °
  23.   'HB╜HC[3+3╛(''2⌡~A╧«A'' ÉEA ''1+╞ε0⌡(1⌐⌡/µA)╞,A'')+3⌡1<µµS]'                 °
  24.   'VL╜''│''                   Σ VERTICAL LINE.'                                °
  25.   'VB╜VL,''Φ╟''               Σ VERTICAL BORDER.'                              °
  26.   'V╜VB[(1<R)⌡1+0<²1╞²1╟,S]'                                                   °
  27.   '»(0εµA)/''A╜(1⌐µA)µΓ╞A''   Σ SHOW PROTOTYPE OF EMPTIES.'                    °
  28.   '╕(1<╧A)/GEN' '╕(2<µµA)/D3'                                                  °
  29.   'D╜«A                     Σ SIMPLE ARRAYS.' 'W╜1╞µD╜(²2╞1 1,µD)µD'           °
  30.   'N╜²1+1╟µD' '╕(0=µµA)/SS'                                                    °
  31.   'D╜(C[1],V,((W-1)µVL),C[2]),((HT,NµHL),[0]D,[0]HB,NµHL),C[0],(WµVL),C[       °
  32.  3]' '╕0' 'SS:HB╜((0 '' '')=╞0µΓA)/'' -'''                                     °
  33.   'D╜'' '',('' '',[0]D,[0]HB,Nµ'' ''),'' ''' '╕0'                              °
  34.   'GEN:D╜«DISPLAY■A          Σ ENCLOSED ...' 'N╜Dδ.⌠'' '''                     °
  35.   'D╜(Nδ~1ΦN)≡D' 'D╜(δ≡~''  ''╤D)/D' 'D╜((1,µS)µS)DISPLAY D'                   °
  36.   '╕(2≥µ,S)╟D3E,0' 'D3:D╜0 ²1╟0 1╟«ΓA         Σ MULT-DIMENSIONAL ...'          °
  37.   'W╜1╞µD' 'N╜²1+1╟µD'                                                         °
  38.   'D╜(C[1],V,((W-1)µVL),C[2]),((HT,NµHL),[0]D,[0]HB,NµHL),C[0],(WµVL),C[       °
  39.  3]' 'D3E:N╜²2+µ,S'                                                            °
  40. X 'V╜C[Nµ1],[0]VB[1+0<²2╟,S],[0](((²3+╞µD),N)µVL),[0]C[Nµ2]' 'D╜V,D'           °
  41. *(1991 11 11 8 26 36 412)                                                      °
  42.  FGO ÉFX 'GO;b;e;t' 'Σ Expression driver' 'L0:b╜e╜''''' 'æ╜''       '''        °
  43.   't╜æ' '╕(^/'' ''=t)/L0' '╕((^/'')OFF ''=5╞6╟t)doif ''exit'')/0'              °
  44.   '╕(('':''εt)doif ''b╜evaldd (+/^\'''' ''''=t)╟t'')/L0'                       °
  45.   '''e╜ÉEM'' ÉEA t' '╕(0=µ,e)/L0' '╕b/L0'                                      °
  46.   '''This is not a valid APL2 expression''' 'æ╜''*'''                          °
  47. X '╕(''?''⌠╞1╟æ)/L0' 'e' '╕L0'                                                 °
  48.  CLIST 2 3 31 ONE                            TWO                               °
  49. X    THREE                                                                     °
  50. XCONE 1 16 CHARACTER STRING                                                    °
  51. XNRC 0 0                                                                       °
  52. *(1995 4 23 14 14 6 304)                                                       °
  53.  FSVOFFER ÉFX 'DC╜PID SVOFFER SV' 'SV╜(²2╞1 1,µSV)µSV╜πSV'                     °
  54.   '╕(2=ÉNC ''PID'')/DYADIC' 'DC╜ÉSVO SV ╪ ╕0'                                  °
  55.   'DYADIC:╕(1^.⌠DC╜PID ÉSVO SV)/END' 'ÉSVE╜15'                                 °
  56.   'CHECK:╕(1^.⌠DC╜ÉSVO SV)/END' '╕(0⌠ÉSVE)/CHECK'                              °
  57. X 'END:SV╜1 0 1 0 ÉSVC SV'                                                     °
  58. *(1995 9 25 14 7 42 448)                                                       °
  59.  FSVOPAIR ÉFX '≈_DC╜≈_PID SVOPAIR ≈_SV;≈_CV'                                   °
  60.   '≈_SV╜(²2╞1 1,µ≈_SV)µ≈_SV╜π≈_SV' '╕(2=ÉNC ''≈_PID'')/≈_DYADIC'               °
  61.   '≈_DC╜ÉSVO ≈_SV' '╕0' '≈_DYADIC:' '≈_CV╜(-+/^\Φ≈_SV='' '')Φ≈_SV'             °
  62.   '≈_CV╜(-+/^\Φ≈_CV⌠'' '')Φ≈_CV' '≈_CV╜≈_CV[;ÉIO]=''C'''                       °
  63.   '╕(1^.⌠≈_CV/≈_DC╜≈_PID ÉSVO ≈_SV)/≈_END' 'ÉSVE╜15' '≈_CHECK:'                °
  64.   '╕(1^.⌠≈_CV/≈_DC╜ÉSVO ≈_SV)/≈_END' '╕(0⌠ÉSVE)/≈_CHECK' '≈_END:'              °
  65. X '≈_CV╜1 0 1 0 ÉSVC ≈_CV≡≈_SV'                                                °
  66. *(1996 5 30 14 16 50 524)                                                      °
  67.  FTEACH ÉFX 'TEACH;B' 'Σ Copyright Z V Jizba 1991; all rights reserved'        °
  68.   'copyright' 'initialize' 'TEACH1  Σ Dealing with (external) files'           °
  69.   '''There are two AP''''s that deal with files. AP210 allows you to'''        °
  70.   '''process any file that you can access. Learning how to use this'''         °
  71.   '''AP is somewhat involved.'',r'                                             °
  72.   '''AP211 is designed to store and retrieve named APL2 objects. The'''        °
  73.   '''use of this AP is easy to learn. If you wish to skip the portion'''       °
  74.   'B╜3⌠''yY''∞╞get ''dealing with AP210, enter Yes here: ''' 'do'              °
  75.   '╕B/L1' 'TEACH2  Σ Auxilliary Processo 210 -- External files'                °
  76.   'TEACH3  Σ AP210 Control variable' 'TEACH4  Σ AP210 Command mode'            °
  77.   'TEACH5  Σ Sample file TEST210' 'TEACH6  Σ AP210 Control Subcommands'        °
  78.   'TEACH7  Σ AP210 Control Subcommands (continued)'                            °
  79.   'TEACH8  Σ AP210 Return Codes'                                               °
  80.   'L1:TEACH9  Σ AP211 Storing and retrieving APL2 objects'                     °
  81.   'TEACH10 Σ Reading and accessing AP211 data'                                 °
  82. X 'TEACH11 Σ Final comments on AP211'                                          °
  83. *(1996 6 3 14 27 41 428)                                                       °
  84.  FTEACH1 ÉFX 'TEACH1' 'Σ File auxilliary processor (AP210)'                    °
  85.   '''In the previous lesson we described a simple Auxilliary Processor,        °
  86.  the'''                                                                        °
  87.   '''AP100. It''''s purpose is to be able to enter OS2/DOS commands from       °
  88.   within'''                                                                    °
  89.   '''APL2. We also studied AP101, the Stack Processor. Using AP 101 we c       °
  90.  an'''                                                                         °
  91.   '''issue System Commands from within APL2. In this lesson we will'''         °
  92.   '''describe Auxilliary Processors 210 and 211. These processors provid       °
  93.  e''' '''the tools for communicating with the OS@ (DOS) file system.'''        °
  94.   'do'                                                                         °
  95.   '''When dealing with files, one has to be able to specify one of sever       °
  96.  al''' '''functions:'',r' '''    a. define a new file'''                       °
  97.   '''    b. write a record into the file'''                                    °
  98.   '''    c. read a record from a file'''                                       °
  99.   '''    d. remove a record from a file''' '''    e. rename a file'''          °
  100.   '''    f. erase a file'',r'                                                  °
  101.   '''The information about what specific function is to be performed is'       °
  102.  ''                                                                            °
  103.   '''not always sufficient. To deal with items b. c. and d., it is also'       °
  104.  ''                                                                            °
  105.   '''necessary to specify a location for data to be stored or retrieved.       °
  106.  '',r'                                                                         °
  107.   '''If we think of the process of dealing with external files as if it'       °
  108.  ''                                                                            °
  109.   '''were a function, then it would be an ambivalent one. The right'''         °
  110.   '''argument would contain the file process to be implemented, and the'       °
  111.  ''                                                                            °
  112.   '''left optional argument would specify the data to be stored, or the'       °
  113.  ''                                                                            °
  114.   '''name of a variable to contain the data to be retrieved. The functio       °
  115.  n'''                                                                          °
  116.   '''would return a code giving the success or failure of the operation.       °
  117. X''' 'end'                                                                     °
  118. *(1996 4 23 13 23 59 552)                                                      °
  119.  FTEACH10 ÉFX 'TEACH10;D211;T' 'Σ Reading and accessing AP211 data'            °
  120.   'T╜211 SVOFFER ''D211''' 'D211╜''DROP'' ''FUNCTION'''                        °
  121.   'D211╜''CREATE'' ''FUNCTION'' ╪ T╜D211'                                      °
  122.   '''Before data can be entered to (or read from) the file, it has to be       °
  123.  ''' '''opened with the USE command'',r'                                       °
  124.   'show ''D211╜''''USE'''' ''''FUNCTION'''''' ''D211'''                        °
  125.   '''Note that in addition to the Return Code, we also get a second'''         °
  126.   '''element, namely the record length assigned to the file.'',r'              °
  127.   '''Once a 211 type file has been opened, there are four types of'''          °
  128.   '''operations that make sense. These are'',r'                                °
  129.   '''    GET  get an APL2 object from the file'''                              °
  130.   '''    SET  place an APL2 object into the file'''                            °
  131.   '''  ERASE  erase an APL2 object from the file'''                            °
  132.   '''   LIST  list the names of APL2 objects in the file'',r' 'do'             °
  133.   '''The SET command is of the form'',r'                                       °
  134.   '''    D211╜''''SET'''' ''''name'''' APL2-object'',r'                        °
  135.   '''Note that the third element must be a scalar element of the three''       °
  136.  '                                                                             °
  137.   '''element vector. That means that normally, the APL2 object must be''       °
  138.  ' '''enclosed.'',r'                                                           °
  139.   '''The following example shows a valid entry because the right argumen       °
  140.  t is''' '''a valid three element nested vector'',r'                           °
  141.   'show ''D211╜''''SET'''' ''''ONE'''' ''''TEST DATA'''''' ''D211'''           °
  142.   '''Again, the return code of 0 means that the SET process was successf       °
  143.  ul.''' 'do'                                                                   °
  144.   '''In the next example we wish to store an array containing the canoni       °
  145.  cal'''                                                                        °
  146.   '''representation of function "date". This array must be enclosed so t       °
  147.  hat the'''                                                                    °
  148.   '''argument to be assigned to D211 is a three element vector.'',r'           °
  149.   'show ''D211╜''''SET'''' ''''TWO'''',ΓÉCR ''''date'''''' ''D211'''           °
  150.   '''Here is another APL2 data type to be stored'',r'                          °
  151.   'show ''D211╜''''SET'''' ''''THREE'''',Γ3 3µ∞9'' ''D211'''                   °
  152.   '''We have now stored three APL2 objects, namely ONE, TWO, and THREE.'       °
  153.  ''                                                                            °
  154.   '''Suppose we find that object ONE is no longer valid, and we wish to'       °
  155.  ''                                                                            °
  156.   '''replace it by another object, say the string ''''ANOTHER TEST VECTO       °
  157.  R''''''' '''This can be done simply by entering'',r'                          °
  158.   'show ''D211╜''''SET'''' ''''ONE'''' ''''ANOTHER TEST VECTOR'''''' ''D       °
  159.  211'''                                                                        °
  160.   '''To retrieve an APL2 object previously stored, we use command GET'',       °
  161.  r'                                                                            °
  162.   'show ''D211╜''''GET'''' ''''THREE'''''' ''THREE╜2πÉ╜D211'' ''DISPLAY        °
  163.  THREE'''                                                                      °
  164.   '''Since D211 can be referenced only once, it is a good idea to assign       °
  165.  '''                                                                           °
  166.   '''it immediately to a normal APL2 variable. Note also that the conten       °
  167.  ts'''                                                                         °
  168.   '''of D211 is a two element vector. The first element of that vector i       °
  169.  s'''                                                                          °
  170.   '''the Return Code, and the second element is the APL2 object that has       °
  171.  ''' '''been retrieved.''' 'do'                                                °
  172.   '''To see what named objects reside in the file, we use command LIST''       °
  173.  ,r' 'show ''D211╜''''LIST'''' ''''NAMES'''''' ''DISPLAY LIST╜D211'''          °
  174.   '''It is also possible to obtain a table listing three numeric items''       °
  175.  ,r'                                                                           °
  176.   '''    The number of fixed length records needed to store the APL2 obj       °
  177.  ect''' '''    The user ID (default is 1001)'''                                °
  178.   '''    The time stamp of the last update of the APL2 object'',r'             °
  179.   'show ''D211╜''''LIST'''' ''''ATTS'''''' ''DISPLAY ATTS╜D211'''              °
  180.   '''Command LIST NAMES tells the contents of an AP211 file. What happen       °
  181.  s'''                                                                          °
  182.   '''when command GET is issued for an entry not on that list. Recall th       °
  183.  at''' '''for a valid entry, D211 contains a two element vector'',r'           °
  184.   'show ''D211╜''''GET'''' ''''ONE'''''' ''DISPLAY D211'''                     °
  185.   '''For an invalid entry, the result is numeric return code'',r'              °
  186.   'show ''D211╜''''GET'''' ''''FOUR'''''' ''DISPLAY D211'''                    °
  187.   '''When using the GET command it may be generally useful to take advan       °
  188.  tage''' '''of the multiple specification feature of APL2'',r'                 °
  189.   'show ''D211╜''''GET'''' ''''THREE'''''' ''(RC DAT)╜D211'' ''RC'' ''DI       °
  190.  SPLAY DAT'''                                                                  °
  191.   '''Finally, one may require the removal of specific objects from the''       °
  192.  ' '''file. The command ERASE will do that'',r'                                °
  193.   'show ''D211╜''''LIST'''' ''''NAMES'''''' ''D211'' ''D211╜''''ERASE'''       °
  194.  ' ''''ONE'''''''                                                              °
  195.   'show ''D211'' ''D211╜''''LIST'''' ''''NAMES'''''' ''D211'''                 °
  196.   '''Although Shared Variable 211 can be retracted with the ÉSVR Command       °
  197.  ,'''                                                                          °
  198.   '''one need not take that step. If more than one file is to be process       °
  199.  ed,'''                                                                        °
  200.   '''the command RELEASE has the effect of closing a file that has been'       °
  201.  '' '''previously opened with the USE command'',r'                             °
  202. X 'show ''D211╜''''RELEASE'''''' ''D211''' 'end'                               °
  203. *(1996 4 23 13 24 24 416)                                                      °
  204.  FTEACH11 ÉFX 'TEACH11' 'Σ Final comments on AP211'                            °
  205.   '''In summary, AP211 is APL-like, is simple to use, and provides a fas       °
  206.  t'''                                                                          °
  207.   '''and efficient way to store APL2 objects. As the limitations on the'       °
  208.  ''                                                                            °
  209.   '''size of APL2 workspaces are gradually removed, one may question the       °
  210.  '''                                                                           °
  211.   '''desirability of having a second level of storage for APL2 data. It        °
  212.  is'''                                                                         °
  213.   '''possible that for many if not most applications one can get along w       °
  214.  ith'''                                                                        °
  215.   '''a single workspace holding every APL2 object. Nevertheless there wi       °
  216.  ll'''                                                                         °
  217.   '''invariably arise situations where this strategy is not the best.'''       °
  218.   'do'                                                                         °
  219.   '''There are many such possible applications of AP211. Here are some o       °
  220.  f''' '''the more obvious ones:'',r'                                           °
  221.   '''    Seldom used APL2 utilities can be stored in file UTILITY'''           °
  222.   '''    Documentation or HELP files can be stored in file HELP'''             °
  223.   '''    Documentation can be placed in file BLUEPRINT'''                      °
  224.   '''    Seldom used subroutines of complex applications'''                    °
  225.   '''    Semantic nets or other AI structures'''                               °
  226.   '''    Data bases of all kinds requiring access by name'',r' 'do'            °
  227.   '''In a later lesson we will show some specific examples of the usage        °
  228.  of''' '''AP211.'''                                                            °
  229.   '''Before we leave this lesson, we should discard file FUNCTION'',r'         °
  230. X 'show ''D211╜''''DROP'''' ''''FUNCTION''''''' 'end'                          °
  231. *(1996 5 30 14 19 47 524)                                                      °
  232.  FTEACH2 ÉFX 'TEACH2;C210;D210;T' 'Σ Control and data variables'               °
  233.   '''AUXILLIARY PROCESSOR 210'',r'                                             °
  234.   '''In the previous lesson we invoked function SVOFFER to activate the'       °
  235.  ''                                                                            °
  236.   '''shared variable named in its right argument. For Auxilliary Process       °
  237.  or'''                                                                         °
  238.   '''210, one shared variable is insufficient to deal with the requireme       °
  239.  nts'''                                                                        °
  240.   '''associated with processing of external files. To deal with this, we       °
  241.  '''                                                                           °
  242.   '''will use the IBM supplied function SVOPAIR. At this point it might'       °
  243.  '' '''be useful to review the use of the ÉSVO System Function.''' 'do'        °
  244.   '''When the ÉSVO command is given, the right argument allows not one,        °
  245.  but'''                                                                        °
  246.   '''two or more names to be associated with a specific AP. If more than       °
  247.  '''                                                                           °
  248.   '''one such variable is needed, the names must in some way be similar,       °
  249.   so'''                                                                        °
  250.   '''that the AP will be able to recognize the existence of the close ti       °
  251.  es''' '''connecting these labels.'',r'                                        °
  252.   '''Typically one of the variables is used to control the process, and'       °
  253.  ''                                                                            °
  254.   '''another one is used to contain the data. Therefore, the first varia       °
  255.  ble'''                                                                        °
  256.   '''must begin with the letter C (for CONTROL). Not surprisingly, the''       °
  257.  '                                                                             °
  258.   '''second variable must begin with the letter D (for DATA). The remain       °
  259.  der'''                                                                        °
  260.   '''of the label is arbitrary (subject to APL2 naming conventions),'''        °
  261.   '''provided the subscript is identical for both.''' 'do'                     °
  262.   '''So if we name the control variable C210, then the data variable has       °
  263.   to''' '''have the name D210.'',r' 'T╜210 SVOPAIR ''C210'' ''D210'''          °
  264.   '''       210 ÉSVO■ ''''C210'''' ''''D210'''''',r,''1 1'''                   °
  265.   'show ''ÉSVO■ ''''C210'''' ''''D210'''''''                                   °
  266.   '''Just as in AP100 and AP101, the full COUPLING requires a second iss       °
  267.  ue'''                                                                         °
  268.   '''of ÉSVO. Note, however, that D210 (the varable associated with data       °
  269.  )'''                                                                          °
  270.   '''retains its coupling of one. Why? Because no data transfer is possi       °
  271. Xble''' '''until a suitable CONTROL command has been set.''' 'TEACH2A'         °
  272. *(1996 4 25 14 1 16 304)                                                       °
  273.  FTEACH2A ÉFX 'TEACH2A;T' 'Σ C210 and D210 as variables' '''''' 'do'           °
  274.   '''Although C210 and D210 are known to APL2 as "variables"'',r'              °
  275.   'show ''ÉNC■ ''''C210'''' ''''D210'''''''                                    °
  276.   '''at this point they are still undefined. Any reference to them will'       °
  277.  '' '''return a VALUE ERROR.'',r' 'T╜0 0 0 0 ÉSVC ''C210'''                    °
  278.   '''(if your screen FREEZES at the next example, do an INTERRUPT, becau       °
  279.  se''' '''your Shared Variable Control has been set to 1.)'''                  °
  280.   '0 show ''C210'''                                                            °
  281.   '''In general, shared variables MUST be assigned (or referenced) in a'       °
  282.  ''                                                                            °
  283.   '''specific sequence. Before we can discuss that sequence, it will be'       °
  284.  '' '''useful to discuss the scope of Auxilliary Processor 210.''' 'do'        °
  285.   '''However, before we get into details on the use of AP210, you may'''       °
  286.   '''wish to study function SVOPAIR. If you do, enter YES at the next'''       °
  287.   '''prompt.'''                                                                °
  288.   '╕(~(╞ans ''Do you wish to study function SVOPAIR?'')ε''Yy'')/0'             °
  289.   '''Function "svopair" is a copy of function SVOPAIR, where all comment       °
  290.  s'''                                                                          °
  291.   '''have been removed and the prefix "≈_" --which is used to reduce the       °
  292.  ''' '''chance of name conflicts-- has also been removed.)''' 'do'             °
  293.   '0 0 1 2 3 4 showfn ''svopair'''                                             °
  294.   '''Just as in SVOFFER, the function is ambivalent. If the left argumen       °
  295.  t'''                                                                          °
  296.   '''(PID) is missing, the branch to DYADIC on line [2] fails, and lines       °
  297.  '''                                                                           °
  298.   '''[3-4] are evaluated. Line [1] converts the right argument to an'''        °
  299.   '''array with at least one row and one column. Line [3] returns the'''       °
  300.   '''degree of coupling of the right arguments.''' 'do'                        °
  301.   '0 5 6 7 8 9 showfn ''svopair'''                                             °
  302.   '''The objective of lines [6-8] is to identify the row of SV that'''         °
  303.   '''contains the name of the control variable. Line [6] shifts the'''         °
  304.   '''rows of SV to the right so that there are no trailing blanks.'''          °
  305.   '''Line [7] shifts the first letter of the last word on each line'''         °
  306.   '''to the first row. (The function allows for the presence of'''             °
  307.   '''"surrogates" in front of the shared variable names.) Line [8] final       °
  308.  ly''' '''identifies the row containing a "C" in the first column.'''          °
  309.   'do'                                                                         °
  310.   '''A first invocation of ÉSVO on the array SV should return the vector       °
  311.  '''                                                                           °
  312.   '''1 1 on line [9]. If it does not, a branch to END (line [14]) ends''       °
  313.  ' '''the function.''' '0 10 11 12 13 showfn ''svopair'''                      °
  314.   '''Line [10] starts the EVENT clock. Line [12] tests for a change in''       °
  315.  '                                                                             °
  316.   '''the value of vector CV. A change causes exit to line [14]. Line [15       °
  317.  ]''' '''loops to line [11] until the event clock runs out.''' 'do'            °
  318.   '0 14 15 showfn ''svopair'''                                                 °
  319.   '''Lines [14-15] end by seting the control shared variable.'',r'             °
  320. X '''NOW BACK TO THE SCOPE OF AP 210''' 'end'                                  °
  321. *(1996 4 14 12 10 16 288)                                                      °
  322.  FTEACH3 ÉFX 'TEACH3' 'Σ Control variable' '''THE CONTROL VARIABLE'',r'        °
  323.   '''Now that both variables are active we can proceed with issuing'''         °
  324.   '''commands to process DOS files. When dealing with files, we must'''        °
  325.   '''recognize that there are three types of information that are needed       °
  326.  :'',r'                                                                        °
  327.   '''    A. The name (including the path name) of the file to be process       °
  328.  ed'''                                                                         °
  329.   '''    B. The type of operation to be performed (read, write, delete)'       °
  330.  '' '''    C. The specific record to be processed''' 'do'                      °
  331.   '''In addition, in general, there are different types of files. For'''       °
  332.   '''example, there are files that'',r'                                        °
  333.   '''   a. can be read only, or can be read and writen into'''                 °
  334.   '''   b. fixed length files, or variable length files'''                     °
  335.   '''   c. direct access files or sequential files'''                          °
  336.   '''   d. ASCII files, Character files, boolean, and APL2 data files'',       °
  337.  r'                                                                            °
  338.   '''To handle this great diversity, the AP210 control variable operates       °
  339.  ''' '''in two modes: COMMAND mode, and SUBCOMMAND mode.''' 'do'               °
  340.   '''The command mode must be issued first. It specifies the general nat       °
  341.  ure'''                                                                        °
  342.   '''of the operation, the file name, and the type of data to be process       °
  343.  ed.'''                                                                        °
  344.   '''The subcommand mode specifies the type of file, whether the operati       °
  345.  on'''                                                                         °
  346.   '''is to be read or write, and the record number and possibly the'''         °
  347. X '''starting position of the read process.''' 'end'                           °
  348. *(1996 4 14 12 10 27 332)                                                      °
  349.  FTEACH4 ÉFX 'TEACH4' 'Σ Command mode of control variable'                     °
  350.   '''COMMAND MODE'',r'                                                         °
  351.   '''In the command mode, the right argument is a character string.'''         °
  352.   '''It has the following format:'',r'                                         °
  353.   '''      command,filespec[,code]'',r' 'do'                                   °
  354.   '''The command is a two letter abbreviation giving the type of action'       °
  355.  '' '''that is to be performed:'',r'                                           °
  356.   '''        IR  open file for reading only'''                                 °
  357.   '''        IW  open file for read or/and write'''                            °
  358.   '''        DL  delete file''' '''        RN  rename file'',r' 'do'           °
  359.   '''The command is followed by a comma, and then by a file specificatio       °
  360.  n'',r'                                                                        °
  361.   '''A third argument, the file code, is optional. It specifies the natu       °
  362.  re'''                                                                         °
  363.   '''of the data type. Four data types are supported by AP210:'',r'            °
  364.   '''      A  APL2 objects (This is the default)'''                            °
  365.   '''      B  Bit strings packed 8 bits per byte without headers'''            °
  366.   '''      C  Character strings in APL2 internal (ASCII) code'''               °
  367.   '''      D  ASCII strings of characters'',r'                                 °
  368.   '''Codes B and C require the file records to be of fixed length. Code'       °
  369.  '' '''D may be used with variable record lengths, as can code A.'''           °
  370.   'do'                                                                         °
  371.   '''There is one more code, T for "Translate". This indicates that the'       °
  372.  ''                                                                            °
  373.   '''record is a string of characters, without any header, to be transla       °
  374. Xted''' '''according to the AP 210 translate table.''' 'end'                   °
  375. *(1996 4 14 12 10 44 400)                                                      °
  376.  FTEACH5 ÉFX 'TEACH5;T' 'Σ Subcommand mode'                                    °
  377.   'T╜210 SVOPAIR ''C210'' ''D210'''                                            °
  378.   '''As an example, let us assume we wish to store some APL2 arrays in''       °
  379.  '                                                                             °
  380.   '''a file. The file is to be called "TEST210", and is to be placed in'       °
  381.  '' '''the current directory (which is the default).'',r'                      °
  382.   'show ''C210╜''''IW,TEST210'''''''                                           °
  383.   '''Note that we did not use the file code, since APL2 type file is the       °
  384.  ''' '''default.''' 'do'                                                       °
  385.   '''At this point we do not know whether our command was succesfully'''       °
  386.   '''completed. However, since variable C210 has been assigned a value''       °
  387.  ' '''(the character string IW,TEST210), it can be referenced.'''              °
  388.   '''It''''s contents is not the character string, but a numeric integer       °
  389.  '''                                                                           °
  390.   '''value that identifies the "completion code". We can find out what''       °
  391.  ' '''this code is, merely by referencing C210'',r' 'show ''C210'''            °
  392.   '''A code of 0 means that the control command has successfully opened'       °
  393.  '' '''file TEST210.'',r'                                                      °
  394.   '''We may at this point wish to determine if a file by that name alrea       °
  395.  dy'''                                                                         °
  396.   '''exists. To do that, we merely would read a record from the file. We       °
  397.  '''                                                                           °
  398.   '''could also just write a new record into the file. In either case, w       °
  399. Xe''' '''must issue a CONTROL SUBCOMMAND.''' 'end'                             °
  400. *(1996 4 14 12 11 10 268)                                                      °
  401.  FTEACH6 ÉFX 'TEACH6' 'Σ Control subcommands'                                  °
  402.   '''CONTROL SUBCOMMANDS'',r'                                                  °
  403.   '''Whenever the Control Command is IR or IW, it must be followed by on       °
  404.  e''' '''or more subcommands. These are of the form'',r'                       °
  405.   '''        C210╜operation [,record number [,scan distance]]'',r'             °
  406.   '''  or using IBM abbreviations: C210╜op[,rn[,rs]]'',r'                      °
  407.   '''Unlike the control command, this assignment is numeric, and the val       °
  408.  ues'''                                                                        °
  409.   '''are positive integers. Here is a listing of available "operation"''       °
  410.  ' '''codes:'',r' '''    OP   MEANING                     DEFAULTS'''          °
  411.   '''     0   Read fixed length record    rn╜0 rs╜128 sequential read'''       °
  412.   '''     1   Write fixed length record   rn╜0 rs╜128 sequential write''       °
  413.  ' '''     2   Read direct record          rn╜starting byte rs╜128'''          °
  414.   '''     3   Write direct record         rn╜starting byte rs╜128'''           °
  415.   '''     4   Read variable length record (Depends on codes A or D)'''         °
  416.   '''     5   Write variable length record    "     "    "    "'',r'           °
  417.   'do'                                                                         °
  418.   '''Let us assume that we have two APL2 variables we wish to store'''         °
  419.   '''in file TEST210:'',r'                                                     °
  420.   'show ''ONE╜''''CHARACTER STRING'''''' ''TWO╜∞20'''                          °
  421.   '''Each step requires the following sequence:'',r'                           °
  422.   'show ''D210╜ONE'' ''C210╜5'' ''C210'' ''D210╜TWO'' ''C210╜5'' ''C210'       °
  423. X'' 'end'                                                                      °
  424. *(1996 4 14 12 11 22 316)                                                      °
  425.  FTEACH7 ÉFX 'TEACH7' 'Σ Control subcommand continued'                         °
  426.   '''Notice that each assignment to D210 must be followed by two control       °
  427.  '''                                                                           °
  428.   '''subcommands, one to specify the nature of the operation, and one to       °
  429.  ''' '''test the Return Code.''' 'do'                                          °
  430.   '''At this point we can continue by verifying whether the information'       °
  431.  ''                                                                            °
  432.   '''been stored properly. Note that record numbers are in 0 index origi       °
  433.  n.'',r'                                                                       °
  434.   'show ''C210╜4 0'' ''C210'' ''D210'' ''C210╜4 1'' ''C210'' ''D210'''         °
  435.   '''When reading a file, each reference to D210 must be preceeded by tw       °
  436.  o'''                                                                          °
  437.   '''control commands; one to specify the nature of the read operation,        °
  438.  and''' '''one to test the Return Code.'',r'                                   °
  439.   '''When a file is no longer to be used, it has to be closed. This is''       °
  440.  '                                                                             °
  441.   '''done simply by assigning a null string to the control variable'',r'       °
  442.   'show ''C210╜'''''''''''                                                     °
  443.   '''Once a a file has been closed, it is permissible to issue another''       °
  444.  ' '''Control Command'',r'                                                     °
  445.   'show ''C210╜''''IR,C:\APL2\testXXX'''''' ''C210'''                          °
  446.   '''The Return Code 2 means that the named file does not exist. Had the       °
  447.  '''                                                                           °
  448.   '''Control Command started with IW, instead with IR, a new file named'       °
  449. X'' '''''''testXXX'''' would have been defined.''' 'end'                       °
  450. *(1996 4 14 11 55 55 620)                                                      °
  451.  FTEACH8 ÉFX 'TEACH8' 'Σ Return Codes' '''RETURN CODES'',r'                    °
  452.   '''You are encouraged to practice different combinations of Control'''       °
  453.   '''Commands and Subcommands. As you do, you will invariably get any on       °
  454.  e'''                                                                          °
  455.   '''of several non-zero Return Codes. You can find the meanings of thes       °
  456.  e''' '''on page 216 of your APL2 USER''''S GUIDE.'',r'                        °
  457.   '''Once you become familiar with the usage of AP210, you may wish to''       °
  458.  '                                                                             °
  459.   '''define your own functions to read and write specific file applicati       °
  460.  ons.''' 'do'                                                                  °
  461.   '''IBM supplies two workspaces named APLFILE and FILE. These invoke th       °
  462.  e'''                                                                          °
  463.   '''AP210 and support functions to OPEN, CLOSE, READ and WRITE records.       °
  464.  '''                                                                           °
  465.   '''It is entirely possible that these workspaces will satisfy many of'       °
  466.  ''                                                                            °
  467.   '''your requirements. In any case, you can use these workspaces (or'''       °
  468.   '''functions within) as a basis for your own applications.'',r'              °
  469.   '''Before we leave AP210, we should delete file TEST210. This can be''       °
  470.  ' '''done with Control Command'',r'                                           °
  471.   'show ''C210╜''''DL,TEST210'''''' ''C210'''                                  °
  472.   '''and let us not forget to release the Shared Variable'',r'                 °
  473. X 'show ''ÉSVR■ ''''C210'''' ''''D210''''''' 'TEACH8A'                         °
  474. *(1996 4 14 12 11 53 440)                                                      °
  475.  FTEACH8A ÉFX 'TEACH8A;D;CMD' 'Σ Read the ASCII file APL2.CMD'                 °
  476.   '''You do not need to define your APL2 functions to access non-APL'''        °
  477.   '''external files. IBM supplies workspace FILE in library 2, that'''         °
  478.   '''contains just about any functionality that you are likely to need.'       °
  479.  '' '''The workspace 2 FILES contains four groups of functions:'',r'           °
  480.   '''  AP 210 group''' '''  AP 211 group''' '''  Delta group'''                °
  481.   '''  Transfer group''' 'do'                                                  °
  482.   '''The AP 210 group contains functions that allow you to open, close a       °
  483.  '''                                                                           °
  484.   '''file, to read or write bytes or records, find file size, to compare       °
  485.  '''                                                                           °
  486.   '''two files, to display the contents of a file, to delete a file, and       °
  487.  ''' '''to rename a file.'',r'                                                 °
  488.   '''The AP 211 group deals with functions useful with AP 211, which wil       °
  489.  l''' '''be discussed later.'',r'                                              °
  490.   '''Right now it is the "Delta Group" that is of interest''' 'do'             °
  491.   '''This group contains only two functions: ╢FM and ╢FV. Both functions       °
  492.  '''                                                                           °
  493.   '''are ambivalent. If the left argument is absent, these functions wil       °
  494.  l'''                                                                          °
  495.   '''read the contents of a file (specified in the right argument). If t       °
  496.  he'''                                                                         °
  497.   '''left argument is present, it must be a rank 2 character array. This       °
  498.  '''                                                                           °
  499.   '''array will be written to the file specified in the right argument.'       °
  500.  '' 'do'                                                                       °
  501.   '''As an example, consider loading into this workspace the APL2.CMD fi       °
  502.  le'''                                                                         °
  503.   '''listed on page 11 of the User''''s Guide. Your APL2OS2 may not resi       °
  504.  de'''                                                                         °
  505.   '''on drive C. Therefore, before proceeding with this exercise, you mu       °
  506.  st''' '''specify this drive:'',r'                                             °
  507.   'D╜╞(1 get ''    ATTENTION! Enter the APL2OS2 drive (default is C:)'')       °
  508.  ,''C'''                                                                       °
  509.   '''On the assumption that this file has the following address:'',r'          °
  510.   'D,'':\APL2OS2\BIN\APL2.CMD'',r'                                             °
  511.   '''its contents can be read into variable CMD'',r'                           °
  512.   'show ''CMD╜╢FM D,'''':\APL2OS2\BIN\APL2.CMD'''''' ''µCMD'' ''DISPLAY        °
  513.  CMD'''                                                                        °
  514.   '''Function ╢FM retrieved this file as a rank 2 character array.'''          °
  515.   '''Function ╢FV will retrieve the same data as a nested vector of'''         °
  516.   '''individual records from that file'',r'                                    °
  517.   'show ''CMD╜╢FV D,'''':\APL2OS2\BIN\APL2.CMD'''''' ''µ■CMD'' ''DISPLAY       °
  518.   2╞CMD''' 'do'                                                                °
  519.   '''NOTE: If you merely desire to edit an ASCII text file, you may do s       °
  520.  o''' '''using the ")HOST" command. Enter'',r'                                 °
  521.   '''     )HOST apledit filename'',r'                                          °
  522.   '''(replace the word "filename" by the address of the file to be edite       °
  523. Xd)''' 'end'                                                                   °
  524. *(1996 4 14 12 12 13 284)                                                      °
  525.  FTEACH9 ÉFX 'TEACH9;D211' 'Σ Auxilliary processor 211'                        °
  526.   '''AUXILLIARY PROCESSOR 211'',r'                                             °
  527.   '''There are several features of AP210 that are inconvenient for certa       °
  528.  in'''                                                                         °
  529.   '''APL2 applications. For one, it may be necessary to know the content       °
  530.  s'''                                                                          °
  531.   '''of a file by record numbers. In APL, we are used to accessing data        °
  532.  by'''                                                                         °
  533.   '''name. With AP210, one has to know the file characteristics, while''       °
  534.  '                                                                             °
  535.   '''in APL we are used to let the system do such book-keeping. For thos       °
  536.  e'''                                                                          °
  537.   '''of us who prefer to deal with files as if these were merely extensi       °
  538.  ons''' '''of APL, there is AP211.''' 'do'                                     °
  539.   '''Auxilliary Processor 211 supports ONLY one Shared Variable.'',r'          °
  540.   'show ''211 SVOFFER ''''D211''''''' 'D211╜''DROP'' ''FUNCTION'''             °
  541.   '''We can create a file, say FUNCTION with the following command'',r'        °
  542.   'show ''D211╜''''CREATE'''' ''''FUNCTION'''''' ''D211'''                     °
  543.   '''Referencing D211 after making an assignment to it is ALWAYS a good'       °
  544.  ''                                                                            °
  545.   '''idea. The Return Codes can be found on p 220 of the USER''''S MANUA       °
  546.  L.''' 'do'                                                                    °
  547.   '''If you were to repeat this command, the return code would be a ²17'       °
  548.  ''                                                                            °
  549.   '''indicating that the file is already in use. The file created by'''        °
  550.   '''CREATE will have fixed lenth records of 1024 bytes. (This can be'''       °
  551.   '''changed by inserting an alternate value as a third element of the''       °
  552.  ' '''CREATE assignment.)'',r'                                                 °
  553. X '''     D211╜''''CREATE'''' filename record-size'',r' 'end'                  °
  554. XNTHREE 2 3 3 1 2 3 4 5 6 7 8 9                                                °
  555. XATWO╜1-ÉIO-∞20                                                                °
  556. XCa 0 %                                                                        °
  557. *(1991 11 11 8 26 35 408)                                                      °
  558.  Faddquote ÉFX 'u╜addquote w'                                                  °
  559.   'Σ Put quotes around a string, and double existing quotes'                   °
  560. X 'u╜ÉAV[40],((1+w=ÉAV[40])/w),ÉAV[40]'                                        °
  561. *(1992 5 6 8 49 44 496)                                                        °
  562.  Fans ÉFX 'U╜V ans W;A;R;T' 'Σ Respond to an inquiry'                          °
  563.   'T╜(0=ÉNC ''V'')doif ''V╜'''' ''''''' '╕(0⌠1╞0╞εV)/L0' '''      '',W'        °
  564.   'U╜É' '╕(0╧V)/0' 'U╜VµU' '╕0' 'L0:T╜(1<╧V)doif ''R╜1╟V'' ''V╜╞V'''           °
  565.   'æ╜A╜''      '',W,V' 'U╜(µA)╟æ' '╕(~T)/0'                                    °
  566. X '╕((0=╞0╞R)doif ''U╜RµU,'''' '''''')/0' 'U╜π(U⌠R)ΓU'                         °
  567. *(1991 11 11 8 26 35 408)                                                      °
  568. XFaq ÉFX 'u╜aq w' 'Σ Enclose quoted string' 'u╜Γaddquote w'                    °
  569. *(1991 11 11 8 26 35 408)                                                      °
  570.  Fav ÉFX 'av;a;n;i;ÉIO' 'Σ Display characters in the Atomic vector'            °
  571.   'ÉIO╜0' 'a╜22 78µ'' ''' 'n╜3 0«φ12 22µ1+∞256'                                °
  572.   'a[;,(6⌡∞12)°.+2 3 4]╜n' 'a[;6+6⌡∞12]╜φ12 22µÉAV'                            °
  573. X 'a[7 8 10 13;6]╜'' ''' 'a[14+∞8;68 69 70 72]╜'' ''' 'a'                      °
  574. *(1996 4 7 14 15 40 384)                                                       °
  575.  Fcopyright ÉFX 'copyright' 'Σ Copyright statement'                            °
  576.   '(10µ'' ''),''Copyright, Z. V. Jizba, 1995'',r'                              °
  577.   '''To see disclaimers, enter ÉCR ''''copyright''''''' 'do' '╕0'              °
  578.   '''This and subsequent workspaces labelled TEACHxx are made available'       °
  579.  ''                                                                            °
  580.   '''at no cost to anyone who desires to learn how to use effectively'''       °
  581.   '''the IBM/OS2 version of APL2.'',r'                                         °
  582.   '''This software is provided "AS IS" with no WARRANTY of any kind, eit       °
  583.  her'''                                                                        °
  584.   '''express or implied. Any risk in its use resides with you, the user        °
  585. Xof''' '''these tutorials.''' '''(PRESS ENTER to continue)'''                  °
  586. XCd 0 "                                                                        °
  587. *(1991 11 11 8 26 37 416)                                                      °
  588.  Fdate ÉFX 'u╜date w' 'Σ Format date and time of day' 'u╜«6╞w'                 °
  589. X 'u╜('' ''⌠u)Γu' 'u╜εu,■''-- .. '''                                           °
  590. XCdig 1 10 1234567890                                                          °
  591. *(1991 11 11 8 26 34 404)                                                      °
  592.  Fdo ÉFX 'do;t;e;b' 'Σ Expression driver' 'e╜''''' 'æ╜''       ''' 't╜æ'       °
  593.   '╕(^/'' ''=t)/0'                                                             °
  594.   '╕(('':''εt)doif ''b╜evaldd (+/^\'''' ''''=t)╟t'')/2'                        °
  595.   '''e╜ÉEM'' ÉEA t' '╕(0=µ,e)/2'                                               °
  596.   '''This is not a valid APL2 expression''' 'æ╜''*''' '╕(''?''⌠╞1╟æ)/2'        °
  597. X 'e' '╕2'                                                                     °
  598. *(1991 11 11 8 26 34 404)                                                      °
  599.  Fdoif ÉFX 'U╢╜V╢ doif W╢;t╢' 'Σ Rule' '╕(^/~U╢╜V╢)/0'                         °
  600. X '''U╢╜V╢ doif■ W╢'' ÉEA ''»V╢/W╢'''                                          °
  601. XNdos 0 ²26                                                                    °
  602. XCe 1 0                                                                        °
  603. *(1996 3 31 14 34 39 548)                                                      °
  604.  Fend ÉFX 'end' '''²²''' 'e╜''''' 'æ╜''       ''' 't╜æ' '╕(^/'' ''=t)/0'       °
  605.   '╕(('':''εt)doif ''b╜evaldd (+/^\'''' ''''=t)╟t'')/3'                        °
  606.   '''e╜ÉEM'' ÉEA t' '╕(0=µ,e)/0'                                               °
  607.   '''This is not a valid APL2 expression''' 'æ╜''*''' '╕(''?''⌠╞1╟æ)/0'        °
  608. X 'e'                                                                          °
  609. *(1991 11 11 8 26 35 408)                                                      °
  610. XFendd ÉFX 'endd' 'Σ End of document' '20µ''²''' 'do'                          °
  611. *(1995 10 8 13 54 41 564)                                                      °
  612.  Ferase ÉFX 'erase;t;DISPLAY;OS2;GO;PROFILE;SVOFFER;SVOPAIR;╢FM;╢FV'           °
  613.   't╜ÉNL 3' 't╜(~t^.εlc,'' '')≡t' 't╜ÉEX(~t[;∞5]^.=''TEACH'')≡t'               °
  614. X 't╜ÉNL 2' 't╜ÉEX(~t^.εlc,'' '')≡t' 't╜ÉNL 4' 't╜ÉEX(~t^.εlc,'' '')≡t'        °
  615. *(1991 11 11 8 26 36 412)                                                      °
  616.  Fevaldd ÉFX 'u╜evaldd w;c;n'                                                  °
  617.   'Σ Evaluate a direct definition expression' 'u╜0' 'n╜(w∞''Σ'')-1'            °
  618.   'c╜(((n╞w)⌠'':'')Γn╞w),Γ''ΣDD '',(n+1)╟w' '╕(label╞c)/0'                     °
  619.   '╕((2=µc)doif ''u╜showdd 1╙c'')/0'                                           °
  620.   '╕((3=ÉNC╞c)doif ''u╜⌡µÉ╜(╞c),'''' is already defined.'''''')/0'             °
  621.   '╕((3=µc)doif ''u╜simdd c'')/0' 'c╜(Γ''α∙ aw'')replace■c'                    °
  622.   'u╜ε''u╜'',((''a''εεc[2 3 4])/''a ''),(╞c),'' w;t;b'''                       °
  623.   'u╜u(5πc)(''b╜(t╜'',(3πc),'')/'',addquote ''u╜'',4πc)'                       °
  624. X 'u╜u,''╕(t doif b)/0''(''u╜'',2πc)' 'u╜╧ÉFX u'                               °
  625. *(1991 11 11 8 26 36 412)                                                      °
  626.  Fexit ÉFX 'exit w' 'Σ Exit if there are too many suspended functions'         °
  627. X '╕((10>µÉLC)doif ''w'')/0' '''Please re-enter '',w' '╕'                      °
  628. XCf 1 2  {                                                                     °
  629. XCg 1 2  }                                                                     °
  630. *(1996 4 18 14 22 21 380)                                                      °
  631.  Fget ÉFX 'u╜v get w;t' 'Σ Prompt for response from keyboard'                  °
  632.   't╜(0=ÉNC ''v'')doif ''v╜1''' 'w╜w,(~²1╞v)/'': ''' 'L0:æ╜w' 't╜æ'            °
  633.   '╕((''╕''=(µw)╟t)doif ''╕'')/0' '╕(^/'' ''=w)/L1'                            °
  634.   'Σ ╕((~w╧(µw)╞t)doif ''''''PLEASE DO NOT BACKSPACE'''''')/L0'                °
  635.   't╜(µw)╟t' 'L1:u╜(²1+(,'' ''⌠t)∞1)╟t' '╕(1╞v)/0' 't╜(u⌠'' '')Γu'             °
  636. X 'u╜(µt),(Γu),t'                                                              °
  637. *(1991 11 11 8 26 36 412)                                                      °
  638.  Fglobals ÉFX 'globals' 'Σ Initialize useful global variables' 'r╜2╙ÉTC'       °
  639.   'q╜40╙ÉAV' 's╜Φp╜'' '',d╜35╙ÉAV' 'uc╜''ABCDEFGHIJKLMNOPQRSTUVWXYZ'''         °
  640.   'lc╜''abcdefghijklmnopqrstuvwxyz''' 'dig╜''1234567890'''                     °
  641. X 'g╜'' '',h╜126╙ÉAV' 'f╜ÉAV[33 124]' 'a╜38╙ÉAV'                               °
  642. XCh 0 }                                                                        °
  643. *(1996 4 9 13 38 53 532)                                                       °
  644.  Fhelp ÉFX 'help'                                                              °
  645.   '''If you feel that a single linear reading of these lessons is not th       °
  646.  e'''                                                                          °
  647.   '''best way to learn about APL2OS2, you may try to do the following.''       °
  648.  ,r' '''1. At any pause enter: ÉCR ''''TEACH'''''''                            °
  649.   '''   (a listing of the components of the tutorial workspace will appe       °
  650.  ar)'''                                                                        °
  651.   '''2. Jot down the names that appear in UPPER CASE --mostly TEACHxx--'       °
  652.  ''                                                                            °
  653.   '''3. Each of these is a component of the lesson that can be invoked''       °
  654.  '                                                                             °
  655.   '''   at the pause simply by entering its name. This will repeat that'       °
  656.  ''                                                                            °
  657.   '''   portion of the tutorial. The completion of each portion is marke       °
  658. Xd''' '''   by a line containing ²².''' 'end'                                  °
  659. *(1991 11 11 8 26 36 412)                                                      °
  660.  Finitialize ÉFX 'initialize;t' 'Σ  Initialize workspace' 'erase'              °
  661. X 'globals'                                                                    °
  662. *(1991 11 11 8 26 35 408)                                                      °
  663.  Fkeys ÉFX 'keys' 'Σ Display keyboard'                                         °
  664.   '''        1  2  3  4  5  6  7  8  9  0  +  ⌡'''                             °
  665.   '''SHFT ╒  ■  ²  <  ≤  =  ≥  >  ⌠  δ  ^  -  ÷'''                             °
  666.   '''ALT  ╘  ƒ  ·  ⁿ  √  Φ  φ  Θ  ╡  τ  σ  !  Æ''' ''''''                      °
  667.   '''         Q  W  E  R  T  Y  U  I  O  P  ╜  ╙  ╧'''                         °
  668.   '''SHFT     ?  ∙  ε  µ  ~  ╞  ╟  ∞  Ω  *  ╕  ╨  ╤'''                         °
  669.   '''ALT      q  w  e  r  t  y  u  i  o  p  æ  ≈  ╥'''                         °
  670.   '''CTRL     ┌  ┬  ┐              ╔  ╦  ╗''' ''''''                           °
  671.   '''          A  S  D  F  G  H  J  K  L  [  ]'''                              °
  672.   '''SHFT      α  ⌐  ╛  _  ╖  ╢  °  ''''  É  (  )'''                           °
  673.   '''ALT       a  s  d  f  g  h  j  k  l  »  «'''                              °
  674.   '''CTRL     ├  ┼  ┤       ─  ═    ╠  ╬  ╣''' ''''''                          °
  675.   '''           Z  X  C  V  B  N  M  ,  .  /'''                                °
  676.   '''SHFT       Γ  π  ∩  ¼  ¥  ÿ  |  ;  :  \'''                                °
  677.   '''ALT        z  x  c  v  b  n  m  Σ  ±  ≡'''                                °
  678.   '''CTRL      └  ┴  ┘  │  ║      ╚  ╩  ╝''' ''''''                            °
  679. X '''Toggle switch to ASCII is CTL-BACKSPACE''' '''CTRL+G gives beep'''        °
  680. *(1991 11 11 8 26 36 412)                                                      °
  681.  Flabel ÉFX 'u╜label w'                                                        °
  682.   'Σ Return 1 if w is not a valid character string label (also excludes        °
  683. Xl.c.)' '╕(u╜(1<µµw)δ1<╧w)/0' '╕(u╜~^/wεlc,uc,dig)/0' 'u╜w[1]εlc,dig'          °
  684. XClc 1 26 abcdefghijklmnopqrstuvwxyz                                           °
  685. *(1991 11 11 8 26 36 412)                                                      °
  686.  Fnon ÉFX 'non;t;rc;et;r'                                                      °
  687.   'Σ Ignore invalid keyboard entries, but evaluate valid APL2 expression       °
  688.  s' 'æ╜''       ''' 't╜æ' '╕(0=µ(t⌠'' '')/t)/0' '(rc et r)╜ÉEC t'              °
  689. X '╕(0=rc)/2' '╕((1=rc)doif ''r'')/2' '╕2'                                     °
  690. *(1991 11 11 8 26 36 412)                                                      °
  691.  Fnotb ÉFX 'u╜notb w' 'Σ Remove trailing blanks'                               °
  692.   '╕((1<╧w)doif ''u╜notb■ w'')/0' '╕((1<µµw)doif ''u╜πnotb Γ[2]w'')/0'         °
  693. X 'u╜(1-(,'' ''⌠Φw)∞1)╟w'                                                      °
  694. XCp 1 2  "                                                                     °
  695. *(1991 11 11 8 26 36 412)                                                      °
  696.  Fpause ÉFX 'v pause w;t'                                                      °
  697.   'Σ Pause, then print w v spaces right and return'                            °
  698. X 't╜(0=ÉNC ''v'')doif ''v╜6''' 'do' '(vµ'' ''),w' 'do'                        °
  699. XCq 0 '                                                                        °
  700. XCr 0                                                                         °
  701. *(1991 11 11 8 26 36 412)                                                      °
  702.  Freplace ÉFX 'u╜v replace w;i;r;s' 'Σ  Replace elements in v in w'            °
  703.   'i╜Γ∞µu╜w' 's╜2πv╜(v⌠'' '')Γv' 'i╜⌡r╜i⌡■Γ[1]w°.=╞v'                          °
  704. X 'u[(εi)/εr]╜s[(εi)/εi⌡■∞µs]'                                                 °
  705. *(1991 11 11 8 26 37 416)                                                      °
  706.  Fround ÉFX 'u╜v round w' 'Σ Half adjust w to vth decimal'                     °
  707. X 'u╜(╛0.5+w⌡10*v)÷10*v'                                                       °
  708. XCs 1 2 "                                                                      °
  709. *(1991 11 11 8 26 37 416)                                                      °
  710.  Fshow ÉFX '╢v show ╢w;╢t;╢b' 'Σ Display and execute ╢w'                       °
  711.   '╢t╜(0=ÉNC ''╢v'')doif ''╢v╜0'''                                             °
  712.   '╕((0=╧╢w)doif ''show ╢w,'''' '''''')/0'                                     °
  713.   '╕((1<╧╢w)doif ''╢v show■ ╢w'')/0' '''      '',╢w'                           °
  714. X '╕((╢v^'':''ε╢w)doif ''╢t╜evaldd ╢w'')/L0' '''ÉEM'' ÉEA ╢w' 'L0:do'          °
  715. *(1991 11 11 8 26 37 416)                                                      °
  716.  Fshowdd ÉFX 'u╜showdd w;a;b;c;r'                                              °
  717.   'Σ  Display a direct definition function'                                    °
  718.   '╕((1=╧w)doif ''u╜showdd Γw'')/u╜0'                                          °
  719.   '╕((3⌠ÉNC╞w)doif ''(ε╞w),'''' is not a function'''''')/0'                    °
  720.   'c╜Γ[2]ÉCR╞w' 'c╜notb(2╞c),(Γ''aw α∙'')replace■2╟c'                          °
  721.   '╕((~''ΣDD''╧3╞2πc)doif ''''''Not a direct definition function'''''')/       °
  722.  0' 'u╜1' 'b╜('' ''⌠╞c)Γ╞c' 'a╜''      ''' 'r╜2╟3πc'                           °
  723.   '╕((3=µc)doif ''a,(╞w),'''':'''',r,(3<µ2πc)/''''   Σ'''',3╟2πc'')/0'         °
  724.   'a╜a,(╞w),'':'',(2╟5πc),'':''' 'b╜(+\r=''('')-+\r='')''' 'b╜b∞0'             °
  725. X 'a╜a,(²3╟(b-1)╞3╟r),'':'',2╟»(b+2)╟r' 'a,(3<µ2πc)/''  Σ'',3╟2πc'             °
  726. *(1991 11 11 8 26 37 416)                                                      °
  727.  Fshowfn ÉFX 'u╜v showfn w;f;n;t;ÉIO' 'Σ Simulate the STSC ÉVR command'        °
  728.   't╜(0=ÉNC ''v'')doif ''v╜0''' 'ÉIO╜0'                                        °
  729.   'u╜r,''      '',''╖'',w,''[É]'',(╞v)╞''╖''' 'n╜1╞µf╜ÉCR w' 'n╜«∞n'           °
  730.   'n╜(n⌠'' '')Γn' 'f╜(π''['',■n,■Γ''] ''),f'                                   °
  731.   't╜(1<µ,v)doif ''f╜f[1╟v;]'' ''u╜''''''''''' 'u╜²1╟u,r,,f,r'                 °
  732. X 'u╜((-+/^\'' ''=Φu)╟u),('' ''(r,''      ╖'',date 2 ÉAT w))[╞v],r'            °
  733. *(1991 11 11 8 26 37 416)                                                      °
  734.  Fsimdd ÉFX 'u╜simdd w;e' 'Σ Simple direct definition mode' 'u╜0'              °
  735.   '╕((0⌠ÉNC╞w)doif ''''''Already defined'''''')/0' 'e╜''α''ε2πw'               °
  736.   'w[2]╜Γ''u╜'',''α∙ aw'' replace 2πw' 'w╜w[1 3 2]'                            °
  737. X 'w[1]╜Γε''u╜'',(e/''a ''),w[1],'' w''' 'u╜╧ÉFX w'                            °
  738. *(1995 10 2 13 45 46 524)                                                      °
  739.  Fsvopair ÉFX 'DC╜PID svopair SV;CV' 'SV╜(²2╞1 1,µSV)µSV╜πSV'                  °
  740.   '╕(2=ÉNC ''PID'')/DYADIC' 'DC╜ÉSVO SV' '╕0' 'DYADIC:'                        °
  741.   'CV╜(-+/^\ΦSV='' '')ΦSV' 'CV╜(-+/^\ΦCV⌠'' '')ΦCV' 'CV╜CV[;ÉIO]=''C'''        °
  742.   '╕(1^.⌠CV/DC╜PID ÉSVO SV)/END' 'ÉSVE╜15' 'CHECK:'                            °
  743.   '╕(1^.⌠CV/DC╜ÉSVO SV)/END' '╕(0⌠ÉSVE)/CHECK' 'END:'                          °
  744. X 'CV╜1 0 1 0 ÉSVC CV≡SV'                                                      °
  745. XCt 1 7                                                                        °
  746. XCuc 1 26 ABCDEFGHIJKLMNOPQRSTUVWXYZ                                           °
  747. *(1995 10 8 14 0 19 264)                                                       °
  748.  F╢FM ÉFX 'R╜A ╢FM B;E;F;G;H;I;J;TC;ÉIO;C╢F;D╢F'                               °
  749.   'Σ Emulation of APL2/370 ╢FM built-in function using AP210'                  °
  750.   'Σ Licensed Materials - Property of IBM' 'ÉIO╜0'                             °
  751.   '(G H)╜210 ÉSVO■''C╢F'' ''D╢F''' 'ÉSVE╜15' 'SVCHECK:'                        °
  752.   '(G H)╜ÉSVO■''C╢F'' ''D╢F''' '╕((G=2)^(H>0))/SVOK'                           °
  753.   '╕(0⌠ÉSVE)/SVCHECK' '╕LB' 'SVOK:' 'G╜1 0 1 0 ÉSVC ''C╢F''' 'G╜0'             °
  754.   'H╜32768' '╕(0=ÉNC ''A'')/LA' 'C╢F╜''DL,'',B' '╕(^/0 2⌠╞E╜C╢F)/LC'           °
  755.   '╕((δ/1 2=µµA)^0=⌡/µA)/LC' 'C╢F╜''IW,'',B,'',D''' '╕(0⌠╞E╜C╢F)/LC'           °
  756.   'D╢F╜''A''' 'C╢F╜5' '╕(0⌠╞E╜C╢F)/LC' 'C╢F╜4 0' '╕(0⌠╞E╜C╢F)/LC'              °
  757.   'TC╜1╟D╢F' '╕((3≤µE),(2=╧A)^1=µE╜µA)/LJ,LI' 'I╜A,╞TC'                        °
  758.   '»(2=µTC)/''I╜I,╞1╟TC''' 'I╜,I' '╕LO,B╜A╜''''' 'LI:B╜∞µF╜2+╞■µ■A'            °
  759.   'LN:E╜1⌐+/H≥+\F' 'I╜εA[E╞B],■ΓTC' 'B╜E╟B' 'F╜E╟F' 'LO:D╢F╜(J╜H╛µI)╞I'        °
  760.   'C╢F╜3,G,J' '╕((8=╞E),0⌠╞E╜C╢F)/LG,LC' 'G╜G+J' '╕(H≥µI)/LF'                  °
  761.   '╕LO,µI╜H╟I' 'LF:╕(0⌠µB)/LN' '╕0,R╜C╢F,C╢F╜∞0'                               °
  762.   'LA:C╢F╜''IR,'',B,'',D''' '╕(0⌠╞E╜C╢F)/LC' '╕(0⌠B╜D╢F)/LMO'                  °
  763.   '╕0,0µR╜0 0µ''''' 'LMO:R╜''''' 'J╜ÉTC[2]' 'LE:C╢F╜2,G,H╛B'                   °
  764.   '╕((8=╞E),0⌠╞E╜C╢F)/LG,LC' 'F╜(+\0+ÉTC[2]=J)ΓJ╜J,D╢F' 'J╜╞²1╞F'              °
  765.   'R╜R,1╟■(-B>H)╟F' '╕(0≥B╜B-H)/LX' '╕LE,G╜G+H'                                °
  766.   'LX:R╜(-(ÉAF 26)=╞╞²1╞R)╟R' 'R╜(-0=µ╞²1╞R)╟R' 'R╜(-ÉTC[1]=²1╞■R)╟■R'         °
  767.   'R╜πR' '╕0' 'LG:╕(H=128)/LC' '╕((LO,LE)[0=ÉNC ''A'']),H╜128⌐⌐H÷2'            °
  768. X 'LB:ÉES ''AP210 share offer failed''' 'LJ:ÉES 5 2' 'LC:╕0,R╜E'               °
  769. *(1994 4 21 21 0 0 240)                                                        °
  770.  F╢FV ÉFX 'R╜A ╢FV B;E;F;G;H;I;J;TC;ÉIO;C╢F;D╢F'                               °
  771.   'Σ Emulation of APL2/370 ╢FV built-in function using AP210' 'Σ'              °
  772.   'Σ Licensed Materials - Property of IBM'                                     °
  773.   'Σ 5621-430, 5648-065, 5765-012 (c) Copyright IBM Corp. 1983, 1994.'         °
  774.   'Σ' 'Σ A is optional and if omitted the file will be read.'                  °
  775.   'Σ A if included defines the CHARACTER data to be written.'                  °
  776.   'Σ B has the syntax [/path/]filename' 'ÉIO╜0'                                °
  777.   '(G H)╜210 ÉSVO■''C╢F'' ''D╢F''          Σ Offer a pair of variables'        °
  778.   'ÉSVE╜15                             Σ Wait up to 15 seconds for accep       °
  779.  ts' 'SVCHECK:'                                                                °
  780.   '(G H)╜ÉSVO■''C╢F'' ''D╢F''              Σ Check degree of coupling'         °
  781.   '╕((G=2)^(H>0))/SVOK                 Σ Out of loop if shared'                °
  782.   '╕(0⌠ÉSVE)/SVCHECK                   Σ Retry if time left'                   °
  783.   '╕LB                                 Σ Out of time, quit' 'SVOK:'            °
  784.   'G╜1 0 1 0 ÉSVC ''C╢F''                Σ Set access control'                 °
  785.   'G╜0                      Σ Initialise file pointer'                         °
  786.   'H╜32768                  Σ Record size (may be reduced)'                    °
  787.   '╕(0=ÉNC ''A'')/LA'                                                          °
  788.   'C╢F╜''DL,'',B              Σ Delete existing file if any'                   °
  789.   '╕(^/0 2⌠╞E╜C╢F)/LC'                                                         °
  790.   '╕((δ/1 2=µµA)^0=⌡/µA)/LC Σ Check for something to write'                    °
  791.   'C╢F╜''IW,'',B,'',D''         Σ Open new file' '╕(0⌠╞E╜C╢F)/LC'              °
  792.   'D╢F╜''A''                  Σ Write a single variable record' 'C╢F╜5'        °
  793.   '╕(0⌠╞E╜C╢F)/LC' 'C╢F╜4 0                  Σ Read it back'                   °
  794.   '╕(0⌠╞E╜C╢F)/LC'                                                             °
  795.   'TC╜1╟D╢F                 Σ Capture the line terminators (CR/LF or LF)       °
  796.  ' '╕((3≤µE),(2=╧A)^1=µE╜µA)/LJ,LI'                                            °
  797.   'E╜'' ''=,²1╞[1]A╜(²2╞1 1,µA)µA Σ Check for any trailing blanks to rem       °
  798.  ove' 'I╜A,╞TC                  Σ Append line terminator to each row'          °
  799.   '»(2=µTC)/''I╜I,╞1╟TC''     Σ Append another if there are two'               °
  800.   'I╜,I                     Σ Make into a simple vector' '╕(~δ/E)/LH'          °
  801.   'I╜(,(~E±Φ^\'' ''=ΦA[E/∞╞µA;]),((╞µA),µTC)µ1)/I Σ Remove trailing blan       °
  802.  ks' 'LH:╕LO,B╜A╜'''''                                                         °
  803.   'LI:╕(~δ/E╜'' ''=ε²1╞■A)/LD  Σ Check for any trailing blanks to remove       °
  804.  ' 'E╜E/∞µE                  Σ Convert to indices'                             °
  805.   'LL:A[╞E]╜Γ(-('' ''=ΦF)∞0)╟F╜,(╞E)πA      Σ Remove trailing blanks'          °
  806.   '╕(0⌠µE╜1╟E)/LL' 'LD:B╜∞µF╜2+╞■µ■A'                                          °
  807.   'LN:E╜1⌐+/H≥+\F    Σ Number of items that will fit in record (minimum        °
  808.  of 1)'                                                                        °
  809.   'I╜εA[E╞B],■ΓTC           Σ Append line terminators to each item'            °
  810.   'B╜E╟B' 'F╜E╟F' 'LO:D╢F╜(J╜H╛µI)╞I' 'C╢F╜3,G,J'                              °
  811.   '╕((8=╞E),0⌠╞E╜C╢F)/LG,LC'                                                   °
  812.   'G╜G+J                    Σ Increment file pointer'                          °
  813.   '╕(H≥µI)/LF               Σ Check if all of this data has been written       °
  814.  ' '╕LO,µI╜H╟I' 'LF:╕(0⌠µB)/LN'                                                °
  815.   '╕0,R╜C╢F,C╢F╜∞0          Σ Close the file and exit'                         °
  816.   'LA:C╢F╜''IR,'',B,'',D''       Σ Open file for read' '╕(0⌠╞E╜C╢F)/LC'        °
  817.   '╕(0⌠B╜D╢F)/LMO           Σ Is file empty?'                                  °
  818.   '╕0,R╜0µΓ''''               Σ File empty return an empty vector'             °
  819.   'LMO:R╜''''' 'J╜ÉTC[2]' 'LE:C╢F╜2,G,H╛B' '╕((8=╞E),0⌠╞E╜C╢F)/LG,LC'          °
  820.   'F╜(+\0+ÉTC[2]=J)ΓJ╜J,D╢F Σ Split each record into component vectors'        °
  821.   'J╜╞²1╞F                  Σ Store last (incomplete) item'                    °
  822.   'R╜R,1╟■(-B>H)╟F' '╕(0≥B╜B-H)/LX'                                            °
  823.   '╕LE,G╜G+H                Σ Increment file pointer'                          °
  824.   'LX:R╜(-(ÉAF 26)=╞╞²1╞R)╟R Σ Remove EOF record (if there)'                   °
  825.   'R╜(-0=µ╞²1╞R)╟R        Σ Remove last empty record'                          °
  826.   'R╜(-ÉTC[1]=²1╞■R)╟■R   Σ Remove CR''s if present'                           °
  827.   '╕(~δ/E╜'' ''=ε²1╞■R)/0     Σ Check for any trailing blanks to remove'       °
  828.   'E╜E/∞µE                  Σ Convert to indices'                              °
  829.   'LM:R[╞E]╜Γ(-('' ''=ΦF)∞0)╟F╜,(╞E)πR      Σ Remove trailing blanks'          °
  830.   '╕(0⌠µE╜1╟E)/LM' '╕0' 'LG:╕(H=128)/LC'                                       °
  831.   '╕((LO,LE)[0=ÉNC ''A'']),H╜128⌐⌐H÷2     Σ Halve record length'               °
  832.   'LB:ÉES ''AP210 share offer failed'''                                        °
  833. X 'LJ:ÉES 5 2                Σ Rank error' 'LC:╕0,R╜E'                         °
  834.