export ascii and insert a text file
Brian K. White
brian at aljex.com
Wed May 11 10:46:51 PDT 2005
----- Original Message -----
From: "Enrique Arredondo" <henry at vegena.net>
To: <filepro-list at lists.celestial.com>
Sent: Wednesday, May 11, 2005 10:54 AM
Subject: export ascii and insert a text file
> How can I make this happend :
>
> I'm generating a XML document to a ascii file , but Under the tag
> "ImageFile" I need to do a quick system command that will convert a JPG
> file to a text file and stick in inside this tag and then close the tag.
>
> So the Idea is to do this :
>
> Then : "<ImageFile>"{system noredraw "base64 chevy350.jpg >
> chev350.64"{"</ImageFile>" ;gosub writeit
>
> How should I import the chev350.64 to this line ? using a GETENV or import
> ascii line by line ?
Neither I think.
assuming the export filename is in ef
and the jpg filename is in jf
My first suggestion as the best balance between efficient and robust:
close export
system noredraw "base64" < jf < ">>" < ef
reopen export in append mode
Second best suggestion:
If base64 was only going to generate a few lines it'd bebetter to use
readline() to read the base64 file, which you could still do because
handily, base64 output is always made of short lines, so the variable used
in readline() can safely be 70 or 80 bytes. But since base64 will generate
hundreds or thousands of lines, it's ok to close the export, let the system
command dump it's output appending to the file all at once, then reopen the
export in append mode.
Interesting experiment but unwise I think:
You could also use user, but you'd have to be really careful to test for the
last line of output so that you know not to try to read another line or else
it'll hang.
user is probably the ultimate in efficiency in this case, but either my
first suggestion or using readline will be safer from hangs and zombie
base64's.
You would make a shell script that read a line for a filename, and runs
base64 on it, then adds one blank line (if base64 doesn't already do that),
then loops to read another filename.
The script , call it fpb64, would look something like this:
while read filename
do
base64 $filename
done
Then processing looks roughly like this:
...
then: gosub dob64
...
dob64: if:
then: user b64 = fpb64
if: ' write filename
then: b64 = jf
b64loop: if: ' read a line of b64 data
then: bd = b64
if: bd eq ""
then: return
if:
then: 'write bd to the export here
if:
then: goto b64loop
Brian K. White -- brian at aljex.com -- http://www.aljex.com/bkw/
+++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++.
filePro BBx Linux SCO Prosper/FACTS AutoCAD #callahans Satriani
Brian K. White -- brian at aljex.com -- http://www.aljex.com/bkw/
+++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++.
filePro BBx Linux SCO Prosper/FACTS AutoCAD #callahans Satriani
More information about the Filepro-list
mailing list