Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Odd behavior with #ENDIF in #DEFINE
Message
From
11/09/2006 16:01:12
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01152849
Message ID:
01152865
Views:
21
>Greg,
>
>After VFP encounters #IF .F. it will ignore all lines until it finds #ELIF or closing #ENDIF.
>

This I do understand. Actually I am attempting to take advandage of it. What I want is when the developer views the code, they will see the TEST_SUITE / ENDTEST_SUITE statement block. But when compiled, the code between these two statement is removed from the compiled version. To help clarify why I want to do this; I am developing a class that when passed a object reference it will recurs the object model and scan the source code for TEST_SUITE statements. When found, the code between the TEST_CASE are extracted, and executed as automated test cases. So far, I have most of it complete, but this inability to convert the ENDTEST_SUITE into proper #ENDIF statement is hanging me up.

P.S. to get around the problem during the development phase, I am setting the TEST_SUITE to "TEST NOSHOW" and the ENDTEST_SUITE to "ENDTEXT". But leaves the code in the compiled version as a chuck of text.



>
>>
>>I am developing a Test Suite class, and would like to devise my own command using Preprocessors. I have the following include file.
>>
>>
>>#IFNDEF TEST_SUITE
>>
>>#DEFINE TEST_SUITE      #IF .F.
>>#DEFINE ENDTEST_SUITE   #ENDIF
>>
>>#DEFINE TEST_CASE       *
>>#DEFINE ENDTEST_CASE
>>
>>#ENDIF
>>
>>
>>In the various methods, I am define the test case in the actual code as such:
>>
>>
>>* Standard Method Header
>>*---------------------------------------
>>
>>TEST_SUITE
>>TEST_CASE    First Test Case
>>    *- <Place Test Case code here>
>>ENDTEST_CASE
>>ENDTEST_SUITE
>>
>>WAIT WINDOW "For something"
>>
>>*- The remainder of the method is the actual code for the method.
>>
>>
>>Now for the problem.
>>
>>When compiled and ran, the lines after of ENDTEST_SUITE (aka #ENDIF) are ignored at run-time, or something close to that. Here a simplified version of the same problem.
>>
>>
>>SET STEP ON
>>
>>#define kStart #IF .F.		&& text noshow
>>#define kEnding #ENDIF		&& endtext
>>WAIT WINDOW
>>
>>kStart
>>? "Hello"
>>kEnding
>>
>>WAIT WINDOW
>>? "world"
>>
>>RETURN
>>
>>
>>In this example, the debugger stops at the first "WAIT" statement, but it proceeds after it, it exits the routine. Now if you comment out the first WAIT statement and run it again, the behavior changes a little. Now the it stops at the "RETURN" statement after executing the SET STEP statement.
>>
>>Has anyone encountered this before, and is there a fix or work-around to placing a "#ENDIF" is a constant?
Greg Reichert
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform