palmtree with sun behind it CONTACT US
Phone: (412) 835-9417
Email: sales@vss3.com

Tip # 38 - fileProŽ Array Aliases


An alias is another name for the same data. For example, Bugs Bunny also known as Bugsy, or your sweet mother, Mrs. John Smith aka MOM. Two names for the same thing. This can give us a great tool in filePro. Dummy variables and field numbers can be referenced with arrays by counting.

dim cust(15):ca The array cust has 15 elements, cust("1"), cust("2"), ... , cust("15"). Each of these data elements can also be referred to as ca, cb, cc, ..., co. The next 15 alphabetical dummy variables are aliases for the elements in the array. If I change the value of co, then cust("15") also changes. If I change the value of cust("15") then co changes.
dim rep(50)(80):la rep(50) has each element defined as 80 characters and uses the letters, la - mn (if I counted right).
dim field(130):1 In this array, the real fields, 1 to 130, are mapped to the array. This can be a handy way to reference a field with a variable. For example, field("12") would be the alias for the real field 12.
dim array(5):cust(10) This array is mapped to fields in a lookup file. Array("1")=cust(10); array("2")=cust(11), etc.

An alias gives us two names for the same piece of data. Now that you see what can be done, let's look at an example.


Array Lookup Aliases

15 -- - - - - - - - - - - - - - - - - -
If:
Then: lookup nick=filename k=ky i=a -nx
16 - - - - - - - - - - - - - - - - - -
If:
Then: dim amount(8):nick(5)     'This array is mapped to the fields 5-12 in the lookup file.
17 --- - - - - - - - - - - - - - - - - - - -
If:
Then: dim ttl(8)(8,.2,g):ta ; xx(2,.0)="1"

This array is collecting the totals and the fields ta-th can be displayed or printed.

18 --- - - - - - - - - - - - - - - - - - - - - -
loop If: xx le "8"
Then: ttl(xx)=amount(xx); xx=xx+"1"; goto loop
19 --- - - - - - - - - - - - - - - - - - - - - -
This loop is collecting the numbers in those fields 5-12 and assigning them to ta-th. If  more than one record should be collected and totaled, the assignment line could read:  ttl(xx)=amount(xx)+ttl(xx)
Then a GETNEXT and a loop could continue to look for records that should be added.
 

CLEARING ARRAYS -

The neatest trick possible with this array alias logic is to use the CLEAR command to clear the data in a record.  For example, 100 fields from 95 to 194 must be reset to zero.  One way to do this is to type in the processing:  95="";96="";97="", and continue to 194="".  Not my idea of fun.

However, using the alias logic you can do the following:

dim fields(100):95

You have just associated each field from 95 to 194 to an array element.  Now issue the following command:

clear fields

At this point all the data in the fields has been erased.  Isn't that simple?


Written by Nancy Palmquist

Copyright, 1997 by Virtual Software Systems.  All rights reserved.

Contact Us by: Email to Virtual Software Systems or Phone: (412) 835-9417