[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Should I improve TmpCreat?



On Thu, 28 May 2009 13:21:03 -0700, Jim Leonard wrote:

> Or, make your program an *actual* template program by allowing the
> templates to have user-replaceable fields in them, similar to how mail-
> merge functionality works in word processors.  That is functionality not
> easily duplicated at the DOS command-line.  While there still isn't much
> of a need for that, at least it will be something that there is no easy
> equivalent for in the DOS world for people who don't own word processors.

I do this all the time, mostly to generate web pages that differ only in
such tings as a number, or to generate fully formatted links from a tab
delimited list of names and (partial) links.  Awk one liners and pattern
files.  For example, just yesterday, I had to redo several hundred pages
that are wrappers for images - they reload the image every 18 seconds (the
images are one-shot animations that need to be reloaded to cause them to
reanimate).  This was what I did

  for %A in (room_images\*.gif) do (awk "{gsub(/ROOM/, \"%~nA\");print
$0} room_html.pattern > room_images\%~nA.html)

That replaced the ROOM marker with the base name of the image file (the
room number) in two places in the pattern file and wrote the modified copy
to the same directory as the images with the room number as the name and
.html as the extension.  A similar scheme is used to generate the body
parts of very complex index menu pages where the source file consists of
people or laboratory names and room numbers and the pattern file contains
the link string with markers for ROOM and NAME.  That stuff is part of a
touch screen operated building directory built around Apache and Firefox
(in kiosk mode).

WHile I'm working in XP, gawk (awk) is available for just about every OS
that has a command prompt or terminal interface and so is functionality
similar to CMD's FOR, though it might be necessary to parse the file name
in awk itself and write to the file inside the script instead of by
redirection - in most cases, it would still be a one-liner.

-- 

T.E.D. (tdavis@mst.edu) MST (Missouri University of Science and Technology)
used to be UMR (University of Missouri - Rolla).