VFP 9: #define constants

This is a discussion on VFP 9: #define constants within the xbase forums in Other Databases category; 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 ...

Go Back   Database Forum > Other Databases > xbase

Database Forums

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 07-20-2008, 10:15 PM
Default 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.
Reply With Quote
  #2  
Old 07-20-2008, 10:25 PM
Default 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.


Reply With Quote
  #3  
Old 07-20-2008, 10:55 PM
Default Re: VFP 9: #define constants

How about that!

You learn something new every day.


"Sergey Berezniker" wrote in message
news:%238en3Ct6IHA.2220-at-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.

>



Reply With Quote
  #4  
Old 07-21-2008, 11:27 AM
Default 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.
Reply With Quote
  #5  
Old 07-21-2008, 09:30 PM
Default 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.
Reply With Quote
  #6  
Old 07-21-2008, 09:56 PM
Default 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
Reply With Quote
  #7  
Old 07-21-2008, 10:36 PM
Default 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.
Reply With Quote
Reply


Thread Tools
Display Modes



All times are GMT -4. The time now is 09:53 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Integrated by bbpixel2008 :: jvbPlugin R1013.368.1

Search Engine Friendly URLs by vBSEO 3.1.0
vB Ad Management by =RedTyger=
In an effort to better serve ads to our visitors, cookies are used on Mydatabasesupport.com. For more information, check out our Privacy Policy.