Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Clipper function BIN2L
Message
 
 
À
26/09/1999 19:09:34
Daniel Antich
Informática Industrial
Heredia, Costa Rica
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00269066
Message ID:
00269171
Vues:
29
Daniel,

These are the routines I use to to work with API structures.
* ConvertAPI.prg 08-Oct-97 

* these functions convert to/from internal binary storage

function ToWord( pnNumber )
local lnMSB, lnLSB
lnMSB = int( pnNumber / 256 )  && most significant byte
lnLSB = pnNumber % 256  && least significant byte
return chr( lnLSB ) + chr( lnMSB )

function ToLong( pnNumber )
local lnMSW, lnLSW
lnMSW = int( pnNumber / 65536 )  && most significant word
lnLSW = pnNumber % 65536  && least significant word
return ToWord( lnLSW ) + ToWord( lnMSW )

function FromWord( pcBuffer )
return asc( substr( pcBuffer, 2, 1 ) ) * 256 + asc( left( pcBuffer, 1 ) )

function FromLong( pcBuffer )
local lnNegative

if ( bitand( 0x80, asc( substr( pcBuffer, 3, 1 ) ) ) = 0x80 )
   lnNegative = -1
   pcBuffer = left( pcBuffer, 2 ) + chr( bitand( asc( substr( pcBuffer, 3, 1 ) ), 0x7f ) ) + right( pcBuffer, 1 )
else
   lnNegative = 1
endif
return lnNegative * FromWord( substr( pcBuffer, 3, 2 ) ) * 65536 + FromWord( left( pcBuffer, 2 ) )
>Hi,
>
>BIN2L() is a low-level file function that is used with FREAD() to convert a four-byte character string formatted as a signed integer to a Clipper numeric data type.
>The argument is a character string in the form of a 32-bit signed integer number--least significant byte first. BIN2L() returns an integer numeric value.
>
>
>thank you
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform