home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
teachapl.zip
/
APL2OS2T.ZIP
/
TEACH43.ATF
< prev
next >
Wrap
Text File
|
1996-06-16
|
68KB
|
834 lines
XNÉIO 0 1 °
XNÉCT 0 1.000000000000011E²13 °
XCÉFC 1 6 .,*0_² °
XNÉRL 0 16807 °
XCÉPR 0 °
XCÉLX 1 5 TEACH °
NATTS 2 3 9 1 1001 1996 6 3 14 23 23 81 1 1001 1996 6 3 14 23 3 22 1 °
X 1001 1996 6 3 14 23 17 78 °
XNC210 0 0 °
XND210 1 0 °
XAD211╜('DROP')('FUNCTION') °
XNDAT 2 3 3 1 2 3 4 5 6 7 8 9 °
*(1991 11 11 8 26 35 408) °
FDISPLAY ÉFX 'D╜S DISPLAY A;ÉIO;R;C;HL;HC;HT;HB;VL;VB;V;W;N;B' °
'Σ DISPLAY A GENERAL ARRAY IN PICTORIAL FORM' °
'Σ NORMAL CALL IS MONADIC. DYADIC CALL USED ONLY IN' °
'Σ RECURSION TO SPECIFY DISPLAY RANK, SHAPE, AND DEPTH.' 'ÉIO╜0' °
'»(0=ÉNC ''S'')/''S╜µA''' 'R╜╞µ,S Σ PSEUDO RANK.' °
'C╜''┐┌└┘'' Σ UR, UL, LL, AND LR CORNERS.' °
'HL╜''─'' Σ HORIZONTAL LINE.' °
'HC╜HL,''Θ╕'',HL,''~+ε'' Σ HORIZONTAL BORDERS.' °
'HT╜HC[(0<R)⌡1+0<╞²1╞,S]' 'ΣW╜,0╧■╞0µΓ(1⌐µA)╞A' °
'HB╜HC[3+3╛(''2⌡~A╧«A'' ÉEA ''1+╞ε0⌡(1⌐⌡/µA)╞,A'')+3⌡1<µµS]' °
'VL╜''│'' Σ VERTICAL LINE.' °
'VB╜VL,''Φ╟'' Σ VERTICAL BORDER.' °
'V╜VB[(1<R)⌡1+0<²1╞²1╟,S]' °
'»(0εµA)/''A╜(1⌐µA)µΓ╞A'' Σ SHOW PROTOTYPE OF EMPTIES.' °
'╕(1<╧A)/GEN' '╕(2<µµA)/D3' °
'D╜«A Σ SIMPLE ARRAYS.' 'W╜1╞µD╜(²2╞1 1,µD)µD' °
'N╜²1+1╟µD' '╕(0=µµA)/SS' °
'D╜(C[1],V,((W-1)µVL),C[2]),((HT,NµHL),[0]D,[0]HB,NµHL),C[0],(WµVL),C[ °
3]' '╕0' 'SS:HB╜((0 '' '')=╞0µΓA)/'' -''' °
'D╜'' '',('' '',[0]D,[0]HB,Nµ'' ''),'' ''' '╕0' °
'GEN:D╜«DISPLAY■A Σ ENCLOSED ...' 'N╜Dδ.⌠'' ''' °
'D╜(Nδ~1ΦN)≡D' 'D╜(δ≡~'' ''╤D)/D' 'D╜((1,µS)µS)DISPLAY D' °
'╕(2≥µ,S)╟D3E,0' 'D3:D╜0 ²1╟0 1╟«ΓA Σ MULT-DIMENSIONAL ...' °
'W╜1╞µD' 'N╜²1+1╟µD' °
'D╜(C[1],V,((W-1)µVL),C[2]),((HT,NµHL),[0]D,[0]HB,NµHL),C[0],(WµVL),C[ °
3]' 'D3E:N╜²2+µ,S' °
X 'V╜C[Nµ1],[0]VB[1+0<²2╟,S],[0](((²3+╞µD),N)µVL),[0]C[Nµ2]' 'D╜V,D' °
*(1991 11 11 8 26 36 412) °
FGO ÉFX 'GO;b;e;t' 'Σ Expression driver' 'L0:b╜e╜''''' 'æ╜'' ''' °
't╜æ' '╕(^/'' ''=t)/L0' '╕((^/'')OFF ''=5╞6╟t)doif ''exit'')/0' °
'╕(('':''εt)doif ''b╜evaldd (+/^\'''' ''''=t)╟t'')/L0' °
'''e╜ÉEM'' ÉEA t' '╕(0=µ,e)/L0' '╕b/L0' °
'''This is not a valid APL2 expression''' 'æ╜''*''' °
X '╕(''?''⌠╞1╟æ)/L0' 'e' '╕L0' °
CLIST 2 3 31 ONE TWO °
X THREE °
XCONE 1 16 CHARACTER STRING °
XNRC 0 0 °
*(1995 4 23 14 14 6 304) °
FSVOFFER ÉFX 'DC╜PID SVOFFER SV' 'SV╜(²2╞1 1,µSV)µSV╜πSV' °
'╕(2=ÉNC ''PID'')/DYADIC' 'DC╜ÉSVO SV ╪ ╕0' °
'DYADIC:╕(1^.⌠DC╜PID ÉSVO SV)/END' 'ÉSVE╜15' °
'CHECK:╕(1^.⌠DC╜ÉSVO SV)/END' '╕(0⌠ÉSVE)/CHECK' °
X 'END:SV╜1 0 1 0 ÉSVC SV' °
*(1995 9 25 14 7 42 448) °
FSVOPAIR ÉFX '≈_DC╜≈_PID SVOPAIR ≈_SV;≈_CV' °
'≈_SV╜(²2╞1 1,µ≈_SV)µ≈_SV╜π≈_SV' '╕(2=ÉNC ''≈_PID'')/≈_DYADIC' °
'≈_DC╜ÉSVO ≈_SV' '╕0' '≈_DYADIC:' '≈_CV╜(-+/^\Φ≈_SV='' '')Φ≈_SV' °
'≈_CV╜(-+/^\Φ≈_CV⌠'' '')Φ≈_CV' '≈_CV╜≈_CV[;ÉIO]=''C''' °
'╕(1^.⌠≈_CV/≈_DC╜≈_PID ÉSVO ≈_SV)/≈_END' 'ÉSVE╜15' '≈_CHECK:' °
'╕(1^.⌠≈_CV/≈_DC╜ÉSVO ≈_SV)/≈_END' '╕(0⌠ÉSVE)/≈_CHECK' '≈_END:' °
X '≈_CV╜1 0 1 0 ÉSVC ≈_CV≡≈_SV' °
*(1996 5 30 14 16 50 524) °
FTEACH ÉFX 'TEACH;B' 'Σ Copyright Z V Jizba 1991; all rights reserved' °
'copyright' 'initialize' 'TEACH1 Σ Dealing with (external) files' °
'''There are two AP''''s that deal with files. AP210 allows you to''' °
'''process any file that you can access. Learning how to use this''' °
'''AP is somewhat involved.'',r' °
'''AP211 is designed to store and retrieve named APL2 objects. The''' °
'''use of this AP is easy to learn. If you wish to skip the portion''' °
'B╜3⌠''yY''∞╞get ''dealing with AP210, enter Yes here: ''' 'do' °
'╕B/L1' 'TEACH2 Σ Auxilliary Processo 210 -- External files' °
'TEACH3 Σ AP210 Control variable' 'TEACH4 Σ AP210 Command mode' °
'TEACH5 Σ Sample file TEST210' 'TEACH6 Σ AP210 Control Subcommands' °
'TEACH7 Σ AP210 Control Subcommands (continued)' °
'TEACH8 Σ AP210 Return Codes' °
'L1:TEACH9 Σ AP211 Storing and retrieving APL2 objects' °
'TEACH10 Σ Reading and accessing AP211 data' °
X 'TEACH11 Σ Final comments on AP211' °
*(1996 6 3 14 27 41 428) °
FTEACH1 ÉFX 'TEACH1' 'Σ File auxilliary processor (AP210)' °
'''In the previous lesson we described a simple Auxilliary Processor, °
the''' °
'''AP100. It''''s purpose is to be able to enter OS2/DOS commands from °
within''' °
'''APL2. We also studied AP101, the Stack Processor. Using AP 101 we c °
an''' °
'''issue System Commands from within APL2. In this lesson we will''' °
'''describe Auxilliary Processors 210 and 211. These processors provid °
e''' '''the tools for communicating with the OS@ (DOS) file system.''' °
'do' °
'''When dealing with files, one has to be able to specify one of sever °
al''' '''functions:'',r' ''' a. define a new file''' °
''' b. write a record into the file''' °
''' c. read a record from a file''' °
''' d. remove a record from a file''' ''' e. rename a file''' °
''' f. erase a file'',r' °
'''The information about what specific function is to be performed is' °
'' °
'''not always sufficient. To deal with items b. c. and d., it is also' °
'' °
'''necessary to specify a location for data to be stored or retrieved. °
'',r' °
'''If we think of the process of dealing with external files as if it' °
'' °
'''were a function, then it would be an ambivalent one. The right''' °
'''argument would contain the file process to be implemented, and the' °
'' °
'''left optional argument would specify the data to be stored, or the' °
'' °
'''name of a variable to contain the data to be retrieved. The functio °
n''' °
'''would return a code giving the success or failure of the operation. °
X''' 'end' °
*(1996 4 23 13 23 59 552) °
FTEACH10 ÉFX 'TEACH10;D211;T' 'Σ Reading and accessing AP211 data' °
'T╜211 SVOFFER ''D211''' 'D211╜''DROP'' ''FUNCTION''' °
'D211╜''CREATE'' ''FUNCTION'' ╪ T╜D211' °
'''Before data can be entered to (or read from) the file, it has to be °
''' '''opened with the USE command'',r' °
'show ''D211╜''''USE'''' ''''FUNCTION'''''' ''D211''' °
'''Note that in addition to the Return Code, we also get a second''' °
'''element, namely the record length assigned to the file.'',r' °
'''Once a 211 type file has been opened, there are four types of''' °
'''operations that make sense. These are'',r' °
''' GET get an APL2 object from the file''' °
''' SET place an APL2 object into the file''' °
''' ERASE erase an APL2 object from the file''' °
''' LIST list the names of APL2 objects in the file'',r' 'do' °
'''The SET command is of the form'',r' °
''' D211╜''''SET'''' ''''name'''' APL2-object'',r' °
'''Note that the third element must be a scalar element of the three'' °
' °
'''element vector. That means that normally, the APL2 object must be'' °
' '''enclosed.'',r' °
'''The following example shows a valid entry because the right argumen °
t is''' '''a valid three element nested vector'',r' °
'show ''D211╜''''SET'''' ''''ONE'''' ''''TEST DATA'''''' ''D211''' °
'''Again, the return code of 0 means that the SET process was successf °
ul.''' 'do' °
'''In the next example we wish to store an array containing the canoni °
cal''' °
'''representation of function "date". This array must be enclosed so t °
hat the''' °
'''argument to be assigned to D211 is a three element vector.'',r' °
'show ''D211╜''''SET'''' ''''TWO'''',ΓÉCR ''''date'''''' ''D211''' °
'''Here is another APL2 data type to be stored'',r' °
'show ''D211╜''''SET'''' ''''THREE'''',Γ3 3µ∞9'' ''D211''' °
'''We have now stored three APL2 objects, namely ONE, TWO, and THREE.' °
'' °
'''Suppose we find that object ONE is no longer valid, and we wish to' °
'' °
'''replace it by another object, say the string ''''ANOTHER TEST VECTO °
R''''''' '''This can be done simply by entering'',r' °
'show ''D211╜''''SET'''' ''''ONE'''' ''''ANOTHER TEST VECTOR'''''' ''D °
211''' °
'''To retrieve an APL2 object previously stored, we use command GET'', °
r' °
'show ''D211╜''''GET'''' ''''THREE'''''' ''THREE╜2πÉ╜D211'' ''DISPLAY °
THREE''' °
'''Since D211 can be referenced only once, it is a good idea to assign °
''' °
'''it immediately to a normal APL2 variable. Note also that the conten °
ts''' °
'''of D211 is a two element vector. The first element of that vector i °
s''' °
'''the Return Code, and the second element is the APL2 object that has °
''' '''been retrieved.''' 'do' °
'''To see what named objects reside in the file, we use command LIST'' °
,r' 'show ''D211╜''''LIST'''' ''''NAMES'''''' ''DISPLAY LIST╜D211''' °
'''It is also possible to obtain a table listing three numeric items'' °
,r' °
''' The number of fixed length records needed to store the APL2 obj °
ect''' ''' The user ID (default is 1001)''' °
''' The time stamp of the last update of the APL2 object'',r' °
'show ''D211╜''''LIST'''' ''''ATTS'''''' ''DISPLAY ATTS╜D211''' °
'''Command LIST NAMES tells the contents of an AP211 file. What happen °
s''' °
'''when command GET is issued for an entry not on that list. Recall th °
at''' '''for a valid entry, D211 contains a two element vector'',r' °
'show ''D211╜''''GET'''' ''''ONE'''''' ''DISPLAY D211''' °
'''For an invalid entry, the result is numeric return code'',r' °
'show ''D211╜''''GET'''' ''''FOUR'''''' ''DISPLAY D211''' °
'''When using the GET command it may be generally useful to take advan °
tage''' '''of the multiple specification feature of APL2'',r' °
'show ''D211╜''''GET'''' ''''THREE'''''' ''(RC DAT)╜D211'' ''RC'' ''DI °
SPLAY DAT''' °
'''Finally, one may require the removal of specific objects from the'' °
' '''file. The command ERASE will do that'',r' °
'show ''D211╜''''LIST'''' ''''NAMES'''''' ''D211'' ''D211╜''''ERASE''' °
' ''''ONE''''''' °
'show ''D211'' ''D211╜''''LIST'''' ''''NAMES'''''' ''D211''' °
'''Although Shared Variable 211 can be retracted with the ÉSVR Command °
,''' °
'''one need not take that step. If more than one file is to be process °
ed,''' °
'''the command RELEASE has the effect of closing a file that has been' °
'' '''previously opened with the USE command'',r' °
X 'show ''D211╜''''RELEASE'''''' ''D211''' 'end' °
*(1996 4 23 13 24 24 416) °
FTEACH11 ÉFX 'TEACH11' 'Σ Final comments on AP211' °
'''In summary, AP211 is APL-like, is simple to use, and provides a fas °
t''' °
'''and efficient way to store APL2 objects. As the limitations on the' °
'' °
'''size of APL2 workspaces are gradually removed, one may question the °
''' °
'''desirability of having a second level of storage for APL2 data. It °
is''' °
'''possible that for many if not most applications one can get along w °
ith''' °
'''a single workspace holding every APL2 object. Nevertheless there wi °
ll''' °
'''invariably arise situations where this strategy is not the best.''' °
'do' °
'''There are many such possible applications of AP211. Here are some o °
f''' '''the more obvious ones:'',r' °
''' Seldom used APL2 utilities can be stored in file UTILITY''' °
''' Documentation or HELP files can be stored in file HELP''' °
''' Documentation can be placed in file BLUEPRINT''' °
''' Seldom used subroutines of complex applications''' °
''' Semantic nets or other AI structures''' °
''' Data bases of all kinds requiring access by name'',r' 'do' °
'''In a later lesson we will show some specific examples of the usage °
of''' '''AP211.''' °
'''Before we leave this lesson, we should discard file FUNCTION'',r' °
X 'show ''D211╜''''DROP'''' ''''FUNCTION''''''' 'end' °
*(1996 5 30 14 19 47 524) °
FTEACH2 ÉFX 'TEACH2;C210;D210;T' 'Σ Control and data variables' °
'''AUXILLIARY PROCESSOR 210'',r' °
'''In the previous lesson we invoked function SVOFFER to activate the' °
'' °
'''shared variable named in its right argument. For Auxilliary Process °
or''' °
'''210, one shared variable is insufficient to deal with the requireme °
nts''' °
'''associated with processing of external files. To deal with this, we °
''' °
'''will use the IBM supplied function SVOPAIR. At this point it might' °
'' '''be useful to review the use of the ÉSVO System Function.''' 'do' °
'''When the ÉSVO command is given, the right argument allows not one, °
but''' °
'''two or more names to be associated with a specific AP. If more than °
''' °
'''one such variable is needed, the names must in some way be similar, °
so''' °
'''that the AP will be able to recognize the existence of the close ti °
es''' '''connecting these labels.'',r' °
'''Typically one of the variables is used to control the process, and' °
'' °
'''another one is used to contain the data. Therefore, the first varia °
ble''' °
'''must begin with the letter C (for CONTROL). Not surprisingly, the'' °
' °
'''second variable must begin with the letter D (for DATA). The remain °
der''' °
'''of the label is arbitrary (subject to APL2 naming conventions),''' °
'''provided the subscript is identical for both.''' 'do' °
'''So if we name the control variable C210, then the data variable has °
to''' '''have the name D210.'',r' 'T╜210 SVOPAIR ''C210'' ''D210''' °
''' 210 ÉSVO■ ''''C210'''' ''''D210'''''',r,''1 1''' °
'show ''ÉSVO■ ''''C210'''' ''''D210''''''' °
'''Just as in AP100 and AP101, the full COUPLING requires a second iss °
ue''' °
'''of ÉSVO. Note, however, that D210 (the varable associated with data °
)''' °
'''retains its coupling of one. Why? Because no data transfer is possi °
Xble''' '''until a suitable CONTROL command has been set.''' 'TEACH2A' °
*(1996 4 25 14 1 16 304) °
FTEACH2A ÉFX 'TEACH2A;T' 'Σ C210 and D210 as variables' '''''' 'do' °
'''Although C210 and D210 are known to APL2 as "variables"'',r' °
'show ''ÉNC■ ''''C210'''' ''''D210''''''' °
'''at this point they are still undefined. Any reference to them will' °
'' '''return a VALUE ERROR.'',r' 'T╜0 0 0 0 ÉSVC ''C210''' °
'''(if your screen FREEZES at the next example, do an INTERRUPT, becau °
se''' '''your Shared Variable Control has been set to 1.)''' °
'0 show ''C210''' °
'''In general, shared variables MUST be assigned (or referenced) in a' °
'' °
'''specific sequence. Before we can discuss that sequence, it will be' °
'' '''useful to discuss the scope of Auxilliary Processor 210.''' 'do' °
'''However, before we get into details on the use of AP210, you may''' °
'''wish to study function SVOPAIR. If you do, enter YES at the next''' °
'''prompt.''' °
'╕(~(╞ans ''Do you wish to study function SVOPAIR?'')ε''Yy'')/0' °
'''Function "svopair" is a copy of function SVOPAIR, where all comment °
s''' °
'''have been removed and the prefix "≈_" --which is used to reduce the °
''' '''chance of name conflicts-- has also been removed.)''' 'do' °
'0 0 1 2 3 4 showfn ''svopair''' °
'''Just as in SVOFFER, the function is ambivalent. If the left argumen °
t''' °
'''(PID) is missing, the branch to DYADIC on line [2] fails, and lines °
''' °
'''[3-4] are evaluated. Line [1] converts the right argument to an''' °
'''array with at least one row and one column. Line [3] returns the''' °
'''degree of coupling of the right arguments.''' 'do' °
'0 5 6 7 8 9 showfn ''svopair''' °
'''The objective of lines [6-8] is to identify the row of SV that''' °
'''contains the name of the control variable. Line [6] shifts the''' °
'''rows of SV to the right so that there are no trailing blanks.''' °
'''Line [7] shifts the first letter of the last word on each line''' °
'''to the first row. (The function allows for the presence of''' °
'''"surrogates" in front of the shared variable names.) Line [8] final °
ly''' '''identifies the row containing a "C" in the first column.''' °
'do' °
'''A first invocation of ÉSVO on the array SV should return the vector °
''' °
'''1 1 on line [9]. If it does not, a branch to END (line [14]) ends'' °
' '''the function.''' '0 10 11 12 13 showfn ''svopair''' °
'''Line [10] starts the EVENT clock. Line [12] tests for a change in'' °
' °
'''the value of vector CV. A change causes exit to line [14]. Line [15 °
]''' '''loops to line [11] until the event clock runs out.''' 'do' °
'0 14 15 showfn ''svopair''' °
'''Lines [14-15] end by seting the control shared variable.'',r' °
X '''NOW BACK TO THE SCOPE OF AP 210''' 'end' °
*(1996 4 14 12 10 16 288) °
FTEACH3 ÉFX 'TEACH3' 'Σ Control variable' '''THE CONTROL VARIABLE'',r' °
'''Now that both variables are active we can proceed with issuing''' °
'''commands to process DOS files. When dealing with files, we must''' °
'''recognize that there are three types of information that are needed °
:'',r' °
''' A. The name (including the path name) of the file to be process °
ed''' °
''' B. The type of operation to be performed (read, write, delete)' °
'' ''' C. The specific record to be processed''' 'do' °
'''In addition, in general, there are different types of files. For''' °
'''example, there are files that'',r' °
''' a. can be read only, or can be read and writen into''' °
''' b. fixed length files, or variable length files''' °
''' c. direct access files or sequential files''' °
''' d. ASCII files, Character files, boolean, and APL2 data files'', °
r' °
'''To handle this great diversity, the AP210 control variable operates °
''' '''in two modes: COMMAND mode, and SUBCOMMAND mode.''' 'do' °
'''The command mode must be issued first. It specifies the general nat °
ure''' °
'''of the operation, the file name, and the type of data to be process °
ed.''' °
'''The subcommand mode specifies the type of file, whether the operati °
on''' °
'''is to be read or write, and the record number and possibly the''' °
X '''starting position of the read process.''' 'end' °
*(1996 4 14 12 10 27 332) °
FTEACH4 ÉFX 'TEACH4' 'Σ Command mode of control variable' °
'''COMMAND MODE'',r' °
'''In the command mode, the right argument is a character string.''' °
'''It has the following format:'',r' °
''' command,filespec[,code]'',r' 'do' °
'''The command is a two letter abbreviation giving the type of action' °
'' '''that is to be performed:'',r' °
''' IR open file for reading only''' °
''' IW open file for read or/and write''' °
''' DL delete file''' ''' RN rename file'',r' 'do' °
'''The command is followed by a comma, and then by a file specificatio °
n'',r' °
'''A third argument, the file code, is optional. It specifies the natu °
re''' °
'''of the data type. Four data types are supported by AP210:'',r' °
''' A APL2 objects (This is the default)''' °
''' B Bit strings packed 8 bits per byte without headers''' °
''' C Character strings in APL2 internal (ASCII) code''' °
''' D ASCII strings of characters'',r' °
'''Codes B and C require the file records to be of fixed length. Code' °
'' '''D may be used with variable record lengths, as can code A.''' °
'do' °
'''There is one more code, T for "Translate". This indicates that the' °
'' °
'''record is a string of characters, without any header, to be transla °
Xted''' '''according to the AP 210 translate table.''' 'end' °
*(1996 4 14 12 10 44 400) °
FTEACH5 ÉFX 'TEACH5;T' 'Σ Subcommand mode' °
'T╜210 SVOPAIR ''C210'' ''D210''' °
'''As an example, let us assume we wish to store some APL2 arrays in'' °
' °
'''a file. The file is to be called "TEST210", and is to be placed in' °
'' '''the current directory (which is the default).'',r' °
'show ''C210╜''''IW,TEST210''''''' °
'''Note that we did not use the file code, since APL2 type file is the °
''' '''default.''' 'do' °
'''At this point we do not know whether our command was succesfully''' °
'''completed. However, since variable C210 has been assigned a value'' °
' '''(the character string IW,TEST210), it can be referenced.''' °
'''It''''s contents is not the character string, but a numeric integer °
''' °
'''value that identifies the "completion code". We can find out what'' °
' '''this code is, merely by referencing C210'',r' 'show ''C210''' °
'''A code of 0 means that the control command has successfully opened' °
'' '''file TEST210.'',r' °
'''We may at this point wish to determine if a file by that name alrea °
dy''' °
'''exists. To do that, we merely would read a record from the file. We °
''' °
'''could also just write a new record into the file. In either case, w °
Xe''' '''must issue a CONTROL SUBCOMMAND.''' 'end' °
*(1996 4 14 12 11 10 268) °
FTEACH6 ÉFX 'TEACH6' 'Σ Control subcommands' °
'''CONTROL SUBCOMMANDS'',r' °
'''Whenever the Control Command is IR or IW, it must be followed by on °
e''' '''or more subcommands. These are of the form'',r' °
''' C210╜operation [,record number [,scan distance]]'',r' °
''' or using IBM abbreviations: C210╜op[,rn[,rs]]'',r' °
'''Unlike the control command, this assignment is numeric, and the val °
ues''' °
'''are positive integers. Here is a listing of available "operation"'' °
' '''codes:'',r' ''' OP MEANING DEFAULTS''' °
''' 0 Read fixed length record rn╜0 rs╜128 sequential read''' °
''' 1 Write fixed length record rn╜0 rs╜128 sequential write'' °
' ''' 2 Read direct record rn╜starting byte rs╜128''' °
''' 3 Write direct record rn╜starting byte rs╜128''' °
''' 4 Read variable length record (Depends on codes A or D)''' °
''' 5 Write variable length record " " " "'',r' °
'do' °
'''Let us assume that we have two APL2 variables we wish to store''' °
'''in file TEST210:'',r' °
'show ''ONE╜''''CHARACTER STRING'''''' ''TWO╜∞20''' °
'''Each step requires the following sequence:'',r' °
'show ''D210╜ONE'' ''C210╜5'' ''C210'' ''D210╜TWO'' ''C210╜5'' ''C210' °
X'' 'end' °
*(1996 4 14 12 11 22 316) °
FTEACH7 ÉFX 'TEACH7' 'Σ Control subcommand continued' °
'''Notice that each assignment to D210 must be followed by two control °
''' °
'''subcommands, one to specify the nature of the operation, and one to °
''' '''test the Return Code.''' 'do' °
'''At this point we can continue by verifying whether the information' °
'' °
'''been stored properly. Note that record numbers are in 0 index origi °
n.'',r' °
'show ''C210╜4 0'' ''C210'' ''D210'' ''C210╜4 1'' ''C210'' ''D210''' °
'''When reading a file, each reference to D210 must be preceeded by tw °
o''' °
'''control commands; one to specify the nature of the read operation, °
and''' '''one to test the Return Code.'',r' °
'''When a file is no longer to be used, it has to be closed. This is'' °
' °
'''done simply by assigning a null string to the control variable'',r' °
'show ''C210╜''''''''''' °
'''Once a a file has been closed, it is permissible to issue another'' °
' '''Control Command'',r' °
'show ''C210╜''''IR,C:\APL2\testXXX'''''' ''C210''' °
'''The Return Code 2 means that the named file does not exist. Had the °
''' °
'''Control Command started with IW, instead with IR, a new file named' °
X'' '''''''testXXX'''' would have been defined.''' 'end' °
*(1996 4 14 11 55 55 620) °
FTEACH8 ÉFX 'TEACH8' 'Σ Return Codes' '''RETURN CODES'',r' °
'''You are encouraged to practice different combinations of Control''' °
'''Commands and Subcommands. As you do, you will invariably get any on °
e''' °
'''of several non-zero Return Codes. You can find the meanings of thes °
e''' '''on page 216 of your APL2 USER''''S GUIDE.'',r' °
'''Once you become familiar with the usage of AP210, you may wish to'' °
' °
'''define your own functions to read and write specific file applicati °
ons.''' 'do' °
'''IBM supplies two workspaces named APLFILE and FILE. These invoke th °
e''' °
'''AP210 and support functions to OPEN, CLOSE, READ and WRITE records. °
''' °
'''It is entirely possible that these workspaces will satisfy many of' °
'' °
'''your requirements. In any case, you can use these workspaces (or''' °
'''functions within) as a basis for your own applications.'',r' °
'''Before we leave AP210, we should delete file TEST210. This can be'' °
' '''done with Control Command'',r' °
'show ''C210╜''''DL,TEST210'''''' ''C210''' °
'''and let us not forget to release the Shared Variable'',r' °
X 'show ''ÉSVR■ ''''C210'''' ''''D210''''''' 'TEACH8A' °
*(1996 4 14 12 11 53 440) °
FTEACH8A ÉFX 'TEACH8A;D;CMD' 'Σ Read the ASCII file APL2.CMD' °
'''You do not need to define your APL2 functions to access non-APL''' °
'''external files. IBM supplies workspace FILE in library 2, that''' °
'''contains just about any functionality that you are likely to need.' °
'' '''The workspace 2 FILES contains four groups of functions:'',r' °
''' AP 210 group''' ''' AP 211 group''' ''' Delta group''' °
''' Transfer group''' 'do' °
'''The AP 210 group contains functions that allow you to open, close a °
''' °
'''file, to read or write bytes or records, find file size, to compare °
''' °
'''two files, to display the contents of a file, to delete a file, and °
''' '''to rename a file.'',r' °
'''The AP 211 group deals with functions useful with AP 211, which wil °
l''' '''be discussed later.'',r' °
'''Right now it is the "Delta Group" that is of interest''' 'do' °
'''This group contains only two functions: ╢FM and ╢FV. Both functions °
''' °
'''are ambivalent. If the left argument is absent, these functions wil °
l''' °
'''read the contents of a file (specified in the right argument). If t °
he''' °
'''left argument is present, it must be a rank 2 character array. This °
''' °
'''array will be written to the file specified in the right argument.' °
'' 'do' °
'''As an example, consider loading into this workspace the APL2.CMD fi °
le''' °
'''listed on page 11 of the User''''s Guide. Your APL2OS2 may not resi °
de''' °
'''on drive C. Therefore, before proceeding with this exercise, you mu °
st''' '''specify this drive:'',r' °
'D╜╞(1 get '' ATTENTION! Enter the APL2OS2 drive (default is C:)'') °
,''C''' °
'''On the assumption that this file has the following address:'',r' °
'D,'':\APL2OS2\BIN\APL2.CMD'',r' °
'''its contents can be read into variable CMD'',r' °
'show ''CMD╜╢FM D,'''':\APL2OS2\BIN\APL2.CMD'''''' ''µCMD'' ''DISPLAY °
CMD''' °
'''Function ╢FM retrieved this file as a rank 2 character array.''' °
'''Function ╢FV will retrieve the same data as a nested vector of''' °
'''individual records from that file'',r' °
'show ''CMD╜╢FV D,'''':\APL2OS2\BIN\APL2.CMD'''''' ''µ■CMD'' ''DISPLAY °
2╞CMD''' 'do' °
'''NOTE: If you merely desire to edit an ASCII text file, you may do s °
o''' '''using the ")HOST" command. Enter'',r' °
''' )HOST apledit filename'',r' °
'''(replace the word "filename" by the address of the file to be edite °
Xd)''' 'end' °
*(1996 4 14 12 12 13 284) °
FTEACH9 ÉFX 'TEACH9;D211' 'Σ Auxilliary processor 211' °
'''AUXILLIARY PROCESSOR 211'',r' °
'''There are several features of AP210 that are inconvenient for certa °
in''' °
'''APL2 applications. For one, it may be necessary to know the content °
s''' °
'''of a file by record numbers. In APL, we are used to accessing data °
by''' °
'''name. With AP210, one has to know the file characteristics, while'' °
' °
'''in APL we are used to let the system do such book-keeping. For thos °
e''' °
'''of us who prefer to deal with files as if these were merely extensi °
ons''' '''of APL, there is AP211.''' 'do' °
'''Auxilliary Processor 211 supports ONLY one Shared Variable.'',r' °
'show ''211 SVOFFER ''''D211''''''' 'D211╜''DROP'' ''FUNCTION''' °
'''We can create a file, say FUNCTION with the following command'',r' °
'show ''D211╜''''CREATE'''' ''''FUNCTION'''''' ''D211''' °
'''Referencing D211 after making an assignment to it is ALWAYS a good' °
'' °
'''idea. The Return Codes can be found on p 220 of the USER''''S MANUA °
L.''' 'do' °
'''If you were to repeat this command, the return code would be a ²17' °
'' °
'''indicating that the file is already in use. The file created by''' °
'''CREATE will have fixed lenth records of 1024 bytes. (This can be''' °
'''changed by inserting an alternate value as a third element of the'' °
' '''CREATE assignment.)'',r' °
X ''' D211╜''''CREATE'''' filename record-size'',r' 'end' °
XNTHREE 2 3 3 1 2 3 4 5 6 7 8 9 °
XATWO╜1-ÉIO-∞20 °
XCa 0 % °
*(1991 11 11 8 26 35 408) °
Faddquote ÉFX 'u╜addquote w' °
'Σ Put quotes around a string, and double existing quotes' °
X 'u╜ÉAV[40],((1+w=ÉAV[40])/w),ÉAV[40]' °
*(1992 5 6 8 49 44 496) °
Fans ÉFX 'U╜V ans W;A;R;T' 'Σ Respond to an inquiry' °
'T╜(0=ÉNC ''V'')doif ''V╜'''' ''''''' '╕(0⌠1╞0╞εV)/L0' ''' '',W' °
'U╜É' '╕(0╧V)/0' 'U╜VµU' '╕0' 'L0:T╜(1<╧V)doif ''R╜1╟V'' ''V╜╞V''' °
'æ╜A╜'' '',W,V' 'U╜(µA)╟æ' '╕(~T)/0' °
X '╕((0=╞0╞R)doif ''U╜RµU,'''' '''''')/0' 'U╜π(U⌠R)ΓU' °
*(1991 11 11 8 26 35 408) °
XFaq ÉFX 'u╜aq w' 'Σ Enclose quoted string' 'u╜Γaddquote w' °
*(1991 11 11 8 26 35 408) °
Fav ÉFX 'av;a;n;i;ÉIO' 'Σ Display characters in the Atomic vector' °
'ÉIO╜0' 'a╜22 78µ'' ''' 'n╜3 0«φ12 22µ1+∞256' °
'a[;,(6⌡∞12)°.+2 3 4]╜n' 'a[;6+6⌡∞12]╜φ12 22µÉAV' °
X 'a[7 8 10 13;6]╜'' ''' 'a[14+∞8;68 69 70 72]╜'' ''' 'a' °
*(1996 4 7 14 15 40 384) °
Fcopyright ÉFX 'copyright' 'Σ Copyright statement' °
'(10µ'' ''),''Copyright, Z. V. Jizba, 1995'',r' °
'''To see disclaimers, enter ÉCR ''''copyright''''''' 'do' '╕0' °
'''This and subsequent workspaces labelled TEACHxx are made available' °
'' °
'''at no cost to anyone who desires to learn how to use effectively''' °
'''the IBM/OS2 version of APL2.'',r' °
'''This software is provided "AS IS" with no WARRANTY of any kind, eit °
her''' °
'''express or implied. Any risk in its use resides with you, the user °
Xof''' '''these tutorials.''' '''(PRESS ENTER to continue)''' °
XCd 0 " °
*(1991 11 11 8 26 37 416) °
Fdate ÉFX 'u╜date w' 'Σ Format date and time of day' 'u╜«6╞w' °
X 'u╜('' ''⌠u)Γu' 'u╜εu,■''-- .. ''' °
XCdig 1 10 1234567890 °
*(1991 11 11 8 26 34 404) °
Fdo ÉFX 'do;t;e;b' 'Σ Expression driver' 'e╜''''' 'æ╜'' ''' 't╜æ' °
'╕(^/'' ''=t)/0' °
'╕(('':''εt)doif ''b╜evaldd (+/^\'''' ''''=t)╟t'')/2' °
'''e╜ÉEM'' ÉEA t' '╕(0=µ,e)/2' °
'''This is not a valid APL2 expression''' 'æ╜''*''' '╕(''?''⌠╞1╟æ)/2' °
X 'e' '╕2' °
*(1991 11 11 8 26 34 404) °
Fdoif ÉFX 'U╢╜V╢ doif W╢;t╢' 'Σ Rule' '╕(^/~U╢╜V╢)/0' °
X '''U╢╜V╢ doif■ W╢'' ÉEA ''»V╢/W╢''' °
XNdos 0 ²26 °
XCe 1 0 °
*(1996 3 31 14 34 39 548) °
Fend ÉFX 'end' '''²²''' 'e╜''''' 'æ╜'' ''' 't╜æ' '╕(^/'' ''=t)/0' °
'╕(('':''εt)doif ''b╜evaldd (+/^\'''' ''''=t)╟t'')/3' °
'''e╜ÉEM'' ÉEA t' '╕(0=µ,e)/0' °
'''This is not a valid APL2 expression''' 'æ╜''*''' '╕(''?''⌠╞1╟æ)/0' °
X 'e' °
*(1991 11 11 8 26 35 408) °
XFendd ÉFX 'endd' 'Σ End of document' '20µ''²''' 'do' °
*(1995 10 8 13 54 41 564) °
Ferase ÉFX 'erase;t;DISPLAY;OS2;GO;PROFILE;SVOFFER;SVOPAIR;╢FM;╢FV' °
't╜ÉNL 3' 't╜(~t^.εlc,'' '')≡t' 't╜ÉEX(~t[;∞5]^.=''TEACH'')≡t' °
X 't╜ÉNL 2' 't╜ÉEX(~t^.εlc,'' '')≡t' 't╜ÉNL 4' 't╜ÉEX(~t^.εlc,'' '')≡t' °
*(1991 11 11 8 26 36 412) °
Fevaldd ÉFX 'u╜evaldd w;c;n' °
'Σ Evaluate a direct definition expression' 'u╜0' 'n╜(w∞''Σ'')-1' °
'c╜(((n╞w)⌠'':'')Γn╞w),Γ''ΣDD '',(n+1)╟w' '╕(label╞c)/0' °
'╕((2=µc)doif ''u╜showdd 1╙c'')/0' °
'╕((3=ÉNC╞c)doif ''u╜⌡µÉ╜(╞c),'''' is already defined.'''''')/0' °
'╕((3=µc)doif ''u╜simdd c'')/0' 'c╜(Γ''α∙ aw'')replace■c' °
'u╜ε''u╜'',((''a''εεc[2 3 4])/''a ''),(╞c),'' w;t;b''' °
'u╜u(5πc)(''b╜(t╜'',(3πc),'')/'',addquote ''u╜'',4πc)' °
X 'u╜u,''╕(t doif b)/0''(''u╜'',2πc)' 'u╜╧ÉFX u' °
*(1991 11 11 8 26 36 412) °
Fexit ÉFX 'exit w' 'Σ Exit if there are too many suspended functions' °
X '╕((10>µÉLC)doif ''w'')/0' '''Please re-enter '',w' '╕' °
XCf 1 2 { °
XCg 1 2 } °
*(1996 4 18 14 22 21 380) °
Fget ÉFX 'u╜v get w;t' 'Σ Prompt for response from keyboard' °
't╜(0=ÉNC ''v'')doif ''v╜1''' 'w╜w,(~²1╞v)/'': ''' 'L0:æ╜w' 't╜æ' °
'╕((''╕''=(µw)╟t)doif ''╕'')/0' '╕(^/'' ''=w)/L1' °
'Σ ╕((~w╧(µw)╞t)doif ''''''PLEASE DO NOT BACKSPACE'''''')/L0' °
't╜(µw)╟t' 'L1:u╜(²1+(,'' ''⌠t)∞1)╟t' '╕(1╞v)/0' 't╜(u⌠'' '')Γu' °
X 'u╜(µt),(Γu),t' °
*(1991 11 11 8 26 36 412) °
Fglobals ÉFX 'globals' 'Σ Initialize useful global variables' 'r╜2╙ÉTC' °
'q╜40╙ÉAV' 's╜Φp╜'' '',d╜35╙ÉAV' 'uc╜''ABCDEFGHIJKLMNOPQRSTUVWXYZ''' °
'lc╜''abcdefghijklmnopqrstuvwxyz''' 'dig╜''1234567890''' °
X 'g╜'' '',h╜126╙ÉAV' 'f╜ÉAV[33 124]' 'a╜38╙ÉAV' °
XCh 0 } °
*(1996 4 9 13 38 53 532) °
Fhelp ÉFX 'help' °
'''If you feel that a single linear reading of these lessons is not th °
e''' °
'''best way to learn about APL2OS2, you may try to do the following.'' °
,r' '''1. At any pause enter: ÉCR ''''TEACH''''''' °
''' (a listing of the components of the tutorial workspace will appe °
ar)''' °
'''2. Jot down the names that appear in UPPER CASE --mostly TEACHxx--' °
'' °
'''3. Each of these is a component of the lesson that can be invoked'' °
' °
''' at the pause simply by entering its name. This will repeat that' °
'' °
''' portion of the tutorial. The completion of each portion is marke °
Xd''' ''' by a line containing ²².''' 'end' °
*(1991 11 11 8 26 36 412) °
Finitialize ÉFX 'initialize;t' 'Σ Initialize workspace' 'erase' °
X 'globals' °
*(1991 11 11 8 26 35 408) °
Fkeys ÉFX 'keys' 'Σ Display keyboard' °
''' 1 2 3 4 5 6 7 8 9 0 + ⌡''' °
'''SHFT ╒ ■ ² < ≤ = ≥ > ⌠ δ ^ - ÷''' °
'''ALT ╘ ƒ · ⁿ √ Φ φ Θ ╡ τ σ ! Æ''' '''''' °
''' Q W E R T Y U I O P ╜ ╙ ╧''' °
'''SHFT ? ∙ ε µ ~ ╞ ╟ ∞ Ω * ╕ ╨ ╤''' °
'''ALT q w e r t y u i o p æ ≈ ╥''' °
'''CTRL ┌ ┬ ┐ ╔ ╦ ╗''' '''''' °
''' A S D F G H J K L [ ]''' °
'''SHFT α ⌐ ╛ _ ╖ ╢ ° '''' É ( )''' °
'''ALT a s d f g h j k l » «''' °
'''CTRL ├ ┼ ┤ ─ ═ ╠ ╬ ╣''' '''''' °
''' Z X C V B N M , . /''' °
'''SHFT Γ π ∩ ¼ ¥ ÿ | ; : \''' °
'''ALT z x c v b n m Σ ± ≡''' °
'''CTRL └ ┴ ┘ │ ║ ╚ ╩ ╝''' '''''' °
X '''Toggle switch to ASCII is CTL-BACKSPACE''' '''CTRL+G gives beep''' °
*(1991 11 11 8 26 36 412) °
Flabel ÉFX 'u╜label w' °
'Σ Return 1 if w is not a valid character string label (also excludes °
Xl.c.)' '╕(u╜(1<µµw)δ1<╧w)/0' '╕(u╜~^/wεlc,uc,dig)/0' 'u╜w[1]εlc,dig' °
XClc 1 26 abcdefghijklmnopqrstuvwxyz °
*(1991 11 11 8 26 36 412) °
Fnon ÉFX 'non;t;rc;et;r' °
'Σ Ignore invalid keyboard entries, but evaluate valid APL2 expression °
s' 'æ╜'' ''' 't╜æ' '╕(0=µ(t⌠'' '')/t)/0' '(rc et r)╜ÉEC t' °
X '╕(0=rc)/2' '╕((1=rc)doif ''r'')/2' '╕2' °
*(1991 11 11 8 26 36 412) °
Fnotb ÉFX 'u╜notb w' 'Σ Remove trailing blanks' °
'╕((1<╧w)doif ''u╜notb■ w'')/0' '╕((1<µµw)doif ''u╜πnotb Γ[2]w'')/0' °
X 'u╜(1-(,'' ''⌠Φw)∞1)╟w' °
XCp 1 2 " °
*(1991 11 11 8 26 36 412) °
Fpause ÉFX 'v pause w;t' °
'Σ Pause, then print w v spaces right and return' °
X 't╜(0=ÉNC ''v'')doif ''v╜6''' 'do' '(vµ'' ''),w' 'do' °
XCq 0 ' °
XCr 0 °
*(1991 11 11 8 26 36 412) °
Freplace ÉFX 'u╜v replace w;i;r;s' 'Σ Replace elements in v in w' °
'i╜Γ∞µu╜w' 's╜2πv╜(v⌠'' '')Γv' 'i╜⌡r╜i⌡■Γ[1]w°.=╞v' °
X 'u[(εi)/εr]╜s[(εi)/εi⌡■∞µs]' °
*(1991 11 11 8 26 37 416) °
Fround ÉFX 'u╜v round w' 'Σ Half adjust w to vth decimal' °
X 'u╜(╛0.5+w⌡10*v)÷10*v' °
XCs 1 2 " °
*(1991 11 11 8 26 37 416) °
Fshow ÉFX '╢v show ╢w;╢t;╢b' 'Σ Display and execute ╢w' °
'╢t╜(0=ÉNC ''╢v'')doif ''╢v╜0''' °
'╕((0=╧╢w)doif ''show ╢w,'''' '''''')/0' °
'╕((1<╧╢w)doif ''╢v show■ ╢w'')/0' ''' '',╢w' °
X '╕((╢v^'':''ε╢w)doif ''╢t╜evaldd ╢w'')/L0' '''ÉEM'' ÉEA ╢w' 'L0:do' °
*(1991 11 11 8 26 37 416) °
Fshowdd ÉFX 'u╜showdd w;a;b;c;r' °
'Σ Display a direct definition function' °
'╕((1=╧w)doif ''u╜showdd Γw'')/u╜0' °
'╕((3⌠ÉNC╞w)doif ''(ε╞w),'''' is not a function'''''')/0' °
'c╜Γ[2]ÉCR╞w' 'c╜notb(2╞c),(Γ''aw α∙'')replace■2╟c' °
'╕((~''ΣDD''╧3╞2πc)doif ''''''Not a direct definition function'''''')/ °
0' 'u╜1' 'b╜('' ''⌠╞c)Γ╞c' 'a╜'' ''' 'r╜2╟3πc' °
'╕((3=µc)doif ''a,(╞w),'''':'''',r,(3<µ2πc)/'''' Σ'''',3╟2πc'')/0' °
'a╜a,(╞w),'':'',(2╟5πc),'':''' 'b╜(+\r=''('')-+\r='')''' 'b╜b∞0' °
X 'a╜a,(²3╟(b-1)╞3╟r),'':'',2╟»(b+2)╟r' 'a,(3<µ2πc)/'' Σ'',3╟2πc' °
*(1991 11 11 8 26 37 416) °
Fshowfn ÉFX 'u╜v showfn w;f;n;t;ÉIO' 'Σ Simulate the STSC ÉVR command' °
't╜(0=ÉNC ''v'')doif ''v╜0''' 'ÉIO╜0' °
'u╜r,'' '',''╖'',w,''[É]'',(╞v)╞''╖''' 'n╜1╞µf╜ÉCR w' 'n╜«∞n' °
'n╜(n⌠'' '')Γn' 'f╜(π''['',■n,■Γ''] ''),f' °
't╜(1<µ,v)doif ''f╜f[1╟v;]'' ''u╜''''''''''' 'u╜²1╟u,r,,f,r' °
X 'u╜((-+/^\'' ''=Φu)╟u),('' ''(r,'' ╖'',date 2 ÉAT w))[╞v],r' °
*(1991 11 11 8 26 37 416) °
Fsimdd ÉFX 'u╜simdd w;e' 'Σ Simple direct definition mode' 'u╜0' °
'╕((0⌠ÉNC╞w)doif ''''''Already defined'''''')/0' 'e╜''α''ε2πw' °
'w[2]╜Γ''u╜'',''α∙ aw'' replace 2πw' 'w╜w[1 3 2]' °
X 'w[1]╜Γε''u╜'',(e/''a ''),w[1],'' w''' 'u╜╧ÉFX w' °
*(1995 10 2 13 45 46 524) °
Fsvopair ÉFX 'DC╜PID svopair SV;CV' 'SV╜(²2╞1 1,µSV)µSV╜πSV' °
'╕(2=ÉNC ''PID'')/DYADIC' 'DC╜ÉSVO SV' '╕0' 'DYADIC:' °
'CV╜(-+/^\ΦSV='' '')ΦSV' 'CV╜(-+/^\ΦCV⌠'' '')ΦCV' 'CV╜CV[;ÉIO]=''C''' °
'╕(1^.⌠CV/DC╜PID ÉSVO SV)/END' 'ÉSVE╜15' 'CHECK:' °
'╕(1^.⌠CV/DC╜ÉSVO SV)/END' '╕(0⌠ÉSVE)/CHECK' 'END:' °
X 'CV╜1 0 1 0 ÉSVC CV≡SV' °
XCt 1 7 °
XCuc 1 26 ABCDEFGHIJKLMNOPQRSTUVWXYZ °
*(1995 10 8 14 0 19 264) °
F╢FM ÉFX 'R╜A ╢FM B;E;F;G;H;I;J;TC;ÉIO;C╢F;D╢F' °
'Σ Emulation of APL2/370 ╢FM built-in function using AP210' °
'Σ Licensed Materials - Property of IBM' 'ÉIO╜0' °
'(G H)╜210 ÉSVO■''C╢F'' ''D╢F''' 'ÉSVE╜15' 'SVCHECK:' °
'(G H)╜ÉSVO■''C╢F'' ''D╢F''' '╕((G=2)^(H>0))/SVOK' °
'╕(0⌠ÉSVE)/SVCHECK' '╕LB' 'SVOK:' 'G╜1 0 1 0 ÉSVC ''C╢F''' 'G╜0' °
'H╜32768' '╕(0=ÉNC ''A'')/LA' 'C╢F╜''DL,'',B' '╕(^/0 2⌠╞E╜C╢F)/LC' °
'╕((δ/1 2=µµA)^0=⌡/µA)/LC' 'C╢F╜''IW,'',B,'',D''' '╕(0⌠╞E╜C╢F)/LC' °
'D╢F╜''A''' 'C╢F╜5' '╕(0⌠╞E╜C╢F)/LC' 'C╢F╜4 0' '╕(0⌠╞E╜C╢F)/LC' °
'TC╜1╟D╢F' '╕((3≤µE),(2=╧A)^1=µE╜µA)/LJ,LI' 'I╜A,╞TC' °
'»(2=µTC)/''I╜I,╞1╟TC''' 'I╜,I' '╕LO,B╜A╜''''' 'LI:B╜∞µF╜2+╞■µ■A' °
'LN:E╜1⌐+/H≥+\F' 'I╜εA[E╞B],■ΓTC' 'B╜E╟B' 'F╜E╟F' 'LO:D╢F╜(J╜H╛µI)╞I' °
'C╢F╜3,G,J' '╕((8=╞E),0⌠╞E╜C╢F)/LG,LC' 'G╜G+J' '╕(H≥µI)/LF' °
'╕LO,µI╜H╟I' 'LF:╕(0⌠µB)/LN' '╕0,R╜C╢F,C╢F╜∞0' °
'LA:C╢F╜''IR,'',B,'',D''' '╕(0⌠╞E╜C╢F)/LC' '╕(0⌠B╜D╢F)/LMO' °
'╕0,0µR╜0 0µ''''' 'LMO:R╜''''' 'J╜ÉTC[2]' 'LE:C╢F╜2,G,H╛B' °
'╕((8=╞E),0⌠╞E╜C╢F)/LG,LC' 'F╜(+\0+ÉTC[2]=J)ΓJ╜J,D╢F' 'J╜╞²1╞F' °
'R╜R,1╟■(-B>H)╟F' '╕(0≥B╜B-H)/LX' '╕LE,G╜G+H' °
'LX:R╜(-(ÉAF 26)=╞╞²1╞R)╟R' 'R╜(-0=µ╞²1╞R)╟R' 'R╜(-ÉTC[1]=²1╞■R)╟■R' °
'R╜πR' '╕0' 'LG:╕(H=128)/LC' '╕((LO,LE)[0=ÉNC ''A'']),H╜128⌐⌐H÷2' °
X 'LB:ÉES ''AP210 share offer failed''' 'LJ:ÉES 5 2' 'LC:╕0,R╜E' °
*(1994 4 21 21 0 0 240) °
F╢FV ÉFX 'R╜A ╢FV B;E;F;G;H;I;J;TC;ÉIO;C╢F;D╢F' °
'Σ Emulation of APL2/370 ╢FV built-in function using AP210' 'Σ' °
'Σ Licensed Materials - Property of IBM' °
'Σ 5621-430, 5648-065, 5765-012 (c) Copyright IBM Corp. 1983, 1994.' °
'Σ' 'Σ A is optional and if omitted the file will be read.' °
'Σ A if included defines the CHARACTER data to be written.' °
'Σ B has the syntax [/path/]filename' 'ÉIO╜0' °
'(G H)╜210 ÉSVO■''C╢F'' ''D╢F'' Σ Offer a pair of variables' °
'ÉSVE╜15 Σ Wait up to 15 seconds for accep °
ts' 'SVCHECK:' °
'(G H)╜ÉSVO■''C╢F'' ''D╢F'' Σ Check degree of coupling' °
'╕((G=2)^(H>0))/SVOK Σ Out of loop if shared' °
'╕(0⌠ÉSVE)/SVCHECK Σ Retry if time left' °
'╕LB Σ Out of time, quit' 'SVOK:' °
'G╜1 0 1 0 ÉSVC ''C╢F'' Σ Set access control' °
'G╜0 Σ Initialise file pointer' °
'H╜32768 Σ Record size (may be reduced)' °
'╕(0=ÉNC ''A'')/LA' °
'C╢F╜''DL,'',B Σ Delete existing file if any' °
'╕(^/0 2⌠╞E╜C╢F)/LC' °
'╕((δ/1 2=µµA)^0=⌡/µA)/LC Σ Check for something to write' °
'C╢F╜''IW,'',B,'',D'' Σ Open new file' '╕(0⌠╞E╜C╢F)/LC' °
'D╢F╜''A'' Σ Write a single variable record' 'C╢F╜5' °
'╕(0⌠╞E╜C╢F)/LC' 'C╢F╜4 0 Σ Read it back' °
'╕(0⌠╞E╜C╢F)/LC' °
'TC╜1╟D╢F Σ Capture the line terminators (CR/LF or LF) °
' '╕((3≤µE),(2=╧A)^1=µE╜µA)/LJ,LI' °
'E╜'' ''=,²1╞[1]A╜(²2╞1 1,µA)µA Σ Check for any trailing blanks to rem °
ove' 'I╜A,╞TC Σ Append line terminator to each row' °
'»(2=µTC)/''I╜I,╞1╟TC'' Σ Append another if there are two' °
'I╜,I Σ Make into a simple vector' '╕(~δ/E)/LH' °
'I╜(,(~E±Φ^\'' ''=ΦA[E/∞╞µA;]),((╞µA),µTC)µ1)/I Σ Remove trailing blan °
ks' 'LH:╕LO,B╜A╜''''' °
'LI:╕(~δ/E╜'' ''=ε²1╞■A)/LD Σ Check for any trailing blanks to remove °
' 'E╜E/∞µE Σ Convert to indices' °
'LL:A[╞E]╜Γ(-('' ''=ΦF)∞0)╟F╜,(╞E)πA Σ Remove trailing blanks' °
'╕(0⌠µE╜1╟E)/LL' 'LD:B╜∞µF╜2+╞■µ■A' °
'LN:E╜1⌐+/H≥+\F Σ Number of items that will fit in record (minimum °
of 1)' °
'I╜εA[E╞B],■ΓTC Σ Append line terminators to each item' °
'B╜E╟B' 'F╜E╟F' 'LO:D╢F╜(J╜H╛µI)╞I' 'C╢F╜3,G,J' °
'╕((8=╞E),0⌠╞E╜C╢F)/LG,LC' °
'G╜G+J Σ Increment file pointer' °
'╕(H≥µI)/LF Σ Check if all of this data has been written °
' '╕LO,µI╜H╟I' 'LF:╕(0⌠µB)/LN' °
'╕0,R╜C╢F,C╢F╜∞0 Σ Close the file and exit' °
'LA:C╢F╜''IR,'',B,'',D'' Σ Open file for read' '╕(0⌠╞E╜C╢F)/LC' °
'╕(0⌠B╜D╢F)/LMO Σ Is file empty?' °
'╕0,R╜0µΓ'''' Σ File empty return an empty vector' °
'LMO:R╜''''' 'J╜ÉTC[2]' 'LE:C╢F╜2,G,H╛B' '╕((8=╞E),0⌠╞E╜C╢F)/LG,LC' °
'F╜(+\0+ÉTC[2]=J)ΓJ╜J,D╢F Σ Split each record into component vectors' °
'J╜╞²1╞F Σ Store last (incomplete) item' °
'R╜R,1╟■(-B>H)╟F' '╕(0≥B╜B-H)/LX' °
'╕LE,G╜G+H Σ Increment file pointer' °
'LX:R╜(-(ÉAF 26)=╞╞²1╞R)╟R Σ Remove EOF record (if there)' °
'R╜(-0=µ╞²1╞R)╟R Σ Remove last empty record' °
'R╜(-ÉTC[1]=²1╞■R)╟■R Σ Remove CR''s if present' °
'╕(~δ/E╜'' ''=ε²1╞■R)/0 Σ Check for any trailing blanks to remove' °
'E╜E/∞µE Σ Convert to indices' °
'LM:R[╞E]╜Γ(-('' ''=ΦF)∞0)╟F╜,(╞E)πR Σ Remove trailing blanks' °
'╕(0⌠µE╜1╟E)/LM' '╕0' 'LG:╕(H=128)/LC' °
'╕((LO,LE)[0=ÉNC ''A'']),H╜128⌐⌐H÷2 Σ Halve record length' °
'LB:ÉES ''AP210 share offer failed''' °
X 'LJ:ÉES 5 2 Σ Rank error' 'LC:╕0,R╜E' °