Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bug: Compile - error, run - no error
Message
From
10/12/2006 05:21:22
 
 
To
08/12/2006 19:41:34
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01176311
Message ID:
01176385
Views:
7
>1. MODIFY COMMAND temp.prg
>2. Copy code below into the open temp.prg
>3. ALT+P+M to compile it
>4. Observerd: ERROR: Command contains unrecognized phrase/keyword.
>
>5. Click Cancel to dismiss the messagebox with error
>6. CTRL+E to run the same code
>7. Observerd: Code runs w/o error and ouputs "Invalid Type" to the desktop
>Expected: The same error as in 4.
>
>
>lnDriveType = 0
>DO CASE
>CASE lnDriveType = 6
>	lcDriveType = "RAM disk
>OTHERWISE
>	? "Invalid Type"
>ENDCASE
>
>
>Comments: I thought that CTRL+E causes code to be compiled as with ALT+P+M and then run but it seems not to be the case.

CTRL+E is a DO shortcut, it compile the file with a COMPILE command.
COMPILE command doesn't interact with the user,
and this can to be "by design" into a full dynamic language as VFP,
but if this is the design choice, it is wrong,
because it create a difference among COMPILE and EXECSCRIPT.
At design time this is a minor issue, but at runtime this can to generate side effects,
because COMPILE and/or DO execute the correct code, and generate errors inside the compiled code,
execscript require a perfect syntax code to execute the first line.

EXECSCRIPT is correct for me,
and backward compatibility it is not a good reason to keep on being wrong.
* COMPILE WAY

TEXT TO wrongCode NOSHOW
	lcDriveType < 12a
ENDTEXT

ERASE WRONGCODE.*

STRTOFILE(m.wrongCode,"wrongCode.prg")

* with COMPILE no errors, fxp is created, with an error file.
* this is like ALT+P+M and "Ignore"
COMPILE wrongCode.PRG
IF FILE("wrongCode.ERR")
	MESSAGEBOX(FILETOSTR("wrongCode.ERR"),"ERROR FILE")
ENDIF
* VFP try TO execute the bad line
DO wrongCode.FXP

* execscript is different ! Compile and run is an atomic process
* it is like ALT+P+M and "Cancel"
EXECSCRIPT(m.wrongCode)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform