home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / teachapl.zip / teach51.zip / TEACH51.ATF
Text File  |  1996-10-09  |  70KB  |  852 lines

  1. XNÉIO 0 1                                                                      °
  2. XNÉCT 0 1.000000000000011E²13                                                  °
  3. XCÉFC 1 6 .,*0_²                                                               °
  4. XNÉRL 0 1106878668                                                             °
  5. XCÉPR 0                                                                        °
  6. XCÉLX 1 5 TEACH                                                                °
  7. *(1996 9 9 20 1 53 432)                                                        °
  8.  FCOLRS ÉFX 'V COLRS W;A;B;C;M;R;S;T' 'Σ Test colors, mix and patterns'        °
  9.   '╕(2=ÉSVO ''D207'')/L2 ╪ T╜ÉSVR ''D207'' ╪ T╜open ''COLORS, MIX and PA       °
  10.  TTERNS''' 'L2:T╜(0=ÉNC ''V'')doif ''V╜0''' 'S╜100 480'                        °
  11.   'L0:╕(0=µ,W)/L1' 'C╜2╞(╞W) ╪ A╜S,50 50 0 360'                                °
  12.   'D207╜''MIX''(╞V)''COLOR''(1╙C)''PATTERN''(2╙C) ╪ T╜test'                    °
  13.   'D207╜''BEGAREA'' '''' ''ARC'' A ''ENDAREA'' '''' ╪ T╜test'                  °
  14.   'D207╜''color'' ''black'' ''arc'' A ╪ T╜test' 'S╜S+40 ²15'                   °
  15. X 'V╜1ΦV ╪ W╜1╟W' '╕L0' 'L1:D207╜''view'' ''''' 'T╜æ'                          °
  16. *(1992 2 29 8 32 29 448)                                                       °
  17.  FDISPLAY ÉFX 'D╜S DISPLAY A;ÉIO;R;C;HL;HC;HT;HB;VL;VB;V;W;N;B'                °
  18.   'Σ DISPLAY A GENERAL ARRAY IN PICTORIAL FORM'                                °
  19.   'Σ  NORMAL CALL IS MONADIC.  DYADIC CALL USED ONLY IN'                       °
  20.   'Σ    RECURSION TO SPECIFY DISPLAY RANK, SHAPE, AND DEPTH.' 'ÉIO╜0'          °
  21.   '»(0=ÉNC ''S'')/''S╜µA''' 'R╜╞µ,S                   Σ PSEUDO RANK.'          °
  22.   'C╜''┐┌└┘''                 Σ UR, UL, LL, AND LR CORNERS.'                   °
  23.   'HL╜''─''                   Σ HORIZONTAL LINE.'                              °
  24.   'HC╜HL,''Θ╕'',HL,''~+ε''      Σ HORIZONTAL BORDERS.'                         °
  25.   'HT╜HC[(0<R)⌡1+0<╞²1╞,S]' 'ΣW╜,0╧■╞0µΓ(1⌐µA)╞A'                              °
  26.   'HB╜HC[3+3╛(''2⌡~A╧«A'' ÉEA ''1+╞ε0⌡(1⌐⌡/µA)╞,A'')+3⌡1<µµS]'                 °
  27.   'VL╜''│''                   Σ VERTICAL LINE.'                                °
  28.   'VB╜VL,''Φ╟''               Σ VERTICAL BORDER.'                              °
  29.   'V╜VB[(1<R)⌡1+0<²1╞²1╟,S]'                                                   °
  30.   '»(0εµA)/''A╜(1⌐µA)µΓ╞A''   Σ SHOW PROTOTYPE OF EMPTIES.'                    °
  31.   '╕(1<╧A)/GEN' '╕(2<µµA)/D3'                                                  °
  32.   'D╜«A                     Σ SIMPLE ARRAYS.' 'W╜1╞µD╜(²2╞1 1,µD)µD'           °
  33.   'N╜²1+1╟µD' '╕(0=µµA)/SS'                                                    °
  34.   'D╜(C[1],V,((W-1)µVL),C[2]),((HT,NµHL),[0]D,[0]HB,NµHL),C[0],(WµVL),C[       °
  35.  3]' '╕0' 'SS:HB╜((0 '' '')=╞0µΓA)/'' -'''                                     °
  36.   'D╜'' '',('' '',[0]D,[0]HB,Nµ'' ''),'' ''' '╕0'                              °
  37.   'GEN:D╜«DISPLAY■A          Σ ENCLOSED ...' 'N╜Dδ.⌠'' '''                     °
  38.   'D╜(Nδ~1ΦN)≡D' 'D╜(δ≡~''  ''╤D)/D' 'D╜((1,µS)µS)DISPLAY D'                   °
  39.   '╕(2≥µ,S)╟D3E,0' 'D3:D╜0 ²1╟0 1╟«ΓA         Σ MULT-DIMENSIONAL ...'          °
  40.   'W╜1╞µD' 'N╜²1+1╟µD'                                                         °
  41.   'D╜(C[1],V,((W-1)µVL),C[2]),((HT,NµHL),[0]D,[0]HB,NµHL),C[0],(WµVL),C[       °
  42.  3]' 'D3E:N╜²2+µ,S'                                                            °
  43. X 'V╜C[Nµ1],[0]VB[1+0<²2╟,S],[0](((²3+╞µD),N)µVL),[0]C[Nµ2]' 'D╜V,D'           °
  44. *(1992 8 14 10 7 40 364)                                                       °
  45.  FDOS ÉFX 'DOS W;T;D100;D2' 'Σ Simulation of DOS prompt'                       °
  46.   'T╜100 ÉSVO ''D100'''                                                        °
  47.   'T╜(2⌠ÉSVO ''D100'')doif ''''''AP100.COM'''' opentwo 1'' ''T╜100 ÉSVO        °
  48.  ''''D100''''''' '╕((0<µ(W⌠'' '')/W)doif ''D100╜W'')/0' 'L0:æ╜''C:>'''         °
  49. X '╕(^/'' ''=T╜3╟æ)/0' 'D100╜T' '╕L0'                                          °
  50. *(1992 2 29 8 32 30 452)                                                       °
  51.  FGO ÉFX 'GO;b;e;t' 'Σ Expression driver' 'L0:b╜e╜''''' 'æ╜''       '''        °
  52.   't╜æ' '╕(^/'' ''=t)/L0' '╕((^/'')OFF ''=5╞6╟t)doif ''exit'')/0'              °
  53.   '╕(('':''εt)doif ''b╜evaldd (+/^\'''' ''''=t)╟t'')/L0'                       °
  54.   '''e╜ÉEM'' ÉEA t' '╕(0=µ,e)/L0' '╕b/L0'                                      °
  55.   '''This is not a valid APL2 expression''' 'æ╜''*'''                          °
  56. X '╕(''?''⌠╞1╟æ)/L0' 'e' '╕L0'                                                 °
  57. XNN 1 16 7 9 12 13 10 11 14 8 15 1 4 5 2 3 6 0                                 °
  58. *(1996 8 13 14 8 5 256)                                                        °
  59.  FPAL ÉFX 'PAL;A;B;C;S;T' 'Σ Test colors in palette'                           °
  60.   '╕(2=ÉSVO ''D207'')/L1 ╪ T╜ÉSVR ''D207'' ╪ T╜open ''COLOR PALETTE'''         °
  61.   'L1:S╜60 420 ╪ C╜colors' 'L0:D207╜''COLOR''(╞C) ╪ A╜S,50 50 0 360'           °
  62.   'D207╜''BEGAREA'' '''' ''ARC'' A ''ENDAREA'' '''' ╪ T╜test'                  °
  63.   'D207╜''MOVE''(S-20 80)''COLOR'' ''BLACK'' ''WRITE''(╞C)''arc'' A ╪ T╜       °
  64. Xtest' 'S╜S+40 ²15' '╕(0<µC╜1╟C)/L0' 'D207╜''view'' ''''' 'T╜æ'                °
  65. *(1996 9 12 19 38 25 476)                                                      °
  66.  FPALCOLS ÉFX 'V PALCOLS W;P;R;S;T'                                            °
  67.   'Σ Display palette and color map table colors' 'S╜100 480 ╪ C╜colors'        °
  68.   '╕(0=ÉNC ''M'')/0 ╪ ╕(0⌠ÉNC ''V'')/L0 ╪ V╜1'                                 °
  69.   'L0:D207╜''COLMAP''(V,M[W;]) ╪ T╜test'                                       °
  70.   'L1:D207╜''COLOR''(╞C) ╪ A╜S,50 50 0 360'                                    °
  71.   'D207╜''BEGAREA'' '''' ''ARC'' A ''ENDAREA'' '''' ╪ T╜test'                  °
  72.   'D207╜''COLOR'' ''BLACK'' ''arc'' A ╪ T╜test' 'S╜S+40 ²15'                   °
  73.   '╕(0<µC╜1╟C)/L1'                                                             °
  74.   'D207╜''MOVE''(100 50)''WRITE''(ε''Note changes in '',colors[V+1],''('       °
  75. X',(«M[W;]),'')'')' 'D207╜''view'' ''''' 'æ'                                   °
  76. *(1995 4 23 14 14 6 304)                                                       °
  77.  FSVOFFER ÉFX 'DC╜PID SVOFFER SV' 'SV╜(²2╞1 1,µSV)µSV╜πSV'                     °
  78.   '╕(2=ÉNC ''PID'')/DYADIC' 'DC╜ÉSVO SV ╪ ╕0'                                  °
  79.   'DYADIC:╕(1^.⌠DC╜PID ÉSVO SV)/END' 'ÉSVE╜15'                                 °
  80.   'CHECK:╕(1^.⌠DC╜ÉSVO SV)/END' '╕(0⌠ÉSVE)/CHECK'                              °
  81. X 'END:SV╜1 0 1 0 ÉSVC SV'                                                     °
  82. *(1996 9 19 17 35 57 612)                                                      °
  83.  FTEACH ÉFX 'TEACH' 'Σ Copyright Z V Jizba 1991; all rights reserved'          °
  84.   'copyright' 'initialize' 'warning' 'do' 'TEACH1  Σ Using colors'             °
  85.   'TEACH2  Σ The command COLMAP (PALETTE)'                                     °
  86.   'TEACH3  Σ Changing colors of the COLOR MAP TABLE'                           °
  87.   'TEACH4  Σ The COLOR and CLEAR commands'                                     °
  88.   'TEACH5  Σ Modyfying the COLOR MAP' 'TEACH6  Σ The command MIX'              °
  89.   'TEACH7  Σ Logical operations on colors; the AND option'                     °
  90.   'TEACH8  Σ Using the OR option to modify overlapping colors'                 °
  91. X 'TEACH9  Σ Erasing graphs using the Exclusive OR option'                     °
  92. *(1996 10 3 13 45 36 492)                                                      °
  93.  FTEACH1 ÉFX 'TEACH1' 'Σ Using color' '''USING COLOR'',r'                      °
  94.   '''In the previous lessons we learned how to draw lines, how to write'       °
  95.  ''                                                                            °
  96.   '''text on the screen, and how to fill out areas with selected pattern       °
  97.  s.'''                                                                         °
  98.   '''All the examples up to now have produced displays in black and whit       °
  99.  e.'''                                                                         °
  100.   '''We will now study those commands that will produce colors.'',r'           °
  101.   '''There are three basic colors: RED, GREEN and BLUE. The color that o       °
  102.  ne'''                                                                         °
  103.   '''sees on the screen is a combination of these three colors. This mix       °
  104.  '''                                                                           °
  105.   '''of colors is determined by a set of three values (integers in the''       °
  106.  '                                                                             °
  107.   '''range of 0 to 1000). For example 1000 0 0 represents the most inten       °
  108.  se'''                                                                         °
  109.   '''color RED. Similarly 0 1000 0 would represent the purest GREEN.'''        °
  110.   '''In the past, only two colors were used (0 0 0) and (1000 1000 1000)       °
  111.  . The''' '''first one of these is BLACK, and the second is WHITE.'''          °
  112.   'do'                                                                         °
  113.   '''Colors can be represented by these integer triplets, or by color'''       °
  114.   '''names. The AP207 supports 18 specific color names. BACKGROUND and''       °
  115.  '                                                                             °
  116.   '''NEUTRAL are synonyms. The remaining 16 names make up the COLOR MAP.       °
  117.  '',r'                                                                         °
  118.   ''' BACKGROUND   BROWN     DCYAN   DGMAGENTA      GREEN      RED'''          °
  119.   '''      BLACK    CYAN     DGRAY        DRED    MAGENTA    WHITE'''          °
  120.   '''       BLUE   DBLUE    DGREEN        GRAY    NEUTRAL   YELLOW'',r'        °
  121.   '''When AP 207 is first invoked, a default set of these colors is'''         °
  122.   '''installed. These 16 colors can be changed but the process does not'       °
  123. X'' '''turn out to be very simple.''' 'end'                                    °
  124. *(1996 9 20 18 43 21 508)                                                      °
  125.  FTEACH2 ÉFX 'TEACH2;D207;T' 'Σ Color names' '''COLOR MAP'',r'                 °
  126.   '''As soon as AP207 becomes active, a special array called the'''            °
  127.   '''"COLOR MAP" is generated. This array contains 16 rows and 5 columns       °
  128.  .'''                                                                          °
  129.   '''Each row corresponds to one of the 16 NAMED colors that can be disp       °
  130.  layed'''                                                                      °
  131.   '''on the screen. The color can be activated by one of three ways:'',r       °
  132.  ' ''' 1. by specifying the color NAME'''                                      °
  133.   ''' 2. by specifying the color NUMBER (in index origin 0)'''                 °
  134.   ''' 3. by specifying the intensity of the three color components.'',r'       °
  135.   '''To illustrate these three methods, we will display a table in which       °
  136.  '''                                                                           °
  137.   '''the colors are sorted by increasing intensity of their three color'       °
  138.  ''                                                                            °
  139.   '''components. Each color in this table lists the color name, followed       °
  140.   by'''                                                                        °
  141.   '''two (equal) integers. The first integer refers to the placement of        °
  142.  the'''                                                                        °
  143.   '''color in the COLOR MAP TABLE. The second integer is the color NUMBE       °
  144.  R'''                                                                          °
  145.   '''(of the COLOR MAP) associated with that color. (Note that these num       °
  146.  bers'''                                                                       °
  147.   '''range from 0 to 15.) The last three integers give the relative inte       °
  148.  nsity'''                                                                      °
  149.   '''(on a scale from 0 to 1000) of each of the three primary colors: re       °
  150.  d,''' '''green and blue'',r'                                                  °
  151.   '''                   INITIAL COLOR MAP'''                                   °
  152.   '''COLOR        # red green blue   COLOR        # red green blue'''          °
  153.   '''²²²²²²²     ²²²²²²²²²²²²²²²²²   ²²²²²²²²    ²²²²²²²²²²²²²²²²²'''          °
  154.   '(0 0 0(33 125 33))tab palette' 'do'                                         °
  155.   '''Note that BLACK is defined by the absence of any color (0 0 0)'''         °
  156.   '''while WHITE is defined by maximum intensity of all three colors'''        °
  157.   '''(1000 1000 1000). Indeed, shades of gray can be represented by'''         °
  158. X '''setting all three colors to the same intensity.''' 'end'                  °
  159. *(1996 9 14 18 4 8 276)                                                        °
  160.  FTEACH3 ÉFX 'TEACH3;M;T;D207' 'Σ Examples of colors and palette'              °
  161.   'T╜open ''test'''                                                            °
  162.   '''So far we have discussed how colors are defined. Let us now look at       °
  163.  '''                                                                           °
  164.   '''them. Function PAL will display the 16 initial colors in the same''       °
  165.  ' '''sequence as that shown on the previous table''' 'do'                     °
  166.   'show ''PAL'''                                                               °
  167.   '''Function COLRS can be used for a similar display, but is more versa       °
  168.  tile.'''                                                                      °
  169.   '''We will use this function to display the 16 initial colors in the''       °
  170.  ' '''sequence in which they are defined in the COLOR MAP''' 'do'              °
  171.   'show ''COLRS 0,∞15'''                                                       °
  172.   '''Clearly the two sets of colors can be matched.'',r'                       °
  173.   '''THE COMMAND COLMAP (PALETTE)'',r'                                         °
  174.   '''WARNING! This command as described in the User''''s Guide (both the       °
  175.  '''                                                                           °
  176.   '''hard copy and the on-line documentation) does not always produce th       °
  177.  e'''                                                                          °
  178.   '''desired behavior. In this lesson, I discuss only those options that       °
  179.  '''                                                                           °
  180.   '''appear to work as described. To produce additional behavior, you ma       °
  181.  y''' '''consider defining special utility functions.''' 'do'                  °
  182.   '''As we saw, COLOR MAP is an array of 16 rows showing the colors'''         °
  183.   '''associated with the 16 named colors. There is also another table wi       °
  184.  th'''                                                                         °
  185.   '''a similar name. This table called the COLOR MAP TABLE contains 256'       °
  186.  ''                                                                            °
  187.   '''rows. The contents of this table are controlled by command COLMAP.'       °
  188.  ''                                                                            °
  189.   '''If initially we were to try to display rows of this table other tha       °
  190.  n''' '''the first 16 we will just get a series of gray colors.''' 'do'        °
  191.   'D207╜''clear'' '''' ╪ T╜test' 'show ''COLRS 15+∞16'''                       °
  192.   '''Let us experiment with the color map table. We want to find out if'       °
  193.  ''                                                                            °
  194.   '''changing the contents of the color map table affects the contents o       °
  195.  f'''                                                                          °
  196.   '''the COLOR MAP. We will use the command ''''COLMAP'''' to try to def       °
  197.  ine a new''' '''color in row 16 of the COLOR MAP TABLE'',r'                   °
  198.   'show ''D207╜''''clear'''' '''''''' ''''colmap'''' (16 500 800 0) ╪ T╜       °
  199.  test''' 'show ''COLRS 15 16 17 18'''                                          °
  200.   '''Having defined row 16, it appears that this definition affected as        °
  201.  well'''                                                                       °
  202.   '''all subsequent rows. Let us see what will happen if we define a new       °
  203.  ''' '''color in row 18 of the COLOR MAP TABLE'',r'                            °
  204.   'show ''D207╜''''clear'''' '''''''' ''''colmap'''' (18 0 800 500) ╪ T╜       °
  205.  test''' 'show ''COLRS 15 16 17 18 19'''                                       °
  206.   '''Peculiar behavior. The COLOR MAP TABLE exists in APL2OS2, but defin       °
  207.  ing'''                                                                        °
  208.   '''a new color in row 18 appears to have spread also to row 17 and 19.       °
  209.   The'''                                                                       °
  210.   '''definition in row 16 remains unchanged. We will return to command''       °
  211.  '                                                                             °
  212.   '''COLMAP again later. Before leaving this section, let us verify that       °
  213.   the''' '''original COLOR MAP is still in effect''' 'do'                      °
  214.   'show ''PAL'''                                                               °
  215.   '''The original colors are still in effect. Furthermore, the new color       °
  216.  s'''                                                                          °
  217.   '''defined on rows 16 and 18 of the COLOR MAP TABLE remain unchanged.'       °
  218. X'' 'end'                                                                      °
  219. *(1996 9 14 18 5 57 476)                                                       °
  220.  FTEACH4 ÉFX 'TEACH4;A;T;D207' 'Σ The COLOR command'                           °
  221.   '''THE COLOR COMMAND'',r'                                                    °
  222.   '''If you examined functions PAL and COLRS, you would have noticed tha       °
  223.  t'''                                                                          °
  224.   '''these functions invoke the command COLOR. We will now study this'''       °
  225.   '''command and return to command COLMAP later. We will begin with the'       °
  226.  ''                                                                            °
  227.   '''null string argument. According to the ON LINE USER''''S MANUAL, th       °
  228.  is''' '''will return the color of the FOREGROUND.'',r'                        °
  229.   'T╜open ''COMMAND COLOR'''                                                   °
  230.   'show ''D207╜''''COLOR'''' '''''''''' ''DISPLAY test'''                      °
  231.   '''The foreground color is (7) or BLACK. Let us now set the foreground       °
  232.  ''' '''color to BLUE. This can be done using the color command.'',r'          °
  233.   'show ''D207╜''''color'''' ''''BLUE'''''' ''D207╜''''view'''' ''''''''       °
  234.  '''                                                                           °
  235.   '''Since we have not drawn anything, the screen shows only the default       °
  236.  '''                                                                           °
  237.   '''background color. Let us now write some text, draw a circle and fil       °
  238.  l''' '''a circular area with color''' 'do'                                    °
  239.   'show ''D207╜''''BEGAREA'''' '''''''' ''''ARC''''(200 200 100 100 0 36       °
  240.  0) ''''ENDAREA'''' '''''''''''                                                °
  241.   'show ''D207╜''''MOVE''''(100 400) ''''WRITE'''' ''''BLUE WITH WHITE B       °
  242.  ACKGROUND'''''''                                                              °
  243.   'show ''D207╜''''ARC'''' (400 200 100 100 0 360) ''''view'''' ''''''''       °
  244.  '''                                                                           °
  245.   '''The blue color foreground will be applied to all graphs, patterns a       °
  246.  nd'''                                                                         °
  247.   '''text until a new COLOR command is issued. There are three ways of''       °
  248.  '                                                                             °
  249.   '''specifying a color. So far we have used only one, namely giving the       °
  250.  '''                                                                           °
  251.   '''color name. We can also specify the color number, or give the inten       °
  252.  sity'''                                                                       °
  253.   '''of the three color components. Noting that RED is #2 we issue the C       °
  254.  OLOR''' '''command''' 'do' 'show ''D207╜''''COLOR'''' 2'''                    °
  255.   'show ''D207╜''''MOVE''''(100 500) ''''WRITE'''' ''''RED WITH WHITE BA       °
  256.  CKGROUND''''''' 'show ''D207╜''''COLOR'''' (300 900 200)'''                   °
  257.   'show ''D207╜''''BEGAREA'''' '''''''' ''''ARC'''' (600 200 100 100 0 3       °
  258.  60) ''''ENDAREA'''' ''''''''''' 'show ''D207╜''''view'''' '''''''''''         °
  259.   '''Note that the color of the rightmost circle is GREEN (0 1000 0). Wh       °
  260.  en a'''                                                                       °
  261.   '''color in command COLOR is defined using the intensity of the three'       °
  262.  ''                                                                            °
  263.   '''primary colors, AP 207 selects from the COLOR MAP the one that most       °
  264.  ''' '''closely approaches the given intensities.''' 'do' 'TEACH4A'            °
  265. X 'end'                                                                        °
  266. *(1996 9 14 18 14 12 332)                                                      °
  267.  FTEACH4A ÉFX 'TEACH4A;A;T' 'Σ The CLEAR command'                              °
  268.   '''THE CLEAR COMMAND'',r'                                                    °
  269.   '''So far we have shown how to specify the FOREGROUND color. Can we do       °
  270.  '''                                                                           °
  271.   '''the same with the BACKGROUND color? The answer is YES, but setting        °
  272.  the'''                                                                        °
  273.   '''background color will also eliminate any and all graphs on the grap       °
  274.  hic'''                                                                        °
  275.   '''screen. We have erased graphs using the CLEAR command with a null''       °
  276.  '                                                                             °
  277.   '''argument. By replacing the null argument with any one of the same''       °
  278.  '                                                                             °
  279.   '''arguments used with the COLOR command, we can set the background co       °
  280.  lor''' 'do'                                                                   °
  281.   'show ''D207╜''''CLEAR'''' ''''YELLOW'''''' ''D207╜''''view'''' ''''''       °
  282.  '''''                                                                         °
  283.   '''The screen has been cleared, and the background is now YELLOW. One'       °
  284.  ''                                                                            °
  285.   '''might ask at this point. What if we issued the CLEAR command with a       °
  286.  '''                                                                           °
  287.   '''null argument. Do we get another YELLOW background, or do we get th       °
  288.  e'''                                                                          °
  289.   '''default white? As you can verify in the next example, a null argume       °
  290.  nt''' '''will produce the default WHITE color.''' 'do'                        °
  291.   'show ''D207╜''''CLEAR'''' '''''''''' ''D207╜''''view'''' '''''''''''        °
  292.   '''Let us now try the other two methods for specifying background colo       °
  293.  r''' 'do'                                                                     °
  294.   'show ''D207╜''''CLEAR'''' 3'' ''D207╜''''view'''' '''''''''''               °
  295.   '''The color #3 is defined as MAGENTA, and this is now the background'       °
  296.  '' '''color''' 'do'                                                           °
  297.   'show ''D207╜''''CLEAR'''' (1000 900 900)'' ''D207╜''''view'''' ''''''       °
  298.  '''''                                                                         °
  299.   '''As in the command COLOR, the specified intensities are matched with       °
  300.  '''                                                                           °
  301.   '''those of the COLOR MAP. In this case the match is WHITE (1000 1000        °
  302. X1000)'''                                                                      °
  303. *(1996 10 3 14 26 16 340)                                                      °
  304.  FTEACH5 ÉFX 'TEACH5;M;T;D207' 'Σ Modifying the color map table'               °
  305.   '''We now return to the command COLMAP. We begin by generating a table       °
  306.  '''                                                                           °
  307.   '''containing three columns with random numbers in the range 0-1000'',       °
  308.  r' 'T╜open ''MODIFY COLOR TABLE''' 'show ''M╜?256 3µ1000'''                   °
  309.   '''We will use this array to re-define the COLOR MAP TABLE. But before       °
  310.   we'''                                                                        °
  311.   '''do that, let us specify two special colors in rows 17 and 18.'',r'        °
  312.   'show ''M[17 18;]╜2 3µ487 337 80 1000 920 920'''                             °
  313.   '''The first color is a nice shade of brown. The second color is white       °
  314.  '''                                                                           °
  315.   '''with a pink tint. Now we can issue the command COLMAP giving M as i       °
  316.  ts''' '''right argument''' 'do'                                               °
  317.   'show ''D207╜''''COLMAP'''' M'' ''DISPLAY test'''                            °
  318.   '''This COLMAP command defines the COLOR MAP TABLE.'',r'                     °
  319.   '''We could have entered an array M with fewer than 256 rows. Had we d       °
  320.  one'''                                                                        °
  321.   '''that with say N rows, the color map table would have been changed o       °
  322.  nly''' '''on the first N rows.'',r'                                           °
  323.   '''Defining a new COLOR MAP TABLE also affects the COLOR MAP in the fo       °
  324.  llowing'''                                                                    °
  325.   '''way: For each named color, a search is made in the COLOR MAP TABLE        °
  326.  for the'''                                                                    °
  327.   '''row that most closely matches the DEFAULT color NAME definition. Th       °
  328.  is row'''                                                                     °
  329.   '''is then placed in the COLOR MAP. Let us see the newly defined COLOR       °
  330.   MAP'''                                                                       °
  331.   '''by invoking function PAL.(If by luck the newly defined WHITE become       °
  332.  s other'''                                                                    °
  333.   '''than (1000 1000 1000)-- you will note that the background color mat       °
  334.  ches''' '''the NEW definition of WHITE.)''' 'do' 'show ''PAL'''               °
  335.   '''We can also look at the first 16 colors of the randomly generated''       °
  336.  ' '''COLOR MAP TABLE''' 'do' 'show ''COLRS 0,∞15'''                           °
  337.   '''The colors in the color map table do not match those of the COLOR M       °
  338.  AP.''' '''Let us also look at the colors of the next 16 rows.''' 'do'         °
  339.   'show ''COLRS 15+∞16'''                                                      °
  340.   '''It should be pointed out also that the newly defined COLOR MAP'''         °
  341.   '''now differs from the array M in its first 16 rows.'',r'                   °
  342.   'show ''M[∞16;]''' '(0 0 0(33 125 33))tab palette' 'do'                      °
  343.   '''Although the on line User''''s Guide describes the effect of using        °
  344.  a'''                                                                          °
  345.   '''null argument with COLMAP, I find that it does not work (I get a re       °
  346.  turn'''                                                                       °
  347.   '''code of 39 -- Invalid parameter). I also find that although a ²1'''       °
  348.   '''argument to COLMAP appears to work, it causes some unknown changes        °
  349.  that''' '''may make functions PAL and COLRS inoperable.''' 'do'               °
  350.   '''Can we restore the original COLOR MAP? We can do it with the utilit       °
  351.  y'''                                                                          °
  352.   '''function "colmap". This function generates the initial colors(or do       °
  353.  es it?).'',r'                                                                 °
  354.   'show ''M[∞16;]╜colmap ╪ D207╜''''COLMAP'''' M ╪ T╜test'''                   °
  355.   'show ''PAL'''                                                               °
  356.   '''Note that even though we have specified only a display of the COLOR       °
  357.  '''                                                                           °
  358.   '''MAP, the color changes also apply to that portion of the graph that       °
  359.  ''' '''shows the first 16 rows of the COLOR MAP TABLE.'',r'                   °
  360.   '''Finally, let us see how the CLEAR command behaves if we use the num       °
  361.  ber'''                                                                        °
  362.   '''18. (Recall that we defined this row as white with a pink tinge)'''       °
  363.   'do' 'show ''D207╜''''clear'''' 17'' ''D207╜''''view'''' '''''''''''         °
  364. X 'end'                                                                        °
  365. *(1996 10 3 14 9 59 444)                                                       °
  366.  FTEACH6 ÉFX 'TEACH6;T;N;D207;P' 'Σ The MIX command'                           °
  367.   'N╜7 9 12 13 10 11 14 8 15 1 4 5 2 3 6 0' '''THE COMMAND MIX'''              °
  368.   '''So far we have treated colors as if they were opaque to any previou       °
  369.  s'''                                                                          °
  370.   '''condition of the graphic screen. Function PAL illustrates well this       °
  371.  '''                                                                           °
  372.   '''effect. Each circle that overlies a previously drawn circle ignores       °
  373.  ''' '''the previously drawn color.''' 'T╜open ''MIXING COLORS''' 'do'         °
  374.   'show ''PAL'''                                                               °
  375.   '''The command MIX provides the facility of mixing colors. If a new co       °
  376.  lor'''                                                                        °
  377.   '''is drawn on top of a previously drawn color, a new color is produce       °
  378.  d.'',r'                                                                       °
  379.   '''There are four ways of doing this. The default is obviously NOT to        °
  380.  mix.'''                                                                       °
  381.   '''We can find out what this default is by applying a null string to t       °
  382.  he''' '''MIX argument''' 'do'                                                 °
  383.   'show ''D207╜''''MIX'''' '''''''' ╪ DISPLAY test'''                          °
  384.   '''Therefore a zero right argument to MIX will make subsequent colors'       °
  385.  ''                                                                            °
  386.   '''opaque. Actually, the color MIX MUST BE INVOKED BEFORE EACH applica       °
  387.  tion'''                                                                       °
  388.   '''of a color. If this invocation is not made, the MIX automatically r       °
  389.  eturns''' '''to OPAQUE.'',r'                                                  °
  390.   '''We will use function COLRS to study the arguments to command MIX. S       °
  391.  o far'''                                                                      °
  392.   '''we have invoked COLRS only with a numeric vector right argument. Ac       °
  393.  tually'''                                                                     °
  394.   '''this function is ambivalent. A left argument can include a numeric        °
  395.  scalar'''                                                                     °
  396.   '''or a vector consisting of integers from the set {0,1,2,3}. These va       °
  397.  lues'''                                                                       °
  398.   '''are interpreted as arguments to command MIX. In addition, the right       °
  399.  '''                                                                           °
  400.   '''argument can be a vector of vector pairs, where the second element        °
  401.  of'''                                                                         °
  402.   '''each pair represents the FILL PATTERN  to be used. Here is an examp       °
  403.  le''' '''of using these options with function COLRS.''' 'do'                  °
  404.   'show ''D207╜''''clear'''' '''''''' ╪ 0 2 2 COLRS ((16µ1 5 13 14),■∞16       °
  405.  )'''                                                                          °
  406.   '''We will explain in the next section why only some circles show on t       °
  407.  his'''                                                                        °
  408.   '''display despite the fact we specified 16 colors. Also note that the       °
  409.  '''                                                                           °
  410.   '''fill patterns appear to depend on the superposition of 16 circles.'       °
  411. X'' 'end'                                                                      °
  412. *(1996 9 17 18 21 26 428)                                                      °
  413.  FTEACH7 ÉFX 'TEACH7;T;N;D207;P' 'Σ The MIX command'                           °
  414.   '''Before describing in detail how function MIX works, let us see an e       °
  415.  xample.'''                                                                    °
  416.   '''First, we define N such as to reproduce the colors in the same sequ       °
  417.  ence''' '''as in function PAL.''' 'T╜open ''MIXING COLORS''' 'do'             °
  418.   'show ''N╜7 9 12 13 10 11 14 8 15 1 4 5 2 3 6 0'''                           °
  419.   '''Note that this vector is in the sequence of columns 1 and 2 of the'       °
  420.  '' '''initial COLOR MAP'',r' '(0 0 0(33 125 33))tab palette' 'do'             °
  421.   'show ''PAL'''                                                               °
  422.   '''We will now invoke function COLRS with left argument 1 and right ar       °
  423.  gument N.'''                                                                  °
  424.   '''Note that despite the confusion of colors, the color of the upper r       °
  425.  ight'''                                                                       °
  426.   '''hand wedge matches the colors of the circles generated by function        °
  427.  PAL.''' 'do' 'show ''1 COLRS N''' '''LOGICAL OPERATIONS ON COLORS'',r'        °
  428.   '''The User''''s Manual describes the right argument of 1 to MIX in th       °
  429.  e'''                                                                          °
  430.   '''following way: "Pels to be written are ANDed with existing pels." I       °
  431.  f'''                                                                          °
  432.   '''this is confusing, welcome to the club. The logical operations of A       °
  433.  ND'''                                                                         °
  434.   '''OR and NOT are normally associated with BOOLEAN variables. However,       °
  435.  '''                                                                           °
  436.   '''in dealing with colors, we are dealing with integers in the range''       °
  437.  '                                                                             °
  438.   '''{0,1000}. So what does the operation AND mean? Those of you who hav       °
  439.  e'''                                                                          °
  440.   '''studied FUZZY SETS, have in fact come across the use of logical'''        °
  441.   '''operations on numeric quantities.''' 'do'                                 °
  442.   '''In FUZZY SET theory given two numbers M and N, the operation AND im       °
  443.  plies'''                                                                      °
  444.   '''selecting the smaller of the two values, while the operation OR imp       °
  445.  lies'''                                                                       °
  446.   '''selecting the larger of the two values. I do not know for sure if t       °
  447.  his'''                                                                        °
  448.   '''is the way MIX works, but at least it explains some of the results.       °
  449.  '''                                                                           °
  450.   '''Let us take another look at the COLOR MAP table and see if we can p       °
  451.  redict'''                                                                     °
  452.   '''the color combinations where command 1 (AND) will produce BLACK.'',       °
  453.  r' '(0 0 0(33 125 33))tab palette'                                            °
  454.   'r,''Inspecting this table we find five consecutive rows that produce        °
  455.  (0 0 0)''' '''on a FUZZY AND operation '',r'                                  °
  456.   '''BLACK and DBLUE  (0 0 0)AND(0 0 502)╕(0 0 0)'''                           °
  457.   '''DBLUE and DGREEN (0 0 502)AND(0 502 0)╕(0 0 0)'''                         °
  458.   '''DCYAN and DRED   (0 502 502)AND(502 0 0)╕(0 0 0)'''                       °
  459.   '''BLUE and GREEN   (0 0 1000)AND(0 1000 0)╕(0 0 0)'''                       °
  460.   '''CYAN and RED     (0 1000 1000)AND(1000 0 0)╕(0 0 0)''' 'do'               °
  461.   '''Let us take another look at the command ''''MIX'''' 1 as invoked by       °
  462.   COLRS.'''                                                                    °
  463.   '''Note that it is precisely these color combinations that show up as        °
  464.  BLACK''' 'do'                                                                 °
  465.   'show ''D207╜''''clear'''' '''''''' ╪ T╜test ╪ 1 COLRS N'''                  °
  466.   '''When two or more colors are AND mixed, the color intensities are'''       °
  467.   '''compared, and the smaller of each primary colors are selected. As a       °
  468.  '''                                                                           °
  469.   '''result, such matching produces generally darker (even black) colors       °
  470. X.''' 'end'                                                                    °
  471. *(1996 9 18 19 24 41 508)                                                      °
  472.  FTEACH8 ÉFX 'TEACH8;T;D207;P' 'Σ The MIX command'                             °
  473.   '''THE COMMAND MIX WITH ARGUMENT 2 (OR)'',r'                                 °
  474.   'N╜7 9 12 13 10 11 14 8 15 1 4 5 2 3 6 0'                                    °
  475.   '''We have seen that ''''MIX'''' 1 combines colors by selecting the sm       °
  476.  aller'''                                                                      °
  477.   '''value for each color. The command ''''MIX'''' 2 (OR) should select        °
  478.  the'''                                                                        °
  479.   '''larger value for each color. We will now invoke function COLRS with       °
  480.  '''                                                                           °
  481.   '''a left argument 2 and as before the right argument N. But before yo       °
  482.  u'''                                                                          °
  483.   '''press ENTER to see the result, pause and see if you can predict wha       °
  484.  t''' '''colors you will see on the screen.'',r'                               °
  485.   '''HINT: the background color is WHITE (1000 1000 1000).'''                  °
  486.   'T╜open ''MIXING COLORS''' 'do' 'show ''2 COLRS N'''                         °
  487.   '''On an OR mixing, the WHITE background (1000 1000 1000) dominates al       °
  488.  l'''                                                                          °
  489.   '''other colors. To see how the ''''MIX'''' 2 command works we will fi       °
  490.  rst''' '''draw the 16 overlapping circles to the color RED (2)''' 'do'        °
  491.   'show ''D207╜''''clear'''' '''''''' ╪ T╜test ╪ COLRS (16µ2)'''               °
  492.   '''We can now superimpose on this array of overlapping circles the col       °
  493.  ors'''                                                                        °
  494.   '''of the COLOR MAP. But first, let us try to predict what colors shou       °
  495.  ld'''                                                                         °
  496.   '''be seen. We can do that by looking at the default color definitions       °
  497.  '',r' '(0 0 0(33 125 33))tab palette'                                         °
  498.   'r,''Since the background is RED (1000 0 0) we can try to predict the        °
  499.  areas''' '''where the resulting color should be RED or WHITE:'',r'            °
  500.   '''RED or BLACK should return RED (1000 0 0)OR(0 0 0)╕(1000 0 0)╕RED''       °
  501.  ' '''RED or DRED should return RED (1000 0 0)OR(502 0 0)╕(1000 0 0)'''        °
  502.   '''RED or BLUE or GREEN (1000 0 0)OR(0 0 1000)OR(0 1000 0)╕(1000 1000        °
  503.  1000)'''                                                                      °
  504.   '''RED or GREEN or CYAN (1000 0 0)OR(0 1000 0)OR(0 1000 1000)╕WHITE'''       °
  505.   '''RED or CYAN (1000 0 0)OR(0 1000 1000)╕(1000 1000 1000)'''                 °
  506.   '''RED or MAGENTA or (YELLOW) (1000 0 0)OR(1000 0 1000)OR(1000 1000 0)       °
  507.  ╕WHITE''' 'do' 'show ''2 COLRS N'''                                           °
  508.   '''Since OR selects the larger intensities, the resulting colors are l       °
  509. Xighter''' '''than the originals.''' 'end'                                     °
  510. *(1996 9 19 17 27 11 396)                                                      °
  511.  FTEACH9 ÉFX 'TEACH9;N;T;D207' 'Σ Using the Exclusive OR option'               °
  512.   '''THE EXCLUSIVE OR'',r' 'N╜7 9 12 13 10 11 14 8 15 1 4 5 2 3 6 0'           °
  513.   '''According to the on line User''''s Guide the argument 3 stands for        °
  514.  the''' '''EXCLUSIVE OR:'',r'                                                  °
  515.   ''' "Pels to be written are exclusive ORed with existing pels. This ca       °
  516.  n'''                                                                          °
  517.   '''  be used to move objects around, since writing the same object bac       °
  518.  k'''                                                                          °
  519.   '''  into the same position in this mode restores the original screen,       °
  520.  ''' '''  making the object disappear."'',r'                                   °
  521.   '''The sense is quite clear, but the actual process is not. My suggest       °
  522.  ion'''                                                                        °
  523.   '''to IBM is to include a reference in the above explanation to a docu       °
  524.  ment'''                                                                       °
  525.   '''(if such exists) that gives a detailed algorithm of this process.''       °
  526.  ' 'T╜open ''MIXING COLORS''' 'do'                                             °
  527.   '''First, let us show that the process is very specific to the manner        °
  528.  in'''                                                                         °
  529.   '''which the graphical object is generated. The first example shows th       °
  530.  at'''                                                                         °
  531.   '''a graph produced using different MIX commands will NOT be erased'''       °
  532.   'do'                                                                         °
  533.   'show ''D207╜''''clear'''' '''''''' ╪ T╜test ╪ COLRS N ╪ 3 COLRS N'''        °
  534.   '''On the first pass the 16 colors were drawn as opaque (''''MIX'''' 0       °
  535.  ). On'''                                                                      °
  536.   '''the second pass the same colors were drawn using the EXCLUSIVE OR (       °
  537.  3)''' '''The result is anything but a background white.'',r'                  °
  538.   '''In the next example the SAME graph (3 COLRS N) is issued TWICE. On        °
  539.  the''' '''second pass the graph is erased as expected''' 'do'                 °
  540.   'show ''D207╜''''clear'''' '''''''' ╪ T╜test ╪ 3 COLRS N ╪ 3 COLRS N''       °
  541.  '                                                                             °
  542.   '''One question that must be answered is whether the clearing process        °
  543.  will'''                                                                       °
  544.   '''produce a WHITE result, or the BACGROUND color whatever this may be       °
  545.  .''' 'do'                                                                     °
  546.   'show ''D207╜''''clear'''' 3 ╪ T╜test ╪ 3 COLRS N ╪ 3 COLRS N'''             °
  547.   '''Clearly the EXCLUSIVE or keeps track of the background color. It is       °
  548.  '''                                                                           °
  549.   '''this process that is not clearly explained in the User''''s Guide.'       °
  550. X'' 'end' '''This is the end of lesson 51'''                                   °
  551. XCa 0 %                                                                        °
  552. *(1992 2 29 8 32 29 448)                                                       °
  553.  Faddquote ÉFX 'u╜addquote w'                                                  °
  554.   'Σ Put quotes around a string, and double existing quotes'                   °
  555. X 'u╜ÉAV[40],((1+w=ÉAV[40])/w),ÉAV[40]'                                        °
  556. *(1992 2 29 8 32 29 448)                                                       °
  557. XFaq ÉFX 'u╜aq w' 'Σ Enclose quoted string' 'u╜Γaddquote w'                    °
  558. *(1992 2 29 8 32 30 452)                                                       °
  559.  Fav ÉFX 'av;a;n;i;ÉIO' 'Σ Display characters in the Atomic vector'            °
  560.   'ÉIO╜0' 'a╜22 78µ'' ''' 'n╜3 0«φ12 22µ1+∞256'                                °
  561.   'a[;,(6⌡∞12)°.+2 3 4]╜n' 'a[;6+6⌡∞12]╜φ12 22µÉAV'                            °
  562. X 'a[7 8 10 13;6]╜'' ''' 'a[14+∞8;68 69 70 72]╜'' ''' 'a'                      °
  563. *(1992 2 29 8 32 32 460)                                                       °
  564.  Fback ÉFX 'back;T' 'Σ Reset screen to 25⌡80 size' 'OPEN 124' 'C124╜0 3'       °
  565. X 'CLOSE 124 206'                                                              °
  566.  Ac╜('BLACK')('DBLUE')('DGREEN')('DCYAN')('DRED')('DMAGENTA')('BROWN')('       °
  567.  GRAY')('DGRAY')('BLUE')('GREEN')('CYAN')('RED')('MAGENTA')('YELLOW')('W       °
  568. XHITE')                                                                        °
  569. *(1996 8 13 14 3 20 296)                                                       °
  570. XFclose ÉFX 'close' 'Σ Close AP 207' 'T╜ÉSVR ''D207'' ╪ T╜ÉEX ''D207'''        °
  571. *(1996 9 12 18 3 37 380)                                                       °
  572.  Fcolmap ÉFX 'U╜colmap;C;D;T;D207'                                             °
  573.   'Σ Returns an array of 16 color definitions' 'C╜colors ╪ U╜0 5µ0'            °
  574.   '╕(D╜2=ÉSVO ''D207'')/L0 ╪ T╜open ''PALETTE'''                               °
  575.   'L0:D207╜''COLOR''(╞C) ╪ T╜╞2πtest ╪ D207╜''COLMAP'' T ╪ U╜U,[1]2πtest       °
  576. X' '╕(0<µC╜1╟C)/L0' 'U╜U[;3 4 5]' 'T╜ÉSVR ''D207'' ╪ T╜ÉEX ''D207'''           °
  577.  Acolors╜('BLACK')('DBLUE')('DGREEN')('DCYAN')('DRED')('DMAGENTA')('BROW       °
  578.  N')('GRAY')('DGRAY')('BLUE')('GREEN')('CYAN')('RED')('MAGENTA')('YELLOW       °
  579. X')('WHITE')                                                                   °
  580. *(1996 8 5 14 6 58 428)                                                        °
  581.  Fcopyright ÉFX 'copyright' 'Σ Copyright statement'                            °
  582.   '(10µ'' ''),''Copyright, Z. V. Jizba, 1995,1996'',r'                         °
  583.   '''To see disclaimers, enter ÉCR ''''copyright''''''' 'do' '╕0'              °
  584.   '''This and subsequent workspaces labelled TEACHxx are made available'       °
  585.  ''                                                                            °
  586.   '''at no cost to anyone who desires to learn how to use effectively'''       °
  587.   '''the IBM/OS2 version of APL2.'',r'                                         °
  588.   '''This software is provided "AS IS" with no WARRANTY of any kind, eit       °
  589.  her'''                                                                        °
  590.   '''express or implied. Any risk in its use resides with you, the user        °
  591. Xof''' '''these tutorials.''' '''(PRESS ENTER to continue)'''                  °
  592. XCd 0 "                                                                        °
  593. *(1992 2 29 8 32 33 464)                                                       °
  594.  Fdate ÉFX 'u╜date w' 'Σ Format date and time of day' 'u╜«6╞w'                 °
  595. X 'u╜('' ''⌠u)Γu' 'u╜εu,■''-- .. '''                                           °
  596. XCdig 1 10 1234567890                                                          °
  597. *(1992 2 29 8 32 28 444)                                                       °
  598.  Fdo ÉFX 'do;t;e;b' 'Σ Expression driver' 'e╜''''' 'æ╜''       ''' 't╜æ'       °
  599.   '╕(^/'' ''=t)/0'                                                             °
  600.   '╕(('':''εt)doif ''b╜evaldd (+/^\'''' ''''=t)╟t'')/2'                        °
  601.   '''e╜ÉEM'' ÉEA t' '╕(0=µ,e)/2'                                               °
  602.   '''This is not a valid APL2 expression''' 'æ╜''*''' '╕(''?''⌠╞1╟æ)/2'        °
  603. X 'e' '╕2'                                                                     °
  604. *(1992 2 29 8 32 28 444)                                                       °
  605.  Fdoif ÉFX 'U╢╜V╢ doif W╢;t╢' 'Σ Rule' '╕(^/~U╢╜V╢)/0'                         °
  606. X '''U╢╜V╢ doif■ W╢'' ÉEA ''»V╢/W╢'''                                          °
  607. XNdos 0 ²26                                                                    °
  608. XCe 1 0                                                                        °
  609. *(1996 7 24 14 20 54 540)                                                      °
  610.  Fend ÉFX 'end' 'e╜''''' 'æ╜''       ''' 't╜æ' '╕(^/'' ''=t)/L0'               °
  611.   '╕(('':''εt)doif ''b╜evaldd (+/^\'''' ''''=t)╟t'')/3'                        °
  612.   '''e╜ÉEM'' ÉEA t' '╕(0=µ,e)/L0'                                              °
  613.   '''This is not a valid APL2 expression''' 'æ╜''*'''                          °
  614. X '╕(''?''⌠╞1╟æ)/L0' 'e' 'L0:''²²'''                                           °
  615. *(1992 2 29 8 32 30 452)                                                       °
  616. XFendd ÉFX 'endd' 'Σ End of document' '20µ''²''' 'do'                          °
  617. *(1996 8 12 13 36 9 376)                                                       °
  618.  Ferase ÉFX 'erase;t;b;DISPLAY;DOS;GO;FRAME;SVOFFER;COLRS;PAL;PALCOLS'         °
  619.   't╜ÉNL 3' 't╜(~t^.εlc,'' '')≡t'                                              °
  620.   't╜(~(t[;∞5]^.=''TEACH'')δt[;∞4]^.=''TEST'')≡t' 't╜ÉEX t' 't╜ÉNL 2'          °
  621. X 't╜ÉEX(~t^.εlc,'' '')≡t' 't╜ÉNL 4' 't╜ÉEX(~t^.εlc,'' '')≡t'                  °
  622. *(1992 2 29 8 32 32 460)                                                       °
  623.  Fevaldd ÉFX 'u╜evaldd w;c;n'                                                  °
  624.   'Σ Evaluate a direct definition expression' 'u╜0' 'n╜(w∞''Σ'')-1'            °
  625.   'c╜(((n╞w)⌠'':'')Γn╞w),Γ''ΣDD '',(n+1)╟w' '╕(label╞c)/0'                     °
  626.   '╕((2=µc)doif ''u╜showdd 1╙c'')/0'                                           °
  627.   '╕((3=ÉNC╞c)doif ''u╜⌡µÉ╜(╞c),'''' is already defined.'''''')/0'             °
  628.   '╕((3=µc)doif ''u╜simdd c'')/0' 'c╜(Γ''α∙ aw'')replace■c'                    °
  629.   'u╜ε''u╜'',((''a''εεc[2 3 4])/''a ''),(╞c),'' w;t;b'''                       °
  630.   'u╜u(5πc)(''b╜(t╜'',(3πc),'')/'',addquote ''u╜'',4πc)'                       °
  631. X 'u╜u,''╕(t doif b)/0''(''u╜'',2πc)' 'u╜╧ÉFX u'                               °
  632. *(1992 2 29 8 32 32 460)                                                       °
  633.  Fexit ÉFX 'exit w' 'Σ Exit if there are too many suspended functions'         °
  634. X '╕((10>µÉLC)doif ''w'')/0' '''Please re-enter '',w' '╕'                      °
  635. XCf 1 2  {                                                                     °
  636.  Afonts╜('GOTENG')('GOTGER')('GOTITA')('GRESER')('GRESIM')('MARKERS')('M       °
  637.  ODSIM')('ROMDUP')('ROMDUPF')('ROMITA')('ROMITAB')('ROMSER')('ROMSERB')(       °
  638.  'ROMSIM')('ROMSIMM')('SANSER')('SANSERF')('SCRIPT')('THKRNDF')('THKRNDO       °
  639. X')('THKSQUF')('THKSQUO')                                                      °
  640. XCfpath 1 12 D:\APL2\AVF\                                                      °
  641. XCg 1 2 }                                                                      °
  642. *(1996 3 12 15 27 53 504)                                                      °
  643.  Fget ÉFX 'u╜v get w;t;ÉPR' 'Σ Prompt for response from keyboard'              °
  644.   't╜(0=ÉNC ''v'')doif ''v╜1'' ╪ ÉPR╜''''' 'w╜w,(~²1╞v)/'': '''                °
  645.   'L0:æ╜w' 't╜æ' '╕((''╕''=(µw)╟t)doif ''╕'')/0' '╕(^/'' ''=w)/L1'             °
  646.   '╕((~w╧(µw)╞t)doif ''''''PLEASE DO NOT BACKSPACE'''''')/L0'                  °
  647.   't╜(µw)╟t' 'L1:u╜(²1+(,'' ''⌠t)∞1)╟t' '╕(1╞v)/0' 't╜(u⌠'' '')Γu'             °
  648. X 'u╜(µt),(Γu),t'                                                              °
  649. *(1992 10 25 11 14 30 408)                                                     °
  650.  Fgetfont ÉFX 'getfont W;A;N;F' 'Σ retrieve fonts W' 'W╜0,(Wε0,∞22)/W'         °
  651.   'L0:╕(0=µW╜1╟W)/0' '╕(0=A╜╞W)/L0' 'F╜εfpath,(N╜πfonts[A]),''.AVF'''          °
  652. X 'D207╜''FONTDEF''(N F)' '╕L0'                                                °
  653. *(1996 9 20 18 13 33 436)                                                      °
  654.  Fglobals ÉFX 'globals;T;D207' 'Σ Initialize useful global variables'          °
  655.   'r╜2╙ÉTC' 'q╜40╙ÉAV' 's╜Φp╜'' '',d╜35╙ÉAV'                                   °
  656.   'sv╜(100 211 80 206)(210 124)' 'uc╜''ABCDEFGHIJKLMNOPQRSTUVWXYZ'''           °
  657.   'lc╜''abcdefghijklmnopqrstuvwxyz''' 'dig╜''1234567890'''                     °
  658.   'g╜Φ'' '',h╜126╙ÉAV' 'f╜ÉAV[33 124]' 'a╜38╙ÉAV' 'ul╜''²'''                   °
  659.   'T╜207 SVOFFER ''D207''' 'D207╜''QUERY'' ''''' 'modes╜3πD207'                °
  660.   'path╜''C:\APL2\WORK\''' 'fpath╜''C:\APL2\AVF\'''                            °
  661.   'fonts╜''GOTENG'' ''GOTGER'' ''GOTITA'' ''GRESER'' ''GRESIM'' ''MARKER       °
  662.  S'''                                                                          °
  663.   'fonts╜fonts,''MODSIM'' ''ROMDUP'' ''ROMDUPF'' ''ROMITA'' ''ROMITAB'''       °
  664.   'fonts╜fonts,''ROMSER'' ''ROMSERB'' ''ROMSIM'' ''ROMSIMM'' ''SANSER'''       °
  665.   'fonts╜fonts,''SANSERF'' ''SCRIPT'' ''THKRNDF'' ''THKRNDO'' ''THKSQUF'       °
  666.  ' ''THKSQUO'''                                                                °
  667.   'colors╜''BLACK'' ''DBLUE'' ''DGREEN'' ''DCYAN'' ''DRED'' ''DMAGENTA''       °
  668.   ''BROWN'''                                                                   °
  669.   'colors╜colors,''GRAY'' ''DGRAY'' ''BLUE'' ''GREEN'' ''CYAN'' ''RED'''       °
  670.   'colors╜colors,''MAGENTA'' ''YELLOW'' ''WHITE'''                             °
  671.   '''The current path to font image files (extension .AVF) is '',fpath'        °
  672.   'T╜1 get ''Enter new path if incorrect, else press Enter: '''                °
  673. X 'T╜(0<µT)doif ''fpath╜T'''                                                   °
  674. XCh 0 }                                                                        °
  675. *(1992 8 10 10 44 11 380)                                                      °
  676.  Findex ÉFX 'U╜V index W;A;C;H;I;T' 'Σ List contents of an AP 211 file'        °
  677.   'T╜~(1<╧W)doif ''H╜2πW'' ''W╜1πW''' 'T╜T doif ''H╜''''FUNCTION'''''''        °
  678.   'T╜(ΓW)ε''DOCS'' ''UTILITY'' ''HELP'' ''TUTOR'''                             °
  679.   'T╜T doif ''W╜path,W,''''.211''''''' '1 OPEN 211' 'D211╜''USE'' W'           °
  680.   '''File '',W,'' has record length='',1╟D211'                                 °
  681.   'D211╜''LIST'' ''NAMES''' 'U╜D211'                                           °
  682.   '╕((0=╧U)doif ''U╜''''Unknown file'''''')/0' 'C╜1╟µU╜U[I╜ÉAV√U;]'            °
  683.   '╕((0=ÉNC ''V'')doif ''CLOSE 211'')/0' 'U╜(C╞H),[1]ul,[1]U'                  °
  684.   '╕((0=1╞V)doif ''U╜0 0 2 tab U'' ''CLOSE 211'')/0'                           °
  685.   'D211╜''LIST'' ''ATTS''' 'A╜D211'                                            °
  686.   'A╜(''SZ'' ''ID'' ''DATE'' ''mo'' ''d'' ''TIME'' ''m'' ''s'' ''ms''),[       °
  687.  1]ul,[1]A[I;]' 'V╜(Vε0,(∞9),-∞9)/V' 'U╜U,«A[;(0⌠V)/|V]'                       °
  688.   '╕((0εV)doif ''CLOSE 211'')/0'                                               °
  689.   'T╜~(0<╛/V)doif ''U╜U[∞2;],[1](2 0╟U)[√(2 0╟A)[;|V];]'''                     °
  690.   'T╜T doif ''U╜U[∞2;],[1](2 0╟U)[ⁿ(2 0╟A)[;|V];]''' 'T╜ÉDL 1'                 °
  691. X 'CLOSE 211'                                                                  °
  692. *(1996 9 20 18 12 4 316)                                                       °
  693.  Finitialize ÉFX 'initialize;t'                                                °
  694.   'Σ  Initialize workspace. (To add to "sv" keep 100 FIRST)' 'erase'           °
  695. X 'globals'                                                                    °
  696. *(1992 2 29 8 32 29 448)                                                       °
  697.  Fkeys ÉFX 'keys' 'Σ Display keyboard'                                         °
  698.   '''        1  2  3  4  5  6  7  8  9  0  +  ⌡'''                             °
  699.   '''SHFT ╒  ■  ²  <  ≤  =  ≥  >  ⌠  δ  ^  -  ÷'''                             °
  700.   '''ALT  ╘  ƒ  ·  ⁿ  √  Φ  φ  Θ  ╡  τ  σ  !  Æ''' ''''''                      °
  701.   '''         Q  W  E  R  T  Y  U  I  O  P  ╜  ╙  ╧'''                         °
  702.   '''SHFT     ?  ∙  ε  µ  ~  ╞  ╟  ∞  Ω  *  ╕  ╨  ╤'''                         °
  703.   '''ALT      q  w  e  r  t  y  u  i  o  p  æ  ≈  ╥'''                         °
  704.   '''CTRL     ┌  ┬  ┐              ╔  ╦  ╗''' ''''''                           °
  705.   '''          A  S  D  F  G  H  J  K  L  [  ]'''                              °
  706.   '''SHFT      α  ⌐  ╛  _  ╖  ╢  °  ''''  É  (  )'''                           °
  707.   '''ALT       a  s  d  f  g  h  j  k  l  »  «'''                              °
  708.   '''CTRL     ├  ┼  ┤       ─  ═    ╠  ╬  ╣''' ''''''                          °
  709.   '''           Z  X  C  V  B  N  M  ,  .  /'''                                °
  710.   '''SHFT       Γ  π  ∩  ¼  ¥  ÿ  |  ;  :  \'''                                °
  711.   '''ALT        z  x  c  v  b  n  m  Σ  ±  ≡'''                                °
  712.   '''CTRL      └  ┴  ┘  │  ║      ╚  ╩  ╝''' ''''''                            °
  713. X '''Toggle switch to ASCII is CTL-BACKSPACE''' '''CTRL+G gives beep'''        °
  714. *(1992 2 29 8 32 32 460)                                                       °
  715.  Flabel ÉFX 'u╜label w'                                                        °
  716.   'Σ Return 1 if w is not a valid character string label (also excludes        °
  717. Xl.c.)' '╕(u╜(1<µµw)δ1<╧w)/0' '╕(u╜~^/wεlc,uc,dig)/0' 'u╜w[1]εlc,dig'          °
  718. XClc 1 26 abcdefghijklmnopqrstuvwxyz                                           °
  719. XNmodes 2 1 10 1 800 600 65536 8 256 19 10 2826 2830                           °
  720. *(1992 2 29 8 32 33 464)                                                       °
  721.  Fnon ÉFX 'non;t;rc;et;r'                                                      °
  722.   'Σ Ignore invalid keyboard entries, but evaluate valid APL2 expression       °
  723.  s' 'æ╜''       ''' 't╜æ' '╕(0=µ(t⌠'' '')/t)/0' '(rc et r)╜ÉEC t'              °
  724. X '╕(0=rc)/2' '╕((1=rc)doif ''r'')/2' '╕2'                                     °
  725. *(1992 2 29 8 32 32 460)                                                       °
  726.  Fnotb ÉFX 'u╜notb w' 'Σ Remove trailing blanks'                               °
  727.   '╕((1<╧w)doif ''u╜notb■ w'')/0' '╕((1<µµw)doif ''u╜πnotb Γ[2]w'')/0'         °
  728. X 'u╜(1-(,'' ''⌠Φw)∞1)╟w'                                                      °
  729. *(1996 8 13 11 30 19 388)                                                      °
  730.  Fopen ÉFX 'U╜open W;T' 'Σ Activate AP 207' '╕(2=ÉSVO ''D207'')/U╜0'           °
  731.   'T╜ÉEX ''af''' 'T╜207 SVOFFER ''D207'''                                      °
  732. X 'D207╜''OPEN''(0 W 760 540 0 0)' '╕(0=╞╞U╜test)/0 ╪ ╕'                       °
  733. XCp 1 2  "                                                                     °
  734. *(1996 9 8 23 49 43 592)                                                       °
  735.  Fpalette ÉFX 'U╜palette;C;D;T'                                                °
  736.   'Σ Returns an array of 16 color definitions' 'C╜colors ╪ U╜0 5µ0'            °
  737.   '╕(D╜2=ÉSVO ''D207'')/L0 ╪ T╜open ''PALETTE'''                               °
  738.   'L0:D207╜''COLOR''(╞C) ╪ T╜╞2πtest ╪ D207╜''COLMAP'' T ╪ U╜U,[1]2πtest       °
  739.  ' '╕(0<µC╜1╟C)/L0 ╪ U╜(πcolors),'' '',«U ╪ ╕D/0'                              °
  740. X 'T╜ÉSVR ''D207'' ╪ T╜ÉEX ''D207'''                                           °
  741. XCpath 1 13 C:\APL2\WORK\                                                      °
  742. *(1992 2 29 8 32 33 464)                                                       °
  743.  Fpause ÉFX 'v pause w;t'                                                      °
  744.   'Σ Pause, then print w v spaces right and return'                            °
  745. X 't╜(0=ÉNC ''v'')doif ''v╜6''' 'do' '(vµ'' ''),w' 'do'                        °
  746. *(1992 7 16 11 12 35 372)                                                      °
  747.  Fprint ÉFX 'print W;L;D80' 'Σ Print function W on an Epsom printer'           °
  748.   '╕((~(ÉNC W)ε3 4)doif ''''''This is not a function or defined operator       °
  749. X'''''')/0' 'OPEN 80' 'D80╜5' 'L╜,showfn W' 'D80╜π(L⌠r)ΓL' 'CLOSE 80'          °
  750. XCq 0 '                                                                        °
  751. XCr 0                                                                         °
  752. *(1992 2 29 8 32 32 460)                                                       °
  753.  Freplace ÉFX 'u╜v replace w;i;r;s' 'Σ  Replace elements in v in w'            °
  754.   'i╜Γ∞µu╜w' 's╜2πv╜(v⌠'' '')Γv' 'i╜⌡r╜i⌡■Γ[1]w°.=╞v'                          °
  755. X 'u[(εi)/εr]╜s[(εi)/εi⌡■∞µs]'                                                 °
  756. *(1992 2 29 8 32 38 484)                                                       °
  757.  Freset ÉFX 'reset' 'Σ Reset parameters to initial screen'                     °
  758.   'TEST ''G╜4 16 1 255 1 1 0 319 0 199 0 319 0 199 0 0 100 100 0 0 0 1 1       °
  759. X 1 0'''                                                                       °
  760. *(1992 2 29 8 32 33 464)                                                       °
  761.  Fround ÉFX 'u╜v round w' 'Σ Half adjust w to vth decimal'                     °
  762. X 'u╜(╛0.5+w⌡10*v)÷10*v'                                                       °
  763. XCs 1 2 "                                                                      °
  764. *(1992 8 10 10 58 49 588)                                                      °
  765.  Fshared ÉFX 'U╜shared;T;C2;D2;E2'                                             °
  766.   'Σ List all shared variables currently active'                               °
  767.   'T╜2 ÉSVO■''C2'' ''D2'' ''E2'''                                              °
  768.   '╕((δ/2⌠T╜ÉSVO■''C2'' ''D2'' ''E2'')doif ''''''AP 2 not active'''''')/       °
  769. X0' 'C2╜0' 'U╜D2[;4]' 'U╜((εsv)εU)/εsv'                                        °
  770. *(1992 2 29 8 32 33 464)                                                       °
  771.  Fshow ÉFX '╢v show ╢w;╢t;╢b' 'Σ Display and execute ╢w'                       °
  772.   '╢t╜(0=ÉNC ''╢v'')doif ''╢v╜0'''                                             °
  773.   '╕((0=╧╢w)doif ''show ╢w,'''' '''''')/0'                                     °
  774.   '╕((1<╧╢w)doif ''╢v show■ ╢w'')/0' '''      '',╢w'                           °
  775. X '╕((╢v^'':''ε╢w)doif ''╢t╜evaldd ╢w'')/L0' '''ÉEM'' ÉEA ╢w' 'L0:do'          °
  776. *(1992 2 29 8 32 33 464)                                                       °
  777.  Fshowdd ÉFX 'u╜showdd w;a;b;c;r'                                              °
  778.   'Σ  Display a direct definition function'                                    °
  779.   '╕((1=╧w)doif ''u╜showdd Γw'')/u╜0'                                          °
  780.   '╕((3⌠ÉNC╞w)doif ''(ε╞w),'''' is not a function'''''')/0'                    °
  781.   'c╜Γ[2]ÉCR╞w' 'c╜notb(2╞c),(Γ''aw α∙'')replace■2╟c'                          °
  782.   '╕((~''ΣDD''╧3╞2πc)doif ''''''Not a direct definition function'''''')/       °
  783.  0' 'u╜1' 'b╜('' ''⌠╞c)Γ╞c' 'a╜''      ''' 'r╜2╟3πc'                           °
  784.   '╕((3=µc)doif ''a,(╞w),'''':'''',r,(3<µ2πc)/''''   Σ'''',3╟2πc'')/0'         °
  785.   'a╜a,(╞w),'':'',(2╟5πc),'':''' 'b╜(+\r=''('')-+\r='')''' 'b╜b∞0'             °
  786. X 'a╜a,(²3╟(b-1)╞3╟r),'':'',2╟»(b+2)╟r' 'a,(3<µ2πc)/''  Σ'',3╟2πc'             °
  787. *(1992 9 6 10 33 13 332)                                                       °
  788.  Fshowfn ÉFX 'u╜v showfn w;f;n;t;ÉIO' 'Σ Simulate the STSC ÉVR command'        °
  789.   't╜(0=ÉNC ''v'')doif ''v╜,0''' 'ÉIO╜0'                                       °
  790.   'u╜''      '',''╖'',w,''[É]'',(╞v)╞''╖''' 'n╜1╞µf╜ÉCR w'                     °
  791.   'v╜v[0],((1╟v)ε∞n)/1╟v' 'n╜«∞n' 'n╜(n⌠'' '')Γn'                              °
  792.   'f╜(π''['',■n,■Γ''] ''),f'                                                   °
  793.   't╜(1<µ,v)doif ''f╜f[1╟v;]'' ''u╜''''''''''' 'u╜²1╟u,r,,f,r'                 °
  794. X 'u╜((-+/^\'' ''=Φu)╟u),('' ''(r,''      ╖'',date 2 ÉAT w))[╞v]'              °
  795. *(1992 2 29 8 32 33 464)                                                       °
  796.  Fsimdd ÉFX 'u╜simdd w;e' 'Σ Simple direct definition mode' 'u╜0'              °
  797.   '╕((0⌠ÉNC╞w)doif ''''''Already defined'''''')/0' 'e╜''α''ε2πw'               °
  798.   'w[2]╜Γ''u╜'',''α∙ aw'' replace 2πw' 'w╜w[1 3 2]'                            °
  799. X 'w[1]╜Γε''u╜'',(e/''a ''),w[1],'' w''' 'u╜╧ÉFX w'                            °
  800. XAsv╜(100 211 80 206)(210 124)                                                 °
  801. XCt 1 7                                                                        °
  802. *(1992 6 3 9 59 17 424)                                                        °
  803.  Ftab ÉFX 'U╜V tab W;T;A;B;C;D;E;F;G;M;ÉPW' 'Σ Tabulate list W'                °
  804.   'T╜(0=ÉNC ''V'')doif ''V╜0''' 'M╜''Invalid data for tabulation'''            °
  805.   'V╜4╞V' 'ÉPW╜130╛30⌐G╜V[2]+79⌡V[2]=0'                                        °
  806.   'L1:╕((1<╧W)doif ''''''W╜∞0'''' ÉEA ''''W╜πW'''''')/L1'                      °
  807.   '╕(((0=µεW)δ2<µµW)doif ''U╜(~V╧4╞0)/M'')/0'                                  °
  808.   'T╜(1≥µµU╜«W)doif ''U╜πW╜(U⌠'''' '''')ΓU'''                                  °
  809.   'T╜(0<V[1])doif ''U╜(«(Φ1,╞µW)µ(V[3]µ'''' ''''),∞(╞µW)-V[3]),'''' ''''       °
  810.  ,U''' '╕(G<30)/0' 'T╜(F╜µεV[4])+C╜1╟B╜µA╜(V[3],0)╟U'                          °
  811.   'T╜⌐(1╞B)÷1⌐╛(ÉPW+F)÷T' 'U╜(E╜(V[3],C)╞U),[1](B╜T,1╟B)╞A'                    °
  812.   '''D╜εV[4]'' ÉEA ''D╜ÉAV[εV[4]+33⌡V[4]=0]''' 'L0:A╜(T,0)╟A'                  °
  813. X '╕(0=1╞µA)/0' 'U╜U,(((T+V[3]),µD)µD),E,[1]B╞A' '╕L0'                         °
  814. *(1996 9 9 20 2 6 248)                                                         °
  815.  Ftest ÉFX 'U╜test' 'Σ test return code' '╕(0=╞╞U╜D207)/0'                     °
  816. X '''SESSION ABORTED: The return code is '',╞U ╪ DISPLAYπU ╪ ╕'                °
  817. *(1992 9 5 9 10 34 316)                                                        °
  818.  Ftestap ÉFX 'U╜testap W;B;D;S;T'                                              °
  819.   'Σ Test for existence of specific AP"s' 'D╜''D'',■«■W╜,W'                    °
  820.   'T╜W ÉSVO■D' 'U╜0' '╕((^/B╜2=ÉSVO■D)doif ''T╜ÉEX■ D'')/0'                    °
  821.   'T╜''The following Auxilliary Processor'',(S╜1<+/~B)╞''s'''                  °
  822.   'T,(ε(S+1)╙'' is'' '' are''),'' not available'',(~B)/W' 'U╜1'                °
  823. X 'T╜ÉEX■D'                                                                    °
  824. XCuc 1 26 ABCDEFGHIJKLMNOPQRSTUVWXYZ                                           °
  825. XCul 0 ²                                                                       °
  826. *(1996 9 9 20 10 19 332)                                                       °
  827.  Fwarna ÉFX 'warna;T' 'Σ clear AP207 and explai' 'T╜ÉSVR ''D207'''             °
  828. X 'T╜ÉEX ''D207'''                                                             °
  829. *(1996 9 9 20 10 55 476)                                                       °
  830.  Fwarnb ÉFX 'warnb;T' 'Σ clear AP207 and explain'                              °
  831.   '''WARNING: As you study this lesson, try to respond to all requests.'       °
  832.  ',r'                                                                          °
  833.   '''Of course as in all these tutorials, you are encouraged to experime       °
  834.  nt'''                                                                         °
  835.   '''at any pause. When an AP 207 command is issued, there may be an int       °
  836.  erval'''                                                                      °
  837.   '''of a second or two of no action, followed by a flash on the screen.       °
  838.  '''                                                                           °
  839.   '''If the graphic screen does not appear you may invoke the Ctrl-Esc''       °
  840. X' '''command to display any current AP 207 window.''' 'do'                    °
  841. *(1996 7 12 12 20 34 404)                                                      °
  842.  Fwarning ÉFX 'warning;T' 'Σ clear AP207 and explain' 'warna' 'warnb'          °
  843.   '''As in the previous lesson the function "test" is used to verify'''        °
  844.   '''that a command given to AP207 was successful. The function returns'       °
  845.  ''                                                                            °
  846.   '''a nested vector. The first element of this vector may be nested.'''       °
  847.   '''The take (╞) of this element contains the Return Code.'',r'               °
  848.   '''WARNING! Do not issue a TEST command while there is a graphic'''          °
  849.   '''window in the window list.'',r'                                           °
  850.   '''(You may also wish to view function "test" at this point.)'''             °
  851. X 'end'                                                                        °
  852.