[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.5.4 `extract' - extract text from another file

Usage: (extract file-name marker-fmt [ caveat ] [ default ])
This function is used to help construct output files that may contain text that is carried from one version of the output to the next.

The first two arguments are required, the second are optional:

The resulting strings are presumed to be unique within the subject file. As a simplified example:

 
[+ (extract "fname" "// %s - SOMETHING - %s" ""
"example default") +]
will result in the following text being inserted into the output:

 
// START - SOMETHING - DO NOT CHANGE THIS COMMENT
example default
// END   - SOMETHING - DO NOT CHANGE THIS COMMENT
The "example default" string can then be carried forward to the next generation of the output, provided the output is not named "fname" and the old output is renamed to "fname" before AutoGen-eration begins.

NOTE:
You can set aside previously generated source files inside the pseudo macro with a Guile/scheme function, extract the text you want to keep with this extract function. Just remember you should delete it at the end, too. Here is an example from my Finite State Machine generator:

 
[+ AutoGen5 Template  -*- Mode: text -*-
h=%s-fsm.h   c=%s-fsm.c
(shellf
"[ -f %1$s-fsm.h ] && mv -f %1$s-fsm.h .fsm.head
[ -f %1$s-fsm.c ] && mv -f %1$s-fsm.c .fsm.code" (base-name)) +]

This code will move the two previously produced output files to files named ".fsm.head" and ".fsm.code". At the end of the 'c' output processing, I delete them.

Arguments:
file-name - name of file with text
marker-fmt - format for marker text
caveat - Optional - warn about changing marker
default - Optional - default initial text


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Bruce Korb on May 5, 2003 using texi2html

Viewable With Any Browser   AutoGen Home