Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating a 'packed' decimal for IBM mainframe upload
Message
De
21/09/1998 12:09:03
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00139013
Message ID:
00139080
Vues:
32
Hi Rick,

Glad to hear that the routine does it - I had assumed (there I go again) that one would need to use one of the binary functions of VFP to get the result required, but that just goes to show that there are many ways to skin a cat with FP/VFP!

I always understood BCD to be a predecessor of EBCDIC (from 1401/707X era). But it doesn't really matter, now that Jon has what he needs.

Yes, the good ol Green Card certainly was referenced tens of times daily! I still have one, and its following Yellow Card.

Cheers,

Jim N


>Hi Jim,
>
>Man, this goes back a few years, doesn't it?
>
>I was intrigued by Gerry's routine that Christof posted, and sure enough it works, generating the correct packed decimal strings. The other mainframe format is the one byte per digit format which is (as I recall) of the form Fx|Fx|Fx|Sx, where hex F0 thru F9 are the digits and 'S' is the sign (hex C, D, or F). Both are BCD, I guess, in the sense that BCD means EBCDIC (extended binary coded decimal interchange code) as opposed to ASCII.
>
>BTW, did you know that VFP5 comes with a hex editor that you can use to see this kind of stuff in a file? Look for HEXEDIT.APP in VFP5\TOOLS\HEXEDIT.
>
>While I was thinking about this, I dug around in my desk and found my old IBM 360 'green card'. Do you remember those? They were indispensible at one time. Guess it belongs in a museum now, but it's still useful now and then!
>
>Rick
>
>>Hi Christof,
>>
>>I'm not so sure that "BCD" is "packed Decimal". My brief review of the code seems to confirm this.
>>
>>In case you are unaware, "packed decimal" (in IBMese) takes the form:
>>
>>|nn|nn|nn|ns| where "n" is a number between 0-9, the "|" signifies a byte delimiter (so the example has 4 bytes (character positions) and "s" is the sign (I seem to remember that "B" and 'E" are negative indicators while "A", "C" "D" and "F" ("F" being standard) are positive).
>>
>>Cheers
>>
>>Jim N
>>
>>>Hi Jon,
>>>
>>>Gerry H. Schmitz posted the following code a long time ago on CompuServe (reformatted by myself):
>>>
>>>*==================================================
>>>* convert a numeric value into BCD format
>>>*==================================================
>>>Parameter tnNumber, tnDigits, tlSigned
>>>
>>> *-----------------------------------------------
>>> * get number of digits, must be odd
>>> *-----------------------------------------------
>>> Private lnDigits
>>> lnDigits = tnDigits
>>> If lnDigits%2 == 0
>>> lnDigits = lnDigits+1
>>> Endif
>>>
>>> *-----------------------------------------------
>>> * build number string
>>> *-----------------------------------------------
>>> Private lcNumber, lcSign
>>> If tlSigned
>>> If tnNumber < 0
>>> lcSign = Chr(48+13)
>>> Else
>>> lcSign = Chr(48+12)
>>> Endif
>>> Else
>>> lcSign = Chr(48+15)
>>> Endif
>>> lcNumber = ;
>>> ChrTran( PadR(tnNumber,20), " +-,.E*", "" )
>>> lcNumber = PadL(lcNumber,lnDigits,"0") + lcSign
>>>
>>> *-----------------------------------------------
>>> * convert to BCD string
>>> *-----------------------------------------------
>>> Private lcBCD, lnLoop, lnLow, lnHigh
>>> lcBCD = ""
>>> For lnPos = 1 TO Len(lcNumber) / 2
>>> lnLow = Asc(SubStr(lcNumber,lnPos*2,1))-48
>>> lnHigh = Asc(SubStr(lcNumber,lnPos*2-1,1))-48
>>> lcBCD = lcBCD + Chr(lnLow+16*lnHigh)
>>> Endfor
>>>
>>>Return lcBCD
>>>
>>>Christof
>>>
>>>>Hi everyone,
>>>>I need to create an upload file to be processed by an IBM 3090 how do I convert my text certain 'fields' in my text file to be packed decimals....
>>>>Jon
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform