Re: Convert Packet decimals comp-3 and comp-6
Hi Peter, So PIC9(5) COMP-3 is 5 bytes / 2 = 2.5 rounded to 3 bytes? Also I see that the first record contain some garbage or almost I don't have idea how decode it. Salut, Josep -- View this message in context: http://runtime-revolution.278305.n4.nabble.com/Convert-Packet-decimals-comp-3-and-comp-6-tp3498822p3508877.html Sent from the Revolution - User mailing list archive at Nabble.com. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Convert Packet decimals comp-3 and comp-6
Josep On 9 May 2011 18:28, JosepM jmye...@mac.com wrote: Hi Peter, So PIC9(5) COMP-3 is 5 bytes / 2 = 2.5 rounded to 3 bytes? No, PIC9(5) is a 3 byte field - 5 digits + sign - each of which is 4 bits long. When a PIC9(5) field is included in a record the compiler might insert a 'padding' byte so that the next field starts on a 'word' boundary. I'm fairly certain that IBM COBOL pads records, I don't know about ACCUCOBOL. Also I see that the first record contain some garbage or almost I don't have idea how decode it. It is probably a header record. Regards Peter ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Convert Packet decimals comp-3 and comp-6
Hi Josep The file come from a PC-MSDOS with a old ACUCOBOL-GT application, it's the customer file data, I have the File Definition with the structure of record. Then the test will be ASCII encoded so you don't need to worry about having to convert the text; It's a one-off conversion but I have many files to convert. So my plan was read the file as chunks of bytes, and for each record (divide the lenght of the file by the lenght of a record) get the chars for each field. Making a conversion for the comp-3 and comp-6 data. That sounds feasible. One thing that you may need to watch out for is that the records may have been padded by COBOL when written. For example, a PIC9(5) COMP-3 file could possibly be padded with one byte so that it takes a multiple of either 2 or 4 bytes. Regards Peter ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Convert Packet decimals comp-3 and comp-6
Hi Josep On 6 May 2011, at 00:36, JosepM wrote: Hi, I need to read a file from a Cobol application and import the data files. I have the file description but I don't have idea how convert the decimals fields. 01 NAME PIC X(30) -- This I guess is 30 chars 02 CODE PIC 9(5) COMP-6 -- This is five digits with packet decimal format. I haven't heard of COMP-6 though it is a very long time since I last wrote a COBOL programme, probably the early nineties. I managed to find this The format of a COMP-6 item is identical to a COMP-3 item except that it is unsigned and no space is allocated for the sign. Thus there are two decimal digits per byte, and the actual size of the item is determined by dividing its PICTURE size by two and rounding up. at http://ibmmainframes.com/about146.html Comp-3 stores data in a BCD -- binary coded decimal -- format with the sign after the least significant digit. I would guess that the COMP-6 field would be Bits 1-4 : First Digit Bits 5-8 : Second Digit Bits 9-12 : Third Digit Bits 13-16 : Fourth Digit Bits 17-20 : Fifth Digit Bits 21-24 : to be ignored. From the PIC 9(5) the field is an integer. So the code to extract the value would need to be something along the following lines. It assumes that you treat the COBOL data as a string. I'm afraid that I haven't been able to test it. set tCode to 0 # first byte put char 1 of tCOBOLCODE into tChar # first digit put charToNum(tChar) bitAnd 240 into tInt divide tInt by 8 add tInt to tCode multiply tCode by 10 # second digit put charToNum(tChar) bitAnd 15 into tInt add tInt to tCode multiply tCode by 10 # second byte put char 2 of tCOBOLCODE into tChar # third digit put charToNum(tChar) bitAnd 240 into tInt divide tInt by 8 add tInt to tCode multiply tCode by 10 # fourth digit put charToNum(tChar) bitAnd 15 into tInt add tInt to tCode multiply tCode by 10 # third byte put char 3 of tCOBOLCODE into tChar # fifth digit put charToNum(tChar) bitAnd 240 into tInt add tInt to tCode I'm sure many people on this list can come up with a much better solution. Regards Peter ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Convert Packet decimals comp-3 and comp-6
Many thanks! I will try... But how I must read the file? as file: or as binfile:? I mean how get the chars... :( Salut, Josep -- View this message in context: http://runtime-revolution.278305.n4.nabble.com/Convert-Packet-decimals-comp-3-and-comp-6-tp3498822p3502906.html Sent from the Revolution - User mailing list archive at Nabble.com. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Convert Packet decimals comp-3 and comp-6
I suspect the answer partly lies in knowing where the file originated from and where you are reading it from. (By where, I mean what computer/operating system.) By the way, one thing that is easy to overlook is that if the file has come directly from an IBM Mainframe any character strings will most likely be EBCDIC encoded rather than ASCII and will need converting. By the way, is this a one-off conversion or something that you want to do regularly? Regards Peter On 6 May 2011, at 22:03, JosepM wrote: Many thanks! I will try... But how I must read the file? as file: or as binfile:? I mean how get the chars... :( Salut, Josep -- View this message in context: http://runtime-revolution.278305.n4.nabble.com/Convert-Packet-decimals-comp-3-and-comp-6-tp3498822p3502906.html Sent from the Revolution - User mailing list archive at Nabble.com. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode