Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Your Blog, 5. February 2010
Message
De
12/03/2010 04:03:11
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Your Blog, 5. February 2010
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01454095
Message ID:
01454095
Vues:
239
Hi Thomas,

I found the Text2Bin example in your blog.

I found it very usefull - to convert integers to binarys.

Since I have no idea how to comment your blog, I like to share the code via UT
*betweeen
**?lcBinString

lnI   = 0x000109C1
lcBin = Int2Bin(lnI)
lcNib = Int2Nibble(lnI)
lnBin = Bin2Int(lcBin)
lnNib = Nibble2Int(lcNib)

?lnI,TRANSFORM(lnI,'@0')
?lcBin,lnBin,TRANSFORM(lnBin,'@0')
?lcNib,lnNib,TRANSFORM(lnNib,'@0')

FUNCTION Nibble2Int AS INTEGER
 LPARAMETERS;
  tcString

 RETURN Bin2Int(CHRTR(tcString,' ',''))
ENDFUNC &&Nibble2Int AS Integer

FUNCTION Bin2Int AS INTEGER
 LPARAMETERS;
  tcString

 RETURN INT(VAL(STUFF(TRANSFORM(0h+Bin2Char(PADL(tcString,32,'0'))),2,1,'x')))
ENDFUNC &&Bin2Int AS Integer

FUNCTION Int2Nibble AS STRING
 LPARAMETERS;
  tiInt

 RETURN STUFF(STUFF(STUFF(STUFF(STUFF(STUFF(STUFF(Int2Bin(tiInt),29,0,' '),25,0,' '),21,0,' '),17,0,' '),13,0,' '),09,0,' '),05,0,' ')
ENDFUNC &&Int2Nibble AS STRING

FUNCTION Int2Bin AS STRING
 LPARAMETERS;
  tiInt

 RETURN Char2Bin(EVALUATE(STUFF(TRANSFORM(tiInt,'@0'),2,1,'h')))
ENDFUNC &&Int2Bin AS STRING

*and
**FUNCTION Char2Bin AS STRING
Agnes
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform