Topic: Parsing EBCDIC files with embedded Rec. Lengths (1 of 2), Read 18 times
Conf: VEDIT Macro Language Support
From: Albert Latuch
Date: Thursday, December 08, 2005 03:52 PM

I am a recent converter to VEDIT. Until now I worked mostly in the mainframe world. I am trying to use the macros in VEDIT to do the following. (I am not sure it can be done). I have a need to parse an EBCDIC file that has variable length records. There are Line/Feeds and Carriage/Returns, but they do not indicate line ends. The first four bytes (in hex) tell the length of the follow-on record. i.e. If the first 4 bytes is say x'50' then the length of the first record is 80 bytes. Immediately following that 80 bytes is 4 more bytes giving the length of the next record, etc. to the end of the file. Once the file is parsed, then the first two bytes of the parsed record tell what parsing at the record level must be done to extract the field information. Remember this is all in EBCDIC. To make things more complex, there are embedded .TIFF images in some of the records. My ultimate goal is to be able to break the data first into records, then into labeled fields. Does anyone have any examples or ideas on how I might go about doing this?

 


Topic: Re: Parsing EBCDIC files with embedded Rec. Lengths (2 of 2), Read 31 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Thursday, December 08, 2005 04:39 PM

On Thu, 08 Dec 2005 15:52:00 -0500, Albert Latuch wrote:

>I have a need to parse an EBCDIC file that has variable
>length records. ...
>The first four bytes (in hex) tell the length of the
>follow-on record. i.e.
>...
>My ultimate goal is to be able
>to break the data first into records, then into labeled fields.


Albert:

Welcome to VEDIT and to this forum!


The first part of your problem could be solved with something like
this:


Begin_Of_File

while (! At_EoF) {

Reg_Set(103, "0x") // make the following bytes a hex number
Reg_Copy_Block(103, Cur_Pos, Cur_Pos+4, DELETE) // cut 4 bytes

#103=Num_Eval_Reg(103) // evaluate number from that hex-string
Char(#103) // forward that number of characters
Ins_Newline(1) // insert an End-Of-Line

}



That way it's written for text, no binary.
And I don't know anything about EBCDIC...

But perhaps it may be used as starting point.


Christian