Path: utzoo!utgpu!watmath!att!dptg!rutgers!iuvax!mailrus!ncar!tank!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.text Subject: Re: String functions in TeX: instr and extract Message-ID: <19344@mimsy.UUCP> Date: 31 Aug 89 03:21:13 GMT References: <1989Aug30.133802.15579@cs.dal.ca> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 39 In article <1989Aug30.133802.15579@cs.dal.ca> armstrng@cs.dal.ca (Stan Armstrong) writes: >I need to do some simple string manipulation in TeX. The usual trick is to define delimited macros, e.g., \def\@get#1.#2\@@{\def\@got{#1}} \def\namepart#1{\@get#1.\@@\@got} then `\namepart{a.b}' expands to \@get a.b.\@@, which makes \@get's #1 be `a' and #2 be `b.'. If you give \namepart no `.', the second `.' supplies the one \@get needs, so that \namepart{a} expands to \@get a.\@@, making #1 be `a' and #2 be empty (an implicit space, I think; see _The_TeXbook_ to be sure). A similar (but different) trick can be used to extract the `ext' part `b'. It is a bit more complicated. However: >I would like to redefine the \input command so that an alternate file >extension is used when the file is not found. You cannot achieve this. The only way to test for a file's existence is to open it; and open always succeeds. If the file cannot be opened, TeX interacts with its operator to get a different name---and it will not take `no name' for an answer! (I consider this a bug.) >... I need to recognize the first period which is >not between square brackets as the beginning of the file extension since >VMS filenames are of the form: > >nodename::devicename:[directory.subdirectory]filename.extension;version Not that it will do any good (see `However' above), but \catcode tricks can help here. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris