🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text
Article #677

String functions in TeX: instr and extract

#677
From: Stan Armstrong
Date: Wed, 30 Aug 1989 13:38
24 lines
1652 bytes
I need to do some simple string manipulation in TeX.  I would like to
redefine the \input command so that an alternate file extension is used
when the file is not found.  In order to do this, I need an instr function
to find the position of the file extension within the filename, and an
extract function to remove the extension.  I've looked through the TeXbook
and could not find anything useful, and I've also looked through an issue
of Tugboat which had an example using \expandafter to locate a substring
within a string, but did not return the location of the substring.

Help!  I don't have a lifetime to devote to learning TeX so that I can
write these functions myself.  Surely someone out there must have a working
solution.

It would be nice if the instr function could find the first occurence after
a specified position within the string, although that could be simulated
using the extract function.  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

Any hints, suggestions, etc. would be deeply appreciated.

Ben Armstrong (UUCP: armstrng@dalcs BITNET: armstrong@STMARYS)
Technical Details
Message-ID: <1989Aug30.133802.15579@cs.dal.ca>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!att!dptg!rutgers!cs.utexas.edu!uunet!cs.dal.ca!armstrng

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!att!dptg!rutgers!cs.utexas.edu!uunet!cs.dal.ca!armstrng
From: armstrng@cs.dal.ca (Stan Armstrong)
Newsgroups: comp.text
Subject: String functions in TeX: instr and extract
Message-ID: <1989Aug30.133802.15579@cs.dal.ca>
Date: 30 Aug 89 13:38:02 GMT
Organization: Math, Stats & CS, Dalhousie University, Halifax, NS, Canada
Lines: 24