× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



And... to add to Vern's mission assignment... a flag to indicate case (in)sensitivity.

This email will self destruct in 5 seconds......
Good Luck, Jim (oops... Rory)


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Vern Hamberg
Sent: Friday, March 05, 2010 2:29 PM
To: RPG programming on the IBM i / System i
Subject: Re: AW: More on RPG style

LOL Rory - I knew someone would take the bait - nice!

I'm assuming that the first parameter would usually be a variable,
otherwise, you'd know whether it was in the list already!

Now a similar function for numerics! Your mission, if you choose to
accept it!

Vern

Rory Hewitt wrote:
OK, that was actually the code for my (unfinshed) @LIKE function - silly me!
It should be:

*=====================================================================
* @in(): Check for a string in a series of other strings
*=====================================================================
P @in B Export
D PI N
D pSearch 512A Const Varying
D pScan1 512A Const Varying
D pScan2 512A Const Varying Options(*Nopass)
D pScan3 512A Const Varying Options(*Nopass)
D pScan4 512A Const Varying Options(*Nopass)
D pScan5 512A Const Varying Options(*Nopass)
D pScan6 512A Const Varying Options(*Nopass)
D pScan7 512A Const Varying Options(*Nopass)
D pScan8 512A Const Varying Options(*Nopass)
D pScan9 512A Const Varying Options(*Nopass)
D pScan10 512A Const Varying Options(*Nopass)
*---------------------------------------------------------------------
/free

if ( pSearch = pScan1 ) or
( %parms > 2 and pSearch = pScan2 ) or
( %parms > 3 and pSearch = pScan3 ) or
( %parms > 4 and pSearch = pScan4 ) or
( %parms > 5 and pSearch = pScan5 ) or
( %parms > 6 and pSearch = pScan6 ) or
( %parms > 7 and pSearch = pScan7 ) or
( %parms > 8 and pSearch = pScan8 ) or
( %parms > 9 and pSearch = pScan9 ) or
( %parms > 10 and pSearch = pScan10 );
return *on;
else;
return *off;
endif;

begsr *pssr;
return *off;
endsr;

/end-free
P E

Rory

On Fri, Mar 5, 2010 at 2:08 PM, Rory Hewitt <rory.hewitt@xxxxxxxxx> wrote:


Like this?

if @in( 'me' : 'john' : 'mike' : 'home' : 'seth' );
dsply 'Yup, it''s there!';
else;
dsply 'Nope, it''s not there!';
endif;


*=====================================================================
* @in(): Scan for a string in a series of other strings
*=====================================================================
P @in B Export
D PI N
D pSearch 512A Const Varying
D pScan1 512A Const Varying
D pScan2 512A Const Varying Options(*Nopass)
D pScan3 512A Const Varying Options(*Nopass)
D pScan4 512A Const Varying Options(*Nopass)
D pScan5 512A Const Varying Options(*Nopass)
D pScan6 512A Const Varying Options(*Nopass)
D pScan7 512A Const Varying Options(*Nopass)
D pScan8 512A Const Varying Options(*Nopass)
D pScan9 512A Const Varying Options(*Nopass)
D pScan10 512A Const Varying Options(*Nopass)
*---------------------------------------------------------------------
D qusec DS Likeds(qusec_t) Inz(*Likeds)
*---------------------------------------------------------------------
/free

lead = %subst( pSearch : 1 : 1 ) = '%';
trail = %subst( pSearch : %len( pSearch ) : 1 ) = '%';

if ( %scan( pSearch : pScan1 ) > 0 ) or
( %parms > 2 and %scan( pSearch : pScan2 ) > 0 ) or
( %parms > 3 and %scan( pSearch : pScan3 ) > 0 ) or
( %parms > 4 and %scan( pSearch : pScan4 ) > 0 ) or
( %parms > 5 and %scan( pSearch : pScan5 ) > 0 ) or
( %parms > 6 and %scan( pSearch : pScan6 ) > 0 ) or
( %parms > 7 and %scan( pSearch : pScan7 ) > 0 ) or
( %parms > 8 and %scan( pSearch : pScan8 ) > 0 ) or
( %parms > 9 and %scan( pSearch : pScan9 ) > 0 ) or
( %parms > 10 and %scan( pSearch : pScan10 ) > 0 );
return *on;
else;
return *off;
endif;

begsr *pssr;
return *off;
endsr;

/end-free
P E

This one only works with strings and it's pretty basic, but you get the
idea...

Rory

On Fri, Mar 5, 2010 at 1:22 PM, Vern Hamberg <vhamberg@xxxxxxxxxxx> wrote:


[...]But you could have it so

that only the value to test and the first comparison value are required
- the rest could be *NOPASS.

OK - time for real work!!

Vern





--
This is the RPG programming on the IBM i / System i (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 message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. (Knotts Berry Farm - Cedar Fair L.P.)

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.