Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Execscript problem
Message
From
04/01/2005 13:35:22
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Execscript problem
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00974147
Message ID:
00974147
Views:
77
Nevermind. I just remembered that I cannot use #Define of course in this case...


IF the below code is saved to a program named c1.prg and c1.prg is run using "do c1.prg" from a command window it works fine. However, if c1.prg is called using =execscript(filetostr('c1.prg')) then it bombs with a syntax error. Any ideas?

TIA!
#Define HKEY_CLASSES_ROOT           -2147483648
#Define HKEY_CURRENT_USER           -2147483647
#Define HKEY_LOCAL_MACHINE          -2147483646
#Define HKEY_USERS                  -2147483645
#Define REG_SZ 				1	&& String
#Define REG_BINARY 			3	&& Binary data
#Define REG_DWORD 			4	&& 32bits int
#Define ERROR_SUCCESS		0	&& OK

PRIVATE nKey, cSubKey, cValue, cValueRead, m.value, value1, value2, value3, value4, value5, value6
m.value = sys(17)+chr(13)
nkey = HKEY_LOCAL_MACHINE

cSubKey = "Hardware\DESCRIPTION\System\CentralProcessor\0"
cValue = "ProcessorNameString"
cValueRead=''
cValueRead = ReadREG_SZ(nKey, cSubKey, cValue)
IF !EMPTY(cValueRead)
	m.value = m.value + "Processor 1: "+LTRIM(cValueRead)+CHR(13)
ENDIF

cSubKey = "Hardware\DESCRIPTION\System\CentralProcessor\1"
cValue = "ProcessorNameString"
cValueRead=''
cValueRead = ReadREG_SZ(nKey, cSubKey, cValue)
IF !EMPTY(cValueRead)
	m.value = m.value + "Processor 2: "+LTRIM(cValueRead)+CHR(13)
ENDIF

cSubKey = "Hardware\DESCRIPTION\System\CentralProcessor\2"
cValue = "ProcessorNameString"
cValueRead=''
cValueRead = ReadREG_SZ(nKey, cSubKey, cValue)
IF !EMPTY(cValueRead)
	m.value = m.value + "Processor 3: "+LTRIM(cValueRead)+CHR(13)
ENDIF

cSubKey = "Hardware\DESCRIPTION\System\CentralProcessor\3"
cValue = "ProcessorNameString"
cValueRead=''
cValueRead = ReadREG_SZ(nKey, cSubKey, cValue)
IF !EMPTY(cValueRead)
	m.value = m.value + "Processor 4: "+LTRIM(cValueRead)+CHR(13)
ENDIF

value2nd = passtwo()
m.value = m.value+value2nd+CHR(13)
? m.value
RETURN m.value

PROCEDURE ReadREG_SZ
   PARAMETERS  nKey, cSubKey, cValue
   #DEFINE REG_SZ   1

   DECLARE Integer RegOpenKey IN Win32API ;
      Integer nHKey, String @cSubKey, Integer @nResult
   DECLARE Integer RegQueryValueEx IN Win32API ;
      Integer nHKey, String lpszValueName, Integer dwReserved,;
      Integer @lpdwType, String @lpbData, Integer @lpcbData
   DECLARE Integer RegCloseKey IN Win32API Integer nHKey

   LOCAL nErrCode      && Error Code returned from Registry functions
   LOCAL nKeyHandle    && Handle to Key that is opened in the Registry
   LOCAL lpdwValueType && Type of Value that we are looking for
   LOCAL lpbValue      && The data stored in the value
   LOCAL lpcbValueSize && Size of the variable
   LOCAL lpdwReserved  && Reserved Must be 0
    
   nKeyHandle = 0
   lpdwReserved = 0           
   lpdwValueType = REG_SZ
   lpbValue = ""
   
   nErrCode = RegOpenKey(nKey, cSubKey, @nKeyHandle)
   IF (nErrCode # 0) THEN
      RETURN ""
   ENDIF

   lpcbValueSize = 1 
   nErrCode=RegQueryValueEx(nKeyHandle, cValue, lpdwReserved, @lpdwValueType, @lpbValue, @lpcbValueSize)

   lpbValue = SPACE(lpcbValueSize)   
   nErrCode=RegQueryValueEx(nKeyHandle, cValue, lpdwReserved, @lpdwValueType, @lpbValue, @lpcbValueSize)
   
   =RegCloseKey(nKeyHandle)
   IF (nErrCode # 0) THEN
      RETURN ""
   ENDIF

   lpbValue = LEFT(lpbValue, lpcbValueSize - 1)
RETURN lpbValue


************************
PROCEDURE passtwo
newvalue = ''
VALUE1 = "Number of CPUs: " +GETENV("NUMBER_OF_PROCESSORS")+CHR(13)
value2 =  "Processor Architecture: " +GETENV("PROCESSOR_ARCHITECTURE")+CHR(13)
value3 =  "Processor Identifier: " +GETENV("PROCESSOR_IDENTIFIER")+CHR(13)
value4 =  "Processor Level: " +GETENV("PROCESSOR_LEVEL")+CHR(13)
value5 = "Processor Revision: " +GETENV("PROCESSOR_REVISION")+CHR(13)
newvalue = value1+value2+value3+value4+value5
RETURN newvalue
*************************
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Next
Reply
Map
View

Click here to load this message in the networking platform