You are on page 1of 26
Xe Mnterface ‘interface scripts! CHAPTER 10 ‘THE WONDERFUL SCRIPT CALLED "EASY" INTEAPACS SCRIPTS ‘The purpose of the seript EASY is to help us work the reactive typewriter, It dees this by taking in a typed string, and uses it to control the processor. Seripts of this kind are called ‘interface scripts’ between 2 man end s machine, since the boundary between two things, such is called an 'interfs Ordinarily we will have a number of scripts already stored in the menory as forms, ‘Then much of the activity at the Keyboard will consist of calls to such stored scripts. In order to use such stered scripts, it is necessary to type in the shatp signs and parentheses, as well as the name string, as part of the expression for calling the seripts. Typing sharp signs and parentheses 1s a nuisance because these signs aro on the top row of the keyboard, and are out of the ordinary touch Also they require the use of the shift key in addition to the ranges ular key to activate the character. THa SCRIPT ZAsy ‘The script BASY is handy because it automatically inserts these sharp signs and parentheses. with BASY, all we type are the alphabetic character strings, and any conmas where necessary to separate argunents. SS Copyright @) 1972 Rockford Research, Ine. AL) rights reserved. k-2 The script ASY puts dt all together, and makes the call. This is the script for Bast: 1 # (08 , BAST, (#(PS,( a De (PS, 2C#(RS))C 3e ))e(CL,gAst)))* An equivalent form of SASY, gotten by writing out the format characters, and putting it in a Linear form for diagramming purposes, is: #(DS, BAST, (#(PS, (CRLF) #( PSC #4 RS) )( CREF) )#(CL, BASY)})* stored: #(PS, (CRLF) )#(PS,#( (#5) )( CRLF) )#(GL, HASY) rane: EASY To see how EASY operates, we will assume that SASY is started with the call #(CL,EASY)' . The step-by-step action diagrams as follows: 1 of 3s" poumsty/)/= 2. =f" es" Yaccusist)/= 3. of! 25" lpces, (GRIF) )#( es (HRS) META) #C Ce BAC) = a of ss" fos BER Jor #4188) HEA) 2 chyasr)/= prints out: CALF Ps fps est Mas) aE eeu 2850))/= At this point, the RS primitive 4s waiting for input, We cpuld type in the argunents for a call, but it is more instructive to type in the argunents for a define sting expression. This will show the versatility of HAST, With EASY it 4s not necessary to type in the syntactic K-3 character groups #{ or ) . We just type in: typed int DS,AB,HOUSE" The script SASY puts this together in the following way Hoa eC juabaeed 6. =/ PS PS /0S,AB,HOUSS/) (CRLF) #(CL, £4S¥))/= Ht Me i Pe s/ Ps PS / D3 AB HOUSE /(CRLF))#( cL, aasr))/= stored: HOUSE name: AB afl sf ae os ps SP /acx, pas) )/= printed out: CRLF Lo cD =/ Ps L/#CL,BASr))/= At this point, we are back to where we were at line 2. The action repeats, EASY is a loop, and its action 4s controlled at each stage by whet we type in. Notice that the outermost print string primitive is never executed so long as the action renains under control of EASY. After each action carried out by BAST, the format characters GRIF are printed out te show that the action has been completed, and that new dnmput can be provided. Under the control of EASY, we can now call the new form. se do not need to use #(CL,AB)" . Instead, we do this: typed in: GL,AB! we ot tl 10. =f Se - ({cL,aa/)X CRLF) )e( CL, ASY)) /= a Fl ae it. “fs as vs'f Laas (ER) Ho. ASt})/= x4 wo 12, =/ PS PS /HoUSE/(GRLF)) MCL, BASL) }/= XK» Hom 13. =! Ps US: /#( CL, BASY))/= printed ont: HOUSECRLF After this printout, the processor arrives at a stage which is the sane as that diagrammed at line 9 or line 2. The cycle of action starts all over again. Tt ds revealing to see how this looks of the printed page. The following is exactly what we would see: #(CL,ZAst)! DS, AB, HOUSE! CL, AB" HOUSE After HOUSE is printed, the typewriter moves to a new line to wait for nore input. EASY WITH DEFAULT CALLS A very handy feature of the EASY script results from the default call feature of TRAC language. (Sse Chapter 3,) Because of the default call feature, the mnemonic CL does not need to be typed in to produce a call to a form, All we need to type in is the name of the form. With EASY. the text of the form will be typed out, or the execution of the seript will take place automatically. For exanple, while atill working under control of BASY, we de this: AB HOUSE The text of the form was produced. We can use FDR under control ef BAST: FLGR AB! DELETE-H! INSERT-H! ABY MoUSZ And so on, with any other script, With ZASY we oan work PROG.A or PROG.2, or any other script in memory. EASY does have certain simple Linitations that we should be aware of. EASY handles only one primitive at a time, It specifies only single sharp execution. Thus if we want to secure the effect of the call ##(CL,NAME)' 4n order to print out the text of an executable script, or Af we want to print out several lines of characters without lose of the format characters, we must be careful, With EASY, this can be done with the string: PS #P(CL, NAMB)" As an exereise, you should verify why the FS 1s needed in this instence. Work through the diagram of the action. STOPPING BASY Since EASY will continue to reload itself forever, unless sonething 4s done, the question is, how do we step EASY? We could use the panic stop method (See Chapter 2 and Appendix C), but this is a crude method. A brutal, but effective, way to stop EASY is to use the delete definition prinitive by typing dn DD,ZASY! . In this way, we stop EASY by destroying the copy in memory, and it cannot reload itself te continue, A neater, and more devious, method of stopping EASY is to type in several left parentheses. For examplor typed in: (((* aC eC al comes =/ PS PS L(((/) (CRLF) #(CL,Basy))/= eC PC s/ Ps ps /<(() (GREP) (cn, zast))/= At this point the scanner uses the scanning rule for protective parentheses, ‘but there is no matehing end parenthesis to match the parenthesis ahead of the sean pointer, For this reason, the workspace is cleared to: =/Lfl= and the idling program ds reloaded. The precesser 4s no longer under control of BASY, However, a copy of EASY remains in forms storage. A series of right parentheses will also stop EASY. What happens follows from the application of another rule, typed in: )))! oot oi! ps 8 (D))/) GAT) 4( cL, sasr))/= et ekg CD =/ ps Bs [| _/)))(GRLF))9(CL, BASY))/= This is « perfectly good default call. lowever, we presume ‘that there is no form in storage with a moll string for a name, If there is no form, the value string produced by the call is the null string. Then: eC a) =/ ps {es /))(GREF))#(CL, Bast) )/= printed out: "null string" #4) =/f_s_/ (CEP) HCL, EASE) /= printed out: "mull string" X-7 =/L/) (CRLF) )# (CL, BASY)) /= At this point, there is new no matching #( or ##( among the syntactic characters to the left and upstairs to go with the end parenthesis. Again we use the appropriate rule, and the workspace is cleared to: =/Ll= ‘The Adling progran 1s again loaded, and ZASY is no longer in control. SOME REMARKS: when I am working with TRAC language I find that much of the tine I want to work with the help of SisY. t my reactive typewriter, I ase it when commanding the execution of stered scripts, when stering new forms, when using FIXER, and in many other situations. You probably will also find that EASY is a great convenience to use. However, BAST 4s not always helpful. There are sometines tricky situations where you may want to have only the idling program in control. For exanple, you may not want alvays to think through the implications of the expression #(PS,#(#(RS))) that 4s the heart of EAST, I had originally called this script SNGLISH, tecause this soript avoided the clumsy insertion of sharp signs and parentheses, and because ‘the cosmand words to the processor could look very much like ordinary words in English language. However, sone colleagues in Stockholm, Sweden, took a great liking to this handy little script, They used it with Swedish words, They felt that the script should have an international nane, so they renaned at EASY, I felt that the new nane was more appropriate, and that 1s how BASY got its present nano. exancisis THINGS To THINK ABOUT on 3e ae what is the minimum nunber of close parentheses required to stop SASYT Figure dt out from a disgran, Verify your ansver at the reactive typewriter. what is the effect of typing in the balanced parenthesis combination ((((})))! to BASET whet about the combination Y)MCCCr 7 What will the second string do? The second string is not a talanced string. (See Chapter 6, Page ¥I-7, The Rules For Protective Parentheses.) when SAST is in control, what is the effect of typing in ASX" } What Af you do it againt This is an example of one script running inside another. ‘shen BASY 1s in control, what is the result of doing FILGR,EASY' to make a change in the script of SASY? Is this possible? met ‘eegnent. string! ‘universal Turing machine’ CHAPTER 11 PROCEDURES WITH PARAMETERS -- SEGMENT STRING (3S) THE SBGMENT STRING PRIMITIVE (SS) Tho primitive ‘segment string’ with mnemonic SS ranks anong the £1 most important TRAC language primitives. The other four important anes are DS, CL, PS and RS. With just these five primitives, and with a great deal of vork and cleverness, it is possible to get a TRAC language processor to do nearly anything with strings of characters that can be done with the rest of the 29 other primitives in the TRAC language: 4s the reason that I consider these primitives to be so important. ‘The segment string primitive is used to modify the text of forms in storage in such a way that 4t 48 possible to insert new strings into then when they are called ty the call CL primitive. The action of the segment string primitive 4s best shown by an example. We first store a string: #(05,STRING, THE QUICK BROWN FOX JUMPS OVER THE LAZY Doc)* We would Like to call and print out this form, but we wuld like to vary the text each time it is printed out. In particular, we would like to insert the names of other animals in place of FOX and DOG. To do this, ve use the segment string primitive on the form named STRING: * Readers who have @ technical btackeround will understand when I say that with only the three primitives DS, CL and SS, tt 1s possible to construct a ‘universal Turing machine’, 1.6., a machine which can perform any “computation”. With the addition of FS and RS, an Interactive universal Turing machine can be constructed. Jt ts left as a challenge or exercise to the advanced reader to chow how such machines can be constructed with TRAC language scripts. Copyright (C) 1972 Rockford Research, Inc. All rights reserved. ‘segment gap" ‘segmenting etring' 2 ordinal number! m= #(SS, STRING, DOG, FOX)" With execution of this primitive, the text of the form named STRING is Modified. The result of the action can be diagrammed in this way name: STRING text: THE QUICK BROWN /27 JUMPS OVER THE Lazy /i7 The original text of the form has now been modified by the deletion of the twe character strings DOG and FOX. in their place in the diagram are new markers called 'segvent gaps’. The segment gap marker /1/ is placed in the location where the first of the ‘segmenting strings! 0G was found, The first segmenting string was the first argument after the name string in the SS primitive. The marker /27 is pleced in the eeation where the second segmenting string FOX was found. ‘The second ementing string was the second argument after the name string in the SS primitive. ‘The SS primitive can have additional argunents, and each such argument defines an additional segmenting string. The nunber ef the segenting string, and thus the number placed in the segment gap marker, is ealled the ‘ordinal number! of the segment gap marker. It is quite possible that « segnenting string will find more than one matching string in the text of @ form. In such a case, each of the matching strings is deleted and replaced by a segment gap marker having a same ordinal number. In making deletions in the text of the form, all deletions for the first segmenting string are made first, the markers are inserted, and then deletions and insertion of markers for the second segmenting string 1s performed, and so on for as many gegnenting strings 43 are found in the SS primitive. A match te the characters of the toxt of the form is not allowed if it is necessary for a segmenting string to "straddle" a marker to secure a match. A null string for the "segnented" m-3 “segment gap" *torm pointer’ segnenting string matches nothing, and s0 produces no inserted markers. After the text of a form has been completely segmented by SS, the remaining text and markers are replaced in storage, The form in storage 4s now said to be ‘segmented! because the new segment gap markers divide the text inte segments. The new marks are not to be thought of as text characters. Instead they are invisitle markers which are recognizable only by the processor. Since the seguent gap markers create “gaps” in the old text of the form, the description ‘segment markers is appropriate. The forma have a ‘form pointer! which will be described in detail in Chapter i4, For the moment we don't have to worry about it. All ve need to know is that before the action of SS tak place, the form pointer is restored to the beginning of the text of the form so that the whole form 4s acted upons A form, having been sogeented by the action of SS with one set of strings, can be acted upon again by another segnent string prinitive. This action does net disturb the previous segment gap markers, and tt may insert additional markers for new segmenting strings. Kepeated actions on the sane form by the SS primitive can be done any number of times. In each case, the first argunent after the name string argument of the prinitive will produce « segnent gap marker of ordinal munber one, the next argument a marker of ordinal number two, and so ony With the segmented form of our example, we can now insert now strings into the places located by the markers. To do this we uss the call primitive CL. we make use of a feature of the call prinitive which has not previously been explained. In the example, suppose we wish to insert the string TURTLS where 0G had been, and FISH where FOX u-4 had been. To do this, the call expression 48: #MCL,STRING, TURTLE FISH) ‘This produces the value string: THE QUICK BROWN FISH JUMPS OVER THiS LAZY TURTLE Each tine tho call is used, different strings can be placed in the several argument positions of the call. For example: #(CL,STHING,CAT,RAT)* THE QUICK BROWN RAT JUMPS OVER THE LAZY CAT And so on, with the insertion of different arguments each time. The ‘Yext and markers of the form in storage remain unmodified ty the calls. ‘The marker positions are filled only at the tine the string is copied into the workspace, This last action can be diagramed as follows: fame: STRING text: THE QUICK BaOWN /27 JUMPS OVER THE Lazy (77 OM, soe) =/ ps / SL STRING cat RAT /)/= ( «, =/ PS /THS QUICK BROWN AAT JUMPS OVER THE LAZY CAT/)/= Lorn? > =/{_PS THE QUICK Sow RAT JUMPS OVER Tig Lazy cat //= printed out: THE QUICK BROWN RAT JUMPS OVER THE LAZY CAT lifts Since the call vas « single sharp call, the scanning pointer is placed to the left of the text put in the workspace. Thus the new ‘text is completely scanned, and any executable expressions are executed, With a double sharp call, the seanning is resumed te the right of the inserted string, and any executable strings in the new text are not ‘touched. mae5 ‘parameters! ‘formal variables! The segment string primitive expression can contain (for all practical purposes) as many argument strings as are desired. The standard ‘TRAC 7-66 Language processor allows 128 argunent strings for segmenting purposes, (Additional arguments are neglected.) Similarly, the call prinitive can effectively use any nunber of argunent strings, at least 45 many as the upper Limit number for the segment string. When the call prinitive is used with additional argument strings, for filling in the segment marker positions of a segmented form, the additional argument strings are called the 'paransters' of the call. In a similar fashion, the argument strings of the segnent string primitive, which cause the matching and marking of the text of the naned form, are called ‘formal variables’. ‘The first formal variable of the SS primitive erestes markers which are filled ty the first parameter of the CL primitive, and s@ of with the second and subsequent formal variables and psranetors. ch formal variable has an ordinal nunber Also, for descriptive purpot Ss which 4s the same as the ordinal number of the marker symbol which it creates. Similarly, the ordinal number of « parameter of a call is ‘the same as the ordinal number of the segment gap which the parameter string fills at the tine of execution of the call. when a call prinitive has more parameters than the munber of formal variables, or if there is a parameter in a call which has no corresponding marker in the text ef the called form, the parameters are ignored. There is no place to insert such paraneter strings when the form is copied from storage, and so they simply disappear. If there are veral segment same ordinal number, each of these markers gep markers in the form with th is filled with the same corresponding parameter string from the call. ma-6 An example illustrating many of the features of the handling of formal variables in 9S, and the handling of the parameters in a call, 1s the folowing: rene: TAT text: AABDBBBACCKEDBBCGAAA «CSS TAT, .AA, »BBOC,A)* iota that formal variables 1 and 3 are null strings. stored: /27spses(S/ocum/] 2) G5] Me use SS again: #(55,TAT, BD)!" stored: (2) Banfgous yaa The a1] is now used to bring the text of the forn fron storage and to insert the parameter strings: PUCL TAT, O29 sey 56 eB)! result string is: LiBBBCOKLL Several comments are helpful to the understanding of what has just taken place. In the first use of SS, there were five formal variables, of which the first and third were mill strings and produced no markers. Such filler null-string formal variables make it possible to control the ordinal number of the following formal variables. In this case, we wanted to give the marker /2/ to the string AA. Notice that the sequence in which the formal variables are listed in the 5S expression has an important effect on the way the strings match. Matches were nade first for string AAs and later for A. If the sequence had been reversed, a different pattern of markers would have been created, The second application of SS modifies the form as already marked. a7 "forms' After tha second application, the former locations of both AA and 2D are marked with a segment gap marker of ordinal nuuber tuo. This technique of repeated use of SS allows classes of matching strings to be marked in the form with the same kind of segment gap marker. In this sense, the locations of strings AA and SD are marked as being in the same cless with the same mark (27 . The sixth formal variable R in ‘the second application of SS did not find a matching string in the form. In the call, there are six parameters, of which three are null strings. where a null string 4s inserted, the place held by the marker closes up and simply disappears. ‘There is no marker for the sixth parameter R, 20 this paraneter 4s sixply ignored. Only the first and second parameters of this call actually fill any segment gaps. WHY THEY ARE CALLED "FORMS" By this time, it should be evident why stored strings, especially these with segment gap markers, are called 'forms', They are called ‘forms! because they are very much like business forms used in office systems Application Form: (ane) (Address) Tha underlines in this application form correspond to the segment gap Rarkers, since they indicate where the new text is te be inserted when ‘the form 4s used. Such new text corresponds to the text of the Parameters of a call to the form. The words in parenthesis correspond 4n 4 way to the ordinal numbers of the seguent gap markers, since they identify what kind of new text is to be inserted in these locations, In work with TRAC Language, many of the stored strings, especially those of executable scripts, will have segment gaps for the insertion of strings. Other stored strings may not have segment caps. However, they are all called 'forms'. The word form designates the entire object which is stored, It Aneludes the nane string, the stored text string, the segment gaps Af ony, and also a thing called the 'form pointer’ which will be explained in Chapter 1, MAKING PERMANENT CHANGES IN TEXT The previous examples illustrating the use of the segment string prinktive did not result in any permanent changes to the text of the stored form as a result of the call, Sometimes it is desired to permanently change the text of a forn, This is how it 4s done. Presume that the idling progran ds an control: #(0S,PAGE 3, (THIS TEXTCRLFIS SINGLE SPACED))* The form as recorded will now print with single line spacing when it is called out with ##(CL,PAGE 3)', Now suppose we wish to add another spacing line, and change the word SINGLE to DOUBLE. ‘This is what we de firsts #(SS,PAGE 3,(IF) SINGLE)! Two locations in the form are now marked for making insertions. The parentheses are essential in order to protect the format character. We must always watch this, since otherwise the format characters will disaposar while the arguments of the primitive are being forned. The form is new re-defined in this way: a-9 nae: PAGE 3 text: THis TaxToRfijis (27 sPackD #(DS PAGS 3.H(CLPAGE 3, (LFLF), DOUBLE))* Tne diagran of what happens goes as follows: ac rel ) =/ PS 0S PAGE 3 / CL PAGs 3 TFL DouBLe /))/= eH , ———— =/ PS DS PAGE 3 /THIS TEXTCRLFLFIS DOUBLE SPACED{))/= aoe, . —— ) =/ PS { DS PAGE 3 THIS TEXTCRLFLFIS DOUBLE SPACED /)/= stored: THIS TEXTCHLFLFIS DOUBLE SPACED rane: FAGE 3 The use of the double sharp call caused scanning to resume at the right hand end of the new string, and thus the new format characters were not scanned efter the string was put into the workspace. In the argument of the call, the format characters were protected from scanning by the usual protective parentheses, It 4s usually very important to renenber to use the double sharp call 4n all redefinttions such as this. The previous copy of the form named PAGE 3 disappears when the replacement form is stored. It is probably now apparent that the seript of FIXER used this general method for making changes in text. We shell now restudy the action of FIXER in the Light of what we have learned about segment string, HOW FIXER WORKS: The script of FIMEX 4s recopied here for reference: MI = 10 te #CDS , PIRUR Be #(PS,( Be DELETS-))#(SS .WAMB, #A(RS) } 4, #PS.( Se INSERT) )# (DS NAME #6( CL, NAM, ##(RS))) 6. » Te #(SS , FIXER AME)? The stered form, after the action of the segnent string primitive, looks like this: Sos % #P5,( 10. DaLETE-))#(SS,/77 .##(RS)) a HPS, ( a2, IxsenT-))#(08, 47 sbe(CL, 17 ##(85))) 13. The blank lines at and 13 are used to indicate the invisible format characters at the beginning and the ond of the forme de now see that when we call FIXER, supplying the name string of a form in the call to FIXER, the nane string goes inte the three places in FIXGR where there are segment gaps /T/ . In each of these places, 4 primitive expression in the FLU procedure is waiting for a nane string, When PIMER 4s called with a single sharp call, the complete text with these nane string insertions ts scanned and executed. For example, 4f there ie a form with the nane ABC which we desire to nodify, we start the action of FIXSH with the call #(CL,FIXER,ABS)'. ‘The innediate reeult 1s that the text of the FIXER form is copied into the workspace, with the name string ABC inserted in all m-u the 17 segnent gap locations. Since a single sharp call was used, ‘the scanner pointer is reset to the left end of the new string and scanning beginss 1 “ is. #(FS,( 16. DELETE-))#( SS, ABC HRS) ) 1. #(PS,( 18. FINSERT-))#( DS , ABC ,##( CL, ABC (RS) )) 19 The action can be followed step ty step. The format charactors at the very beginning disappear. The print string primitive prints out DELETS~ on a new line because of the format characters in the PS . The action stops at the read string, waiting for something to be typed 4m. We now type in the string to be deleted in the form named ABC. anything typed in to the RS primitive. Upon completion of the input by the RS primitive, the SS primitive has a string fer segmenting a form in its third argument position. The SS primitive then goes to the form named ABC in the memory and finds all instances of a match between the segmenting string and the text of the form. It deletes all instances of such matching strings in the text of the form, and inserts segnent gap markers /T/ . The text of the form is now ready to receive new inserted strings. The print string at line 17 and 18 now prints out the format characters and INSERT- . At this point the processor cannot complete the DS or CL action until the inner nested KS action has taken place. When a string is "procedure* ‘formal variablet a - iz ‘then typed in, this RS receives it and places it in the workspace, without scanning, in the third argument position of the call primitive, The double sharp call now goes into action. It copies the segmented form with name ABC into the workspace with the text string just received by AS inserted inte the segment gap locations. Because of the double sharp on the call, scanning of the reconstituted text is prevented. The DS primitive now has all its arguments, and so it executes. In doing so, it puts the new reconstituted text into storage with the nane ABC. The original form with the sane nane disappears, The action of FIXER is now completed. The text of the form named ABC has now been changed. PROCEDUNSS WITH FORMAL VARIABLES A ‘procedure’ is a stored form whose text contains prinitives which cause some action to take place. A procedure can be brought into execution by a call, A procedure is set up by a script typed in at a keyboard, or possibly by another procedure, Procedures my have fornal gaps in their texts. In the FIXER example of the preceding section, the script which sets up FIXER consists of the lines 1 through 7, The text of the procedure for FIKSR, that 4s, the thing which is stored 4n memory for execution, consists of the lines 8 through 13. The scripts for PROG.A and FROG.B of Chapter 9 produced preeedures, The procedure FIXER has one "formal variable’. When a procedure is called into execution, the paraneters of the call supply the strings which go inte the formal variable locations in the text of the procedure, Sone procedures have marty formal variables, m+ 13 ‘interactive’ In a call to a procedure, if any parameter arguments are missing, er are null strings, the procedure will still go into execution, tut the results my sometines be strange. If there are too many parameters An a call to « procedure, the additional parameters will be ignored. Procedures may have any reasonable number of formal variables. Since ‘the formal variables of a procedure are set up by the sement string primitive, the maximum nunber of formal variables in a procedure is ‘the same as the maxinun nunber for the SS prinitive. ‘The procedure FIXER hes another feature, It is ‘interactive! because it “interacts” with the person at the keyboard by carrying on a conversation, and by getting new data strings fron the keyboard. In the rest of this Manual, we will seo meny examples of procedures. MAKING CHANGES IN PROCEDURES The procedure FIXER unfortunately cannot be used to make repairs in procedures having formal variables. This is a very serious limitation. FIXER works correctly only on all-text forms. At line 10 of the procedure for FIXER, « segment gap of ordinal number one is created in the form being worked on, If the form is a procedure, it may already have segment gaps of ordinal numbers one, two, ete., so FIXER would insert an additional segment gap among these. The segment gaps which are put in by FIXER for locating the corrections would therefore become confused with the original formal variable segnent gaps of the procedure, Then at line 12 of the FOGR procedure, all the segment geps /I7 would be filled with the inserted string, while all the segment gaps of the procedure with munbers two, three, and so on, would be filled with null strings, and would thus disappear. Svidently the procedure ae would be so mutilated by the use of FIXER that 1t would be inoperable. Thus we need a better way to make changes in procedures containing fornal variables. We ean construct such a procedure for repairing other procedures, and one which does not make such a mess of things as FLOUR does. If the troublesone segnent gaps in the forn being operated upon could somehow be eliminated, then FIER could be used to make the repairs. The Segnent gaps can be eliminated ty simply redefining the form, and in the process filling in the segment gep locations with sone sort of distinctive filler strings. If these filler strings are chosen so thet they are Sifferant from any possible character sequence of the text of the form, ‘then we can recover the segment gap locations in the new text after the Tepairs have been made, As a first step, we want to fill in the segnent gep locations. When this is done, we can use FIXER to make the repairs, As the second new step, we then want to recover the segnent gap locations An the repaired text, We can de this with the segment string primitive, with the filler strings as its arguments. For the filler strings in our new procedures, we shall use the string =1= to [411 segment gaps of ordinal munber one, the string =2= to £411 those of munber two, and so on, We are unlikely to find strings such as these in the text of any ordinary proceduré. The purpose of the first new procedure is to fill in the sognent gaps of any form. Its script 1s: =t=)))) #(DS, FIRST, ( #(DS NAME, ##{ CL, NAME, #(5S, FIRST, NAME)" This seript creates a procedure naned FIRST with one formal variable. Af we wish to modify « form er procedure named ITEM. , we call this xr = 15 procedure into action with the call #(CL,FIRST,ITM.4)" , and the formal variables of the form ITEM. will be filled. This procedure will acoonnodate a procedure or text form with segment gaps having formal variables or segnent gaps up to ordinal number 44, After the action of procedure FIRST on the fom te be repaired, it is safe to use FIXEK . We call FIXER into action in the usual manner with #(CL,FIXER,IT@&M.l)' , and respond to the DELETE and INSERT. instructions as usual. The text of the forn has now been changed. Wow we must recover the original segment gaps of the procedure or forn ‘being worked upon, To do this, we use the procedure SECOND set up by ‘this seript: #(DS SRCOND, (#(SS.NAME. =I #(SS SECOND, NAME)! To make the procedure SECOND go into action, we call it by a2=,3=,04=))) #(CL,SHCOND,ITEM.4)' . The procedure or form ITHH.4 has now bean changed and the original formal variables have been restored. This method of repeir of procedures or forms with segment gaps mekes use of three call: #(CL, FIRST, ITEH.4)" #(CL, FIXER TEM, 44)" #(CL,SBCOND,TTAM.4)" This is really not a very good way of doing things, because in order to make a single change, these three coamands have to be typed in to the keyboard, This is work which should be turned over to the processor, With TRAC language, it 4s rather simple to turn this job over to the processor. This is how we do it: x = 16 #(0S FIX, ( #(CL,FIAST, NAME) #(CL, FILER, NAMB) (CL, SECOND, NAME) » #(55 FD, Name)" As wo can see, this script sets up a new form named FIX . It is @ procedure. ‘The SS statement at the end creates a formal variable in the procedure at each eccurrence of the string NAME. Thus when the procedure FIX is called, and the name of the form to be acted upon is given as the parameter, this name of the form is inserted in each segnent gap location of FIX. This name is then used in each of the three calls which make up FIX, If we want to make another change in ITSM.4 , all we have to do now is to give the call #(CL,PIX,ITEM.4)' and all the actions will take place in the correct sequence. This 18 4 good example of the mariner in which one procedure, FIX 4n this ease, can control and make use of other procedures which are already available in memory. Since FIX uses other proceduri at a lower level of control (the calls to them are inside FIX), we can say that FIX is 2 seeond-level procedur There is no limit on the number of levels of control where procedures use other procedures in TRAC language. THE PROCEDURE "FIX" The method of making corrections with nested procedures in the manner just. shown 4s really a patched-up method, The task ef making xt = 17 corrections is very important. It 4s desirable to put all of these actions into one procedure. Then the action does not have to rely upon four separate procedures (FIX, FIXER, FIRST, SECOND) in order to do the Jobs Therefore, we define a new version of FIX with the following script: #(0S FIX, ( #(DS NAMB. H*( CL, NAMB #(PS.¢ DELETE-))#(SS,NAME,##(RS)) Se ele) ) (P54 ‘INSHRT-))#( DS NAMB, #(CL NAME H(RS))) #(SS NAME: » #(SS FIX, NAME)" 5 )2= 23 me) @ desired actions are now all together in one procedur This new procedure can be called into action by either the regular call primitive CL, or the default call. In either case the name of the form te be acted upon is supplied as the parameter to the cell. for example, if ITEM.4 is to be acted upon, either of the two calls can be used: #(CL, FIX, TTEM.) 4 + (FIC, TTEH.4)* If the procedure BASY is in control, FIX is even nore simple to use. We then merely type in: FIX, TTB. in the chapters which follow, there will be many other axamples of the use of the segment string primitive, and of procedures with formal variable mz - 18 EXERCISES 2. What happens when you do #(FIX,FIX)" 7 Can FIX correct mistakes in parentheses in a form? Could it de so if the KS primitive in FIX had only « single sharp Sign? hat would happen? How many formal variables does the expression #(SS,A3A,(A,B,C))" produge in the form: name: AGA text: #(D5,a, (#(CL,B,C))) Answer: none. why not?