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 10:14:43
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00139013
Message ID:
00139021
Vues:
46
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform