<< 11 January 2006 | Home | 13 January 2006 >>

Getting index values with @Formula

I'm doing quite a lot of @Formula coding these days and I'm finding the "new" index capability of @Formula very helpfull. I know it was introduced in release 6 but I'm just starting to use it - old habits die hard.

In that connection I frequently have two arrays of data where I need to find the index of a key value ("Key") in the first array ("keys") and get then get the entry at the same index in the other array ("data"). I have found no ArrayGetIndex-like function in @Formula so I'm resorting to a @For-loop to find the correct index and then getting the value from the other array.

keys := @GetProfileField("MyProfile"; "Keys");
data := @GetProfileField("MyProfile"; "Data");
result := "";
@For(n:=1; n<=@Elements(keys); n:=n+1;
   @If(keys[n] = Key;
      @Set("result"; profile_kortlink[n]);
      ""
   )
);
result

Anyone who knows of an easier way?