CrystalizeCanada
Instructor
Hi,
I'm trying to find the position of an item in array, say for example "Alley Cat Cycles" in an array of customers say
["Blazing Saddles", "Acme Bikes", "Alley Cat Cycles", "Barry's Bikes]. I want to get the answer 3 here as it's the customer is the third element in the string array. I can get this succesfully with a formula which uses a loop. I'd like to do it without looping as this may take some time - heres the example below (copy and paste it will work as it doesn't refer to any database fields):
//PURPOSE OF FORMULA: Identify position of customer in string array
//VARIABLE DECLARATIONS:
StringVar Array MyStringArray:=["Blazing Saddles", "Alley Cat Cycles", "Acme Bikes", "Barry's Bikes"];
StringVar Array MyCustomer:="Alley Cat Cycles";
NumberVar i;
//FORMULA RESULT:
For i:= 1 to Count(MyStringArray) do
if MyCustomer =MySTringArray then exit for;
i //this will tell me 3
Is there a way to do this without a loop?
Tx
Gordon BOCP
Crystalize
I'm trying to find the position of an item in array, say for example "Alley Cat Cycles" in an array of customers say
["Blazing Saddles", "Acme Bikes", "Alley Cat Cycles", "Barry's Bikes]. I want to get the answer 3 here as it's the customer is the third element in the string array. I can get this succesfully with a formula which uses a loop. I'd like to do it without looping as this may take some time - heres the example below (copy and paste it will work as it doesn't refer to any database fields):
//PURPOSE OF FORMULA: Identify position of customer in string array
//VARIABLE DECLARATIONS:
StringVar Array MyStringArray:=["Blazing Saddles", "Alley Cat Cycles", "Acme Bikes", "Barry's Bikes"];
StringVar Array MyCustomer:="Alley Cat Cycles";
NumberVar i;
//FORMULA RESULT:
For i:= 1 to Count(MyStringArray) do
if MyCustomer =MySTringArray then exit for;
i //this will tell me 3
Is there a way to do this without a loop?
Tx
Gordon BOCP
Crystalize