> > -----Original Message-----
> > From: Braun, Dick [mailto:[log in to unmask]]
> >
> > I am looking for a utility or some code that will run on a
> > HP3000 that will
> > convert a CSV formatted file that originated on a PC and has been
> > transferred to the HP3000 into fixed width fields in a fixed
> > length record.
> > Anyone have any suggestions?
>
...snip...
> Lacking that, a relatively simple MPEX "expression program/command file"
> should do the trick -- using the logic recently posted to "read" a file,
> you could then use the MPEX "NTOKEN" function to retrieve the "n"th token
> from a string [the "buffer" retrieved by reading the file -- break on
> commas, naturally...] and then use "STRWRITE(field:SIZE)" to convert to
> fixed-length fields.
You wouldn't need MPEX to parse the records read in - just use the WORD
function in an ordinary MPE command file. The following simple example
parses the string in the variable "xstr":
setvar xstr "111,222,33,4444,5,66,,88"
setvar xx 0
while xx < len(xstr) do
setvar xword word(xstr,",",,xx,xx+1)
echo !xword.
endwhile
I would suggest that the command file may not be a simple no-brainer to
write. As well as the code to read the file, there would have to be a template
to format the output as well as some error checking stuff. Still, it would be
relatively straightforward for anyone who has done this sort of thing before.
Good luck, Dick.
----------------------------------------------------------
Greg Chaplin
UniSuper
Level 28, 367 Collins St,
Melbourne VIC 3000,
Australia.
Email: [log in to unmask]
Phone: +61 3 9648 4145
Fax: +61 3 9648 4141
|