Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why this code doesn't work?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00839067
Message ID:
00839121
Views:
20
This message has been marked as a message which has helped to the initial question of the thread.
Selim,
It looks like you misunderstand what #define means. It is a preprocessor directive that defines compile-time constants. Basically what this tells the compiler to do is to substitute the defined value for all occurences of the specified constant in the source code when it is compiled. The constant is only used at compile time and is not even defined (or accessible) during runtime which is why you are getting variable WLREVERSE not defined when you code &lcMode in your example. As Sergey said
#define WLNORMAL  2
#define WLCLEAR 3
* #1
oRF.Print(0,0,"just a test",WLCLEAR+WLNORMAL)
* #2
oRF.Print(0,0,"just a test",5)
Examples 1 and 2 are the same, but example #1 is more readable as to your intent. Actually example 1 compiles to oRF.Print(0,0,"just a test",3+2) and 3+2 is evaluated at runtime.

In your example you do not need to use &lcMode at all. I assume that you have #define or an #include file that defines WLREVERSE, WLCLEAR, WLNORMAL, WLFLUSHOUT "compile-time" constants
Local lnRow, lnCol, lcMess, lcMode
DECLARE arrLines[3,4]
arrLines[1,1]=0
arrLines[1,2]=0
arrLines[1,3]='Fisrt Line'
arrLines[1,4]= WLREVERSE+WLCLEAR && without quotes - values will be set at compile time

arrLines[2,1]=1
arrLines[2,2]=0
arrLines[2,3]='Second Line'
arrLines[2,4]= WLNORMAL+WLCLEAR

arrLines[3,1]=2
arrLines[3,2]=0
arrLines[3,3]='Last Line'
arrLines[3,4]= WLNORMAL+WLFLUSHOUT  
FOR _N = 1 to 3
   lnRow = arrLines[_N,1]
   lnCol = arrLines[_N,2]
   lcMess= arrLines[_N,3]
   lcMode= arrLines[_N,4]
   oRF.Print(lnCol,lnRow,lcMess, lcMode)
   *!* vvv You could also do the same thing like this 
   oRF.Print(arrLines[_N,1],arrLines[_N,2],arrLines[_N,3],arrLines[_N,4])
   *!* ^^^ works the same but of course is less readable
ENDFOR
HTH

Elmer


>I do need to store the constants to a string because is something that doesn't run inmediatly. It is something I need to store in an array or collection and then process all together something like this
>
>What i am doing is building a screen. I have a method to add lines to the screen first, after the programmer have added all the lines that'll be on the screen then I have another method to display the screen.
>
>it is not this but this is the main idea
>
>
>Local lnRow, lnCol, lcMess, lcMode
>DECLARE arrLines[3,4]
>arrLines[1,1]=0
>arrLines[1,2]=0
>arrLines[1,3]='Fisrt Line'
>arrLines[1,4]='WLREVERSE+WLCLEAR'
>
>arrLines[2,1]=1
>arrLines[2,2]=0
>arrLines[2,3]='Second Line'
>arrLines[2,4]='WLNORMAL+WLCLEAR'
>
>arrLines[3,1]=2
>arrLines[3,2]=0
>arrLines[3,3]='Last Line'
>arrLines[3,4]='WLNORMAL+WLFLUSHOUT'
>
>FOR _N = 1 to 3
>   lnRow = arrLines[_N,1]
>   lnCol = arrLines[_N,2]
>   lcMess= arrLines[_N,3]
>   lcMode= arrLines[_N,4]
>   oRF.Print(lnCol,lnRow,lcMess, &lcMode)
>ENDFOR
>
>
>see what I need?
Previous
Reply
Map
View

Click here to load this message in the networking platform