-
VFP 9: #define constants
I know that VFP will not perform substitutions within a string as
in
#define SUPERLATIVE better
sentence="Father knows SUPERLATIVE."
but is there a way to get a similar effect?
I use SQLSEL as in
#define SQLSEL select
...
SQLSEL clcode,clname from ccli order by clcode
to differentiate between xBASE select statements and SQL select
statements.
Occasionally, I need to build an SQL statement with a subquery in
it and would like to build the expression as in
wherecond=;
"&limitexpr and "+;
"trnnbr in (SQLSEL wonbr from cwko where woccode=currwocc)"
This does not work. I have to use "select" and make a note (so that
when I search for SQL select statements, I can find them all.
Any ideas?
Sincerely,
Gene Wirchenko
Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.
-
Re: VFP 9: #define constants
Gene,
VFP will perform substitution inside [] string delimiters
#define SUPERLATIVE better
sentence = [Father knows SUPERLATIVE.]
? sentence
--
--sb--
VFP MVP
Gene Wirchenko wrote:
> I know that VFP will not perform substitutions within a string as
> in
> #define SUPERLATIVE better
> sentence="Father knows SUPERLATIVE."
> but is there a way to get a similar effect?
>
> I use SQLSEL as in
> #define SQLSEL select
> ...
> SQLSEL clcode,clname from ccli order by clcode
> to differentiate between xBASE select statements and SQL select
> statements.
>
> Occasionally, I need to build an SQL statement with a subquery in
> it and would like to build the expression as in
> wherecond=;
> "&limitexpr and "+;
> "trnnbr in (SQLSEL wonbr from cwko where woccode=currwocc)"
> This does not work. I have to use "select" and make a note (so that
> when I search for SQL select statements, I can find them all.
>
> Any ideas?
>
> Sincerely,
>
> Gene Wirchenko
>
> Computerese Irregular Verb Conjugation:
> I have preferences.
> You have biases.
> He/She has prejudices.
-
Re: VFP 9: #define constants
How about that!
You learn something new every day.
"Sergey Berezniker" wrote in message
news:%238en3Ct6IHA.2220@TK2MSFTNGP06.phx.gbl...
> Gene,
>
> VFP will perform substitution inside [] string delimiters
>
> #define SUPERLATIVE better
> sentence = [Father knows SUPERLATIVE.]
> ? sentence
>
> --
> --sb--
>
> VFP MVP
>
> Gene Wirchenko wrote:
>> I know that VFP will not perform substitutions within a string as
>> in
>> #define SUPERLATIVE better
>> sentence="Father knows SUPERLATIVE."
>> but is there a way to get a similar effect?
>>
>> I use SQLSEL as in
>> #define SQLSEL select
>> ...
>> SQLSEL clcode,clname from ccli order by clcode
>> to differentiate between xBASE select statements and SQL select
>> statements.
>>
>> Occasionally, I need to build an SQL statement with a subquery in
>> it and would like to build the expression as in
>> wherecond=;
>> "&limitexpr and "+;
>> "trnnbr in (SQLSEL wonbr from cwko where woccode=currwocc)"
>> This does not work. I have to use "select" and make a note (so that
>> when I search for SQL select statements, I can find them all.
>>
>> Any ideas?
>>
>> Sincerely,
>>
>> Gene Wirchenko
>>
>> Computerese Irregular Verb Conjugation:
>> I have preferences.
>> You have biases.
>> He/She has prejudices.
>
-
Re: VFP 9: #define constants
Besides that you can also use constants
with TEXT..ENDTEXT, which is advisable anyway,
if you want to create a multiline SQL statement.
#Define SQLSEL Select
Text To lcSQL
SQLSEL * FRom Table
EndText
? lcSQL
Bye, Olaf.
-
Re: VFP 9: #define constants
Sergey Berezniker wrote:
>VFP will perform substitution inside [] string delimiters
>
>#define SUPERLATIVE better
>sentence = [Father knows SUPERLATIVE.]
>? sentence
Well, well. That is certainly poorly documented. The #define
documentation states that substitutions are not done inside of
quotation marks, but does not say anything about "[" and "]". I did
not even think of them as being different. After all, they delimit
strings, too.
Sincerely,
Gene Wirchenko
Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.
-
Re: VFP 9: #define constants
Gene Wirchenko wrote:
> Well, well. That is certainly poorly documented. The #define
> documentation states that substitutions are not done inside of
> quotation marks, but does not say anything about "[" and "]". I did
> not even think of them as being different. After all, they delimit
> strings, too.
>
I'm pretty sure that VFP wouldn't perform substitution if [] were used
to delimit string literals only. However they are "overloaded" in VFP
and could be used in arrays and UDFs
? myarray[i]
? myudf["Some String Parameter"]
* or
? myudf[[Some String Parameter]]
--
--sb--
VFP MVP
-
Re: VFP 9: #define constants
Sergey Berezniker wrote:
>Gene Wirchenko wrote:
>
>> Well, well. That is certainly poorly documented. The #define
>> documentation states that substitutions are not done inside of
>> quotation marks, but does not say anything about "[" and "]". I did
>> not even think of them as being different. After all, they delimit
>> strings, too.
>>
>
>I'm pretty sure that VFP wouldn't perform substitution if [] were used
>to delimit string literals only. However they are "overloaded" in VFP
>and could be used in arrays and UDFs
I am sure that it will. I tried the example given. I then made
the appropriate changes to my program, and the substitutions were
done.
[snip]
Sincerely,
Gene Wirchenko
Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.