Kurt,
For me, the value comes from being able to store the list data as a character string. I use my "registry" api so that I can load the validation values quickly and easily... The only real caveat with this is that list elements must be delimited (and trimmed) values, and the search string value must also be delimited and trimmed. Given this restriction, the technique is otherwise fairly safe and reliable. No false matches with short scan strings this way...
Arrays are fine, I use them all the time, but this is a reasonable alternative in many cases...
-Eric
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Anderson, Kurt
Sent: Friday, March 01, 2013 11:47 AM
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: RE: Its Friday
Wait, how is that nice?
Why would you use that method over using an array? As Eric even said, there are inherent risks to searching a string for values. I don't see the benefit.
I know it's Friday, but it's Friday 2013. (Not that arrays are a new concept.)
-Kurt
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Gary Thompson
Sent: Friday, March 01, 2013 11:43 AM
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: RE: Its Friday
Eric, nice, avoids the array, challenges my brain...
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of DeLong, Eric
Sent: Friday, March 01, 2013 10:36 AM
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: RE: Its Friday
I have sometimes used %scan() to provide some similar functionality. There are some risks associated with this, so take care to not hurt yourself...
myCustomerExemptTypes = '("NONEXEMPT", "RETAILEXEMPT", "FULLYEXEMPT")'; chain myCust Customer; if %scan( '"'+%trim(CustExTyp)+'"' : myCustomerExemptTypes ) > 0;
// non-zero means FOUND (is Valid)
Endif;
It's important to use delimiters to define values, and to enclose the scan string in like fashion. Parentheses for the list string are not necessary, but I like to use them (or [], {}) to so some sort of "dataset" relationship.
Hth,
-Eric DeLong
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Gary Thompson
Sent: Friday, March 01, 2013 10:44 AM
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: Its Friday
Ever wonder why there is no If IN (not to be confused with *IN) ?
If MyCharVar In ('A','B','C');
MyFace = ': )';
Else;
MyFace = ':(';
Endif;
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.