🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text
Article #726

Re: String functions in TeX: instr and extract

#726
From: Brian T. Schellenberger
Date: Tue, 05 Sep 1989 17:23
81 lines
3308 bytes
In article <1989Aug31.142820.18594@cs.dal.ca> armstrng@cs.dal.ca.UUCP (Stan Armstrong) writes:
|In article <GRUNWALD.89Aug30090437@anchor.colorado.edu> grunwald@flute.cs.uiuc.edu writes:
|>
|>would
|>
|>\def\VmsFileName#1::#2:[#3.#4]#5.#6;#7{
|> \gdef\nodename{#1}
|> \gdef\devicename{#2}
|>	..etc..
|>}
|>
|>work?
|
|I don't see how that helps.  We currently have hundreds of documents which
|contain \input{vmsfilename} commands.  My bias is against changing all of
|these commands to something else.  That rules out a list of parameters.

No, it doesn't.  You can redefine \input like:

\def \input #1 {\VmsFileName #1 . . . .}
Actually, you would want to add a \endVmsFileName to the end, and supply
it from \input; this prevents you from reading too far if you get an odd-
looking filename.

|Besides, any one of the above parts may be missing from the filename and
|will be defaulted by VMS (except for the name and extension).  

This is a serious problem.  You would actually have to break up the
"VmsFileName" into a sequence of pieces, and supply defaults; eg

\def \Empty {}
\def \VmsOne #1.#2\EndOne {\let\devname=\Empty \let\nodename=\Empty . . .
	\let\ver=\Empty
	\VmsTwo{#1::\EndTwo} \VmsEnd{#2;\EndEnd}
\def \VmsTwo #1::#2\EndTwo {\def\tmp{#2} \ifx\tmp\Empty
	\def\fliename{#1}\else
		\def\nodename{#1} \VmsThree{#2:\EndThree}\fi}
\def \VmsThree #1:#2::\EndThree { . . .}

. . . what we do is to pass the parts to other macros, each of which
is given the delimeter it needs so that TeX will always find it.
Then we test to see if the delimeter was *really* there by seeing if
the second argument was empty.  Now, the only problem with this is that
the extra :: the caller tacked onto the VmsTwo argument is still there
if it *wasn't* empty.  No problem, we just add it onto the stuff that 
\VmsThree expects as delimiter, and it gets neatly tossed for us.

|Furthermore,
|the directory specification may contain any number of subdirectories.
|For example, I need to be able to parse the following:
|
|     \input{devname:file.ext}
|     \input{[dir.subdir1]file.ext}
|     \input{devname:[dir.subdir1.subdir2]file.ext}

No problem.  If you have:

\def \foo #1[#2.#3]#4 {. . .

and you call it as

\foo a[b.c.d]e

Then all that happens is:
#1 <- a
#2 <- b
#3 <- c.d
#4 <- e

No problem.  You can iteratively call an #1.#2 parsing function, if you 
*really* need to know all the components (and quite frankly, I can't see
why you want anything other than 

[#1]

but perhaps there's some good reason . . .
-- 
-- Brian, the Man from Babble-on.		...!mcnc!rti!sas!bts
--
"Every jumbled pile of person has a thinking part that wonders what the part
that isn't thinking isn't thinking of" -- THEY MIGHT BE GIANTS
Technical Details
Message-ID: <1191@sas.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!gatech!mcnc!rti!sas!bts
References: <1989Aug30.133802.15579@cs.dal.ca> <GRUNWALD.89Aug30090437@anchor.colorado.edu> <1989Aug31.142820.18594@cs.dal.ca>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!gatech!mcnc!rti!sas!bts
From: bts@sas.UUCP (Brian T. Schellenberger)
Newsgroups: comp.text
Subject: Re: String functions in TeX: instr and extract
Message-ID: <1191@sas.UUCP>
Date: 5 Sep 89 17:23:27 GMT
References: <1989Aug30.133802.15579@cs.dal.ca> <GRUNWALD.89Aug30090437@anchor.colorado.edu> <1989Aug31.142820.18594@cs.dal.ca>
Reply-To: bts@sas.UUCP (Brian T. Schellenberger)
Organization: SAS Institute Inc, Cary NC
Lines: 81