Conditional Array Definitions

Kenneth Brody kenbrody at bestweb.net
Sat Nov 27 07:22:07 PST 2004


Frank McKinney wrote:
> 
> May one safely define arrays on a conditional basis?
> As in:
> 1. If: yr eq "04"
>  Then:DIM cum[ 14](12,):15
> 
> 2. If yr eq "03"
>  Then: DIM cum[14](12,.):30
[...]

No.  Arrays are not defined by executing a DIM statement.  They are
declared by the presence of the DIM statement.

You could, however, declare a single array that covers all of the
fields you want to access, and declare a variable which will then
hold the first subscript you wish to use.

For example:

    declare start(3,.0,g)
    dim cum(30):15

    if: yr = "04"
  then: start = "0"
    if: yr = "03"
  then: start = "15"

Now, any reference to the array would simply add start to the subscript
you would have used.  So, instead of:

    cum[xx]

you would use:

    cum[start+xx]

-- 
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody        | www.hvcomputer.com |                             |
| kenbrody/at\spamcop.net | www.fptech.com     | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:ThisIsASpamTrap at gmail.com>



More information about the Filepro-list mailing list