Getting position of last occurance in list

I have 2 lists:

List 1 (dates)


12/02/04

23/02/04

30/02/04

02/04/04

08/04/04

List 2 (text)


CAL

WRK

CS

CAL

CS

Basically the items in the date list are related to the items in the text list by their order in the list.

I need to find the position in List2 of the last occurance of “CAL” so I can then retrieve the date corresponding to that position in List1.

I though about inverting list2, then using @Member to return the numerical position of “CAL”(this would get the last occurance). I could then use @Subset on List1 with the negative of the number returned by the @Member. But I couldnt see how to invert List2?

Any ideas?

Subject: Or without a for loop…

L1 := @Text(List1) + “~” + List2;@Date(@TextToTime(@Subset(@Trim(@Left(L1; “~CAL”)); -1)))

Subject: Getting position of last occurance in list

I dont find any direct list function to do that…May be you can try below

n:=1;

@While(n <= @Elements(List2);

temp:=@If(@Trim(List2[n])=“CAL”;n;temp);

n := n + 1);

@Prompt([Ok];“Corresponding List1 Data”;List1[temp]);

You may need to add exception like if the the list doesn’t have the matching value, etc.,