[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Re: Hard-coded values and instr() command
- Subject: Re: Hard-coded values and instr() command
- From: Parijat Sahai <parijatsahai@HOTMAIL.COM>
- Date: Tue, 19 Jan 1999 11:02:43 PST
Tony,
Firstly, the following code isn't correct:
let $mgr_codes = '{mgr_codes}'
The substitution variable (!!), mgr_codes, will not be substituted by
the compiler during parsing coz it has been placed within quotes. The
compiler will treat it as a string. You could write
let $mgr_codes = {mgr_codes}
But, it actually doesn't make a difference whether you use the string
variable or the substitution variable in instr() function. In fact, by
using a variable, you're eating up extra memory. What Don says is
perfectly correct. The best solution is to use
#DEFINE mgr_codes 'MM;MA;VA'
or, maybe,
#DEFINE mgr_codes 'MM,MA,VA'
There's no need for those extra quotes. They just complicate the
readability of the program. In the second case, comma won't confuse the
instr() function coz it has been placed inside quotes.
Parijat.
>Date: Sat, 16 Jan 1999 09:57:40 -0500
>Reply-To: SQR-USERS@USA.NET
>From: Tony DeLia <tdelia@EROLS.COM>
>Subject: Re: Hard-coded values and instr() command
>To: Multiple recipients of list SQR-USERS <SQR-USERS@list.iex.net>
>
>Jason,
> We can expand on this a little further... when using a substitution
>variable you have to be careful... it doesn't perform as a variable...
>BUT if you move it to a variable first (in an Init procedure) then use
>the variable for the INSTR...
>
>Like this:
>
>#define mgr_codes 'MM','MA','VA'
>
>let $mgr_codes = '{mgr_codes}'
>
>....
>if instr($mgr_codes, &jobcode, 1)
> do mgr_stuff
>end-if
>
>This would work because the embedded commas won't interfere with the
>syntax of the INSTR command... AND you can still define your jobcodes
>with a substitution variable... I'm not too crazy about using commas as
>delimeters when you don't need to...
>
>I'd rather use:
>#define mgr_codes *MM*MA*VA* to be safe...
>
>
> -Tony DeLia
>
>
>Don Mellen wrote:
>>
>> On Fri, 15 Jan 1999, Jason Penney wrote:
>> ....
>> > #DEFINE mgr_codes 'MM''MA''VA'
>> ....
>> > Examples of variables that resulted in instr() syntax errors:
>> > #DEFINE mgr_codes 'MM','MA','VA'
>> > #DEFINE mgr_codes 'MM';'MA';'VA'
>> ....
>> > So, the only way I've made it work is to have one quote at the
>> > beginning of the list and double quotes between each value.
Anybody
>> > know why?
>>
>> Do any of the following look correct?
>> IF INSTR('MM','MA','VA',&jobcode,1) > 0
>> IF INSTR('MM';'MA';'VA',&jobcode,1) > 0
>>
>> The first one worked because it evaluated to
>> IF INSTR('MM''MA''VA',&jobcode,1) > 0
>> when it compiled (which is a single string with a single quote
seperating
>> the elements). It would also work if you defined mgr_codes like
>> #DEFINE mgr_codes 'MM;MA;VA'
>> resulting in
>> IF INSTR('MM;MA;VA',&jobcode,1) > 0
>> when it is compiled.
>>
>> HTH,
>>
-----------------------------------------------------------------------
>> Donald Mellen | Ray Ontko & Co. - Richmond, IN -
http://www.ontko.com/
>> donm@ontko.com | "In the beginning, there was nothing, which
exploded"
>
>--
>Tony DeLia
>AnswerThink Consulting Group
>PeopleSoft Solutions Practice - Delphi Partners
>tdelia@erols.com
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com