× 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.



On Wed, 2005-12-21 at 09:18 -0700, Mohammad Tanveer wrote:
> Yes that's exactly what I am doing "to allow users to define their own
> validation rules".  I thought about using arrays but I decided to hard code
> the variable names in one of the service program and just recompile the
> service program if there is a need to add a variable. 
> 
Fair enough.  Glad to hear you have it working.

> In VB world you can define collections and reference them by name.  I was
> thinking to do the same in RPGLE, but it seems like IBM will have to
> re-write the RPGLE :-)  
Hmm, to me, an array _is_ a collection.  In VB, it's a collection of
objects, which turns out to be just a list of pointers.  Record buffers
are just a contiguous group of bytes in memory.  You can certainly
manipulate one to be the other without the need for IBM to do anything.

You can also implement just about any sort of data structure that you
desire.  In the past, I've implemented stacks, queues, extend-able
arrays, linked lists, and others.

> 
> Thanks 
> 
> -----Original Message-----
> From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
> On Behalf Of Rich Duzenbury
> Sent: Tuesday, December 20, 2005 3:11 PM
> To: RPG programming on the AS400 / iSeries
> Subject: Re: Dynamic Variable Names in RPGLE
> 
> On Tue, 2005-12-20 at 13:57 -0700, Mohammad Tanveer wrote:
> > Any idea if we can use dynamic variable names in RPGLE?  
> > 
> > Something like this
> > 
> >  fldvalue = %value(&var1);
> > 
> > Once we chain to a file or create cursor program knows what fields are
> > available.  Is there any API or Userspace stuff to get the value of the
> > fields using a dynamic variable name?
> > 
> > 
> > Thanks
> > 
> > 
> > 
> 
> 
> No.
> 
> However, you can roll your own to an extent.  In the case of a record
> buffer, such as results from a chain or read, you can find out the
> column name, type, offset and length at run time via DSPFFD to an
> outfile, the list fields API, the SQL catalog, and others.
> 
> Once you know the column from positions and length for a particular
> record, you could do
> 
> fldvalue = %subst(input_buffer: from_pos: length);
> 
> You will probably need some special handling for field types other than
> alphanumeric.
> 
> 
> 
> Years ago, we had need to allow users to define their own validation
> rules for any of about one hundred different fields contained on a set
> of five screens.  Users needed to do simple validation against lists,
> and also needed the capability to do rudimentary if-then-else logic, as
> well as to compare one field to another field.  The rules change
> frequently, and special cases are routinely added.
> 
> Initially, we though about generating a piece of code and compiling it
> each time they changed the file maintenance, but we were concerned about
> how cpu intensive that would be.  
> 
> Instead, we loaded the fields at run time into an array.  Once there, it
> was easy to write generic code to compare (for example) array(15) to
> array(10) or validate array(27) against a list.  
> 
> The only hard-coded portion of the program was that to move the fields
> from the record into the array.  The rules were stored in a file, and
> the 'engine' worked from the rules.
> 
> 
> As usual, it depends on what problem you are trying to solve as to the
> best way to go about it.  
> 
> 
> Regards,
> Rich
> 
> -- 
> This is the RPG programming on the AS400 / 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.

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.