c Xerox Corporation 1979, 1980Inter-Office MemorandumToAlto UsersDateDecember 30, 1980FromMartin Newell, Lyle RamshawSubjectCommand files with parametersFiled on[Maxc]Do.pressXEROX INTRODUCTIONThe program Do acts on a .do file as @ acts on a .cm file, except the file may containparameters for substitution.ExampleTo edit a file on a remote file server, let edit.do contain://Edit file #1 on file server #2Ftp #2 retrieve/u #1Bravo/n #1Ftp #2 store/c #1Then the command:Do edit spec.bravo maxcwill generate://Edit file spec.bravo on file server maxcFtp maxc retrieve/u spec.bravoBravo/n spec.bravoFtp maxc store/c spec.bravoWhere to find DoDo is on: [Maxc]Do.runSPECIFICATIONCommand line syntax is:Do [ [param1 [param2 [... [paramN]...]]]]Missing items will be requested interactively (see below). Do first substitutes the givenparameters into the text of file, and then presents that text to the Exec as a commandstring. Multiple spaces are equivalent to a single space as a separator of items on thecommand line. tpqX]g~ri ams1qX *+s2Lq ]s1q*+s2Lq YsF1qStqX Juv Gq wqCF B?<<x:9w 74q1x.qq +Ex*)(=& #q b 7uv  qx/qD1I X) 9Qd 2Parameter SpecificationThe nth parameter is substituted for each occurence of #n or #n# in , the latterform being required when the parameter is to be followed by one of: {digit, #, ?, =, *}.The latter form may always be used if in doubt.The string ## should be used to indicate a literal # whenever it is to be followed by oneof: {digit, #, ?, =, *}.In specifying the parameters, escape is the symmetric double-quote character ("); thus," is equivalent to an uninterpreted . This is useful for including spaces in aparameter, e.g.Do file.do a" parameter" with" five" internal" spacesTo include a symmetric double-quote itself, type two of them: "".A null actual parameter may be specified by typing the single-character string ``-'' on thecommand line, or interactively to the request for that parameter. In those rare instanceswhere you really want to specify ``-'' as an actual parameter, you can convince Do not totranslate ``-'' into the null string by typing ``"-'' instead. Null parameters may also bespecified interactively by typing to the request for that parameter.Missing ParametersPrompts: If no value for the nth parameter is given in the command line then the value ofthat parameter will normally be requested interactively, using a standard prompt. Theprompt may be changed by including it with the first appearance of that parameter in the.do file, thus:#n?prompt#where n is the number of the parameter as before, and prompt is the required promptstring, conforming to the rules for typing parameters (i.e. using " as escape).Defaults: Another possibility when no value for the nth parameter is given is to provide adefault in the .do file, thus:#n=default#where default is the default value of parameter n, again conforming to the rules for typingparameters.The trailing # can be omitted from a prompt or default if the next character is or. Again, if in doubt then include the trailing #.Automatic file name extensionOn file lookup if includes an extension then no other extension is attempted.Otherwise the extensions .do and .cm are attempted, followed by an attempt at the filename with no extension. If that fails, or if no file name was given, the user is prompted forthe correct file name. Any typed parameters are retained and should not be retyped.Nfq b^wq 'wqwq]n<[/XCW;TWRK QMx5JqAGUF!9D}FB[AuI >J;wqwq,9Q8@63gwqwq0;wq/wq.O+wqwq%*&wqwq#wq#wq#"- 9!}6 R'<>N9  T9U 3NestingDo does the right thing if embedded in a string of commands. Do's may be nestedarbitrarily deep.Mapping featureIt is often convenient to be able to perform some operation once for each file name in alist. If the first occurrence of the nth formal parameter in the .do file includes a trailingasterisk, as in #n*, then Do will instantiate the .do file multiple times, first substituting thenth actual parameter for the nth formal parameter, and then the (n+1)st actual for the nthformal, and so on until the actual parameters are exhausted. Only the highest numberedformal parameter may be mapped in this way. Note that it is impossible to default anyparameters when using this mapping feature. A couple of hacksThe ^U command in the Executive can be used to create a special purpose .do file inLine.Cm with only a few keystrokes: for details on ^U, see the Executive documentation.Also note that, when typing a parameter interactively, it is perfectly legal to supply thestring ``//''; this can cause wondrous things to happen later, since it causes the Executive toignore the rest of the line on which it appears. EXAMPLE 1As another version of the example given at the beginning, but using a prompt and adefault, let edit.do contain://Edit file #1?Edit" file:# on file server #2=Ivy#Ftp #2 retrieve/u #1Bravo/n #1Ftp #2 store/c #1[Note: neither of the trailing #'s above is necessary - they were included for clarity]1.The command:Do edit spec.bravo maxcwill generate (the same as in the initial example since all parameters are given)://Edit file spec.bravo on file server maxcFtp maxc retrieve/u spec.bravoBravo/n spec.bravoFtp maxc store/c spec.bravo2.The command:Dowill provoke the questions (and possible answers):Do file: editEdit file: spec.bravoNfq b^2]n ZCW<U%wq7T wqORwqwqwqwqQ<O8M, JG7F$ LDQC.2A1 >muvu;Aq.$96x253 2.q7+ (x%Xq))"-x* %uq Jxq2x o (9X4and generate://Edit file spec.bravo on file server IvyFtp Ivy retrieve/u spec.bravoBravo/n spec.bravoFtp Ivy store/c spec.bravo3.Usually the command will be somewhere between these two extremes, making use ofthe defaulting, e.g.Do edit spec.bravowhich would generate the same command file as in the previous example, but withoutany prompting.EXAMPLE 2Here is an example that uses the mapping feature. Suppose that your Bravo is configuredso that, when invoked in the mannerBravo/H spec.bravo 3it will print three copies of spec.bravo and then quit. You can use Do to help you printmany files by putting the following text into the file hardcopy.do://Hardcopy #1 copies of #2* firstBravo/H #2 #1//then go on and do the restThen, giving the Executive the command:Do Hardcopy 5 *.bravowill print five copies of all of your .bravo files.Nfqb ^x)]n[ZfW;q7URxO`q:M JuvuEq:DZ#A.x>q<<C9Tx!7 6K3 q'/x,q3D ,8;MATH  TIMESROMAN  TIMESROMAN  TIMESROMANLOGO TIMESROMAN  TIMESROMAN TIMESROMAN  HELVETICA M ~j/x*do.bravoRamshawDecember 30, 1980 11:16 AM