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



Mark: Yes, ALT can be used with arrays. How would I code an "associative array" without using tables? Probably something like:

   monitor;
      char = TypeChars(%lookup(SrcAttribute:SrcTypes));
   on-error 121;
      char = '-';
   endmon;

As you can see, the above code avoids the use of a separate index variable. But then, I don't see what's the big deal about avoiding an index variable. Either way, there's still only one lookup.

(BTW, there are several languages available that properly implement the concept of "associative array". Rexx, Perl, and Python (among others) allow the use of any string as an index. In Rexx, any there's no difference between a associative arrays and normal arrays. In Perl, they're called "hashes", and in Python, they're called "dictionaries". In whatever language, it's a very powerful and popular concept.)

Cheers! Hans


mlazarus@xxxxxxxx wrote:
Hans,


I understand what you're saying. It's just that we suspect that

tables are relics of an older era, and that there's not much need to do much with them. Functionally, there's nothing that you can do with tables that you can't also do with arrays. And since arrays are so much more powerful anyways, why bother limiting yourself by using a table?



On the other hand, if there really is some overwhelmingly compelling

reason that tables should be enhanced, I'm all ears!


One word: "simplicity".

I'll say at the outset that if I were designing the language from the
ground up, there would be no diference between a table and an array. But
since there is this concept built into the language, I may as well use it.


 I recently had occasion to use it, so it's fresh in my mind.  I have a
simple compile time table with static data that contains the "columns":
Source type, Type code and Description.  Source type is unique.  Type code
can repeat and Description will be ignored by the program (it's only for
the programmer's edification.)

The requirements are simple: If it's found in the table, use the
alternating table's value. So the code looks like this:
IF %TLookup( SrcAttribute: TabSrcTypes: TabTypeChars ) = *Off ;
RETURN '-' ; ELSE ; RETURN TabTypeChars ; ENDIF ;


 With arrays this would require a separate lookup, an additional variable
(the index), code to reset the index.  It's not a large amount of code
difference, but it is slightly more complex.

 Can the ALT keyword be used w/ compile time arrays?  (I still want to keep
the values side-by-side on the bottom.)  If not, then I would have to
define it as an OVERLAYed DS, but it would still require using an index
variable; not as elegant.



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.