[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
Sorry about the typo... I wrote this late Saturday night after a party.
There is a rule that isn't in the SQR documentation: SQR and Beer Don't
Mix!
I meant to put this...
#define mgr_codes 'MM'',''MA'',''VA'
Quotes can be a real pain... Commas and quotes should be avoided if
possible... Like I said this string '*MM*MA*VA*' works much better... or
'|MM|MA|VA|'... etc...
-Tony DeLia
PS - "Do not operate heavy machinery or write SQR programs while
drinking alcohol"
> 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