Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Binary to Hex Conversion
Message
 
À
16/06/1997 10:32:47
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00036266
Message ID:
00036529
Vues:
59
> It is a number in string format. Given a record with optional fields, each > bit in the binary string corresponds to a field in the record. For example, > if the fifth field is included, the fifth bit in the binary number is set > on. If the fifth field is not included, the fifth bit in the binary number > is set off. This binary number is then converted to hex and sent at the > beginning of the record. When I get a reply record back, I have to do the > opposite...convert from hex to binary to determine which fields have been > sent. I may not always have 16 bits...it depends on the record type that is > sent. Different record types have a different number of fields. * The simplest, and perhaps most efficient but error-prone method is: m.lcInString = "C3D1" m.lcOutString = "" for m.lpCount = 1 to len(m.lcInString) do case case substr(m.lcInString,m.lpCount,1) = "0" m.lcOutString = m.lcOutString + "0000" case substr(m.lcInString,m.lpCount,1) = "1" m.lcOutString = m.lcOutString + "0001" case substr(m.lcInString,m.lpCount,1) = "2" m.lcOutString = m.lcOutString + "0010" case substr(m.lcInString,m.lpCount,1) = "3" m.lcOutString = m.lcOutString + "0011" case substr(m.lcInString,m.lpCount,1) = "4" m.lcOutString = m.lcOutString + "0100" etc. endcase endfor
Paul Russell
EMail: prussell@fox.nstn.ca
Phone: (902) 499-5043
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform