Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Function to determine versions of Windows XP
Message
From
07/02/2002 15:59:44
 
 
To
07/02/2002 15:47:03
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00616673
Message ID:
00616998
Views:
19
OOPs, I realized I neglected the relatively important additional function!
* Program....: ASC2BEINT.PRG
* Version....: 1.0
* Author.....: ** Richard G Bean **
* Date.......: April 3, 2000
* Notice.....: ** Melange Computer Services, Inc **
* Compiler...: Visual FoxPro 06.00.8492.00 for Windows
* Abstract...: Ascii String to BigEndian Integer
*              (i.e. Most significant byte on right)
*              (use asc2int() for LittleEndian)
*		  Doesn't return negative numbers
*		  RETURN -1 if any error
* Changes....:

*FUNCTION asc2BEint

LPARAMETERS p_cString, p_nStart, p_nLength
IF PCOUNT() < 1 OR VARTYPE(p_cString) <> "C"
	RETURN -1
ENDIF

IF PCOUNT() < 2 OR VARTYPE(p_nStart) <> "N"
	p_nStart = 1
ENDIF
IF PCOUNT() < 3 OR VARTYPE(p_nLength) <> "N"
	p_nLength = LEN(p_cString)
ENDIF

LOCAL lnRet_val

DO CASE
CASE p_nLength = 1
   lnRet_val = asc(SUBSTR(p_cString, p_nStart, 1))

CASE p_nLength = 2
   lnRet_val = asc(SUBSTR(p_cString, p_nStart, 1));
   			+ asc(SUBSTR(p_cString, p_nStart+1, 1))*256

CASE p_nLength = 3
   lnRet_val = asc(SUBSTR(p_cString, p_nStart, 1));
   			+ asc(SUBSTR(p_cString, p_nStart+1, 1))*256;
   			+ asc(SUBSTR(p_cString, p_nStart+2, 1))*256^2

CASE p_nLength = 4
   lnRet_val = asc(SUBSTR(p_cString, p_nStart, 1));
   			+ asc(SUBSTR(p_cString, p_nStart+1, 1))*256;
   			+ asc(SUBSTR(p_cString, p_nStart+2, 1))*256^2;
   			+ asc(SUBSTR(p_cString, p_nStart+3, 1))*256^3
   			
OTHERWISE
	lnRet_val = -1
ENDCASE

RETURN INT(lnRet_val)
Rick
Previous
Reply
Map
View

Click here to load this message in the networking platform