1. Euphoria and fixed field record formats .....
- Posted by John Dutcher <jfdutcher1958 at yahoo.com> Nov 20, 2004
- 555 views
I am new but have used Euphoria very happily and effectively for several projects and really like it. I am interested in how those who have a depth of knowledge do code to handle fixed format data records usually viewed as structures as in Cobol, Basic etc. I processed them in a CGI app using Euphoria by just "slicing" every field from the record level "sequence"...but had the luxury that all data was "text" or character. But consider a tiny sample Cobol created record: 01 AAA. character ---> 03 BBB pic x(12). packed decimal ---> 03 CCC pic s9(5) comp-3. zoned decimal ---> 03 DDD pic s999 display. signed binary ---> 03 EEE pic s999 comp. This representative sequence often repeats in some pattern many times per record. What is the "right" way to address these values after one has read them into a sequence or object that is the result the I/O operation ?
2. Re: Euphoria and fixed field record formats .....
- Posted by Jonas Temple <jtemple at yhti.net> Nov 20, 2004
- 539 views
John Dutcher wrote: > > I am new but have used Euphoria very happily and > effectively for several projects and really like it. > > I am interested in how those who have a depth of knowledge do code to > handle fixed format data records usually viewed as structures as in > Cobol, Basic etc. I processed them in a CGI app using Euphoria by > just "slicing" every field from the record level "sequence"...but had > the luxury that all data was "text" or character. > > But consider a tiny sample Cobol created record: > 01 AAA. > character ---> 03 BBB pic x(12). > packed decimal ---> 03 CCC pic s9(5) comp-3. > zoned decimal ---> 03 DDD pic s999 display. > signed binary ---> 03 EEE pic s999 comp. > > This representative sequence often repeats in some pattern many times > per record. > > What is the "right" way to address these values after one has read > them into a sequence or object that is the result the I/O operation ? > Are the records in a database (i.e. Mainframe) or on the local PC? If it's on a mainframe are they flat files or do they have external descriptions? If the data is on the PC then you'll just have to substring the sequence to get the data. The trick is going to be converting the packed decimal into a Euphoria atom. I think there is an EBCDIC translation library somewhere in the archives that might help with the text stuff. I work on the AS/400 so I use Client Access to get to the database and CA has functions to convert from packed to a float. Jonas Temple http://www.yhti.net/~jktemple
3. Re: Euphoria and fixed field record formats .....
- Posted by "Mike Sabal" <Sabal.Mike at notations.com> Nov 21, 2004
- 558 views
>>>guest at RapidEuphoria.com 11/20 9:46 am >>> I am new but have used Euphoria very happily and effectively for several projects and really like it. I am interested in how those who have a depth of knowledge do code to handle fixed format data records usually viewed as structures as in Cobol, Basic etc. What is the "right" way to address these values after one has read them into a sequence or object that is the result the I/O operation ? -------------------- There really isn't one "right" way to handle fixed length records. Best practice is generally dictated by what you intend to do. If you are looking to interface with an external library (.dll or .so) that requires structures, your best bet is to search the mailing list archives for some at length discussions on this topic. I know win32lib does a fine job of handling this problem, as well as several other libraries. If you simply need to store data that will only be used by a Euphoria program, I wouldn't even worry about fixed formats. Your program will be better written by validating the data at the time of entry. The last case, a fixed length record being used by non-Euphoria programs, will require a bit of special handling. It should be fairly simple to write a routine that takes your 4 fields as parameters, validate them, pad or truncate the lengths (or using sprintf for numerical fields), and write the resulting data to a file. I hope I wasn't too vague. Good luck. Michael J. Sabal