Leanna Posted February 2, 2012 Share Posted February 2, 2012 Hello!I have three arrays$F1 = StringSplit(“24|42|03|24|24|03|42”, “|”)$F2 = StringSplit( “11|10|60” , “|”)$F3 = StringSplit( “42|24|03” , “|”)How can I do the following:1. To transform an array $F1 into array $R2 = “02|01|03|02|02|03|01” – every value here is the index in $F3 of $F1 valueI.e. $F1[1] = 24 – it is the second element in $F3=> $R[1] = 01. …. $F1[6] =03 – it is the third element in $F3 => $R[6] = 03How to make a new array?2. To substitute every value in $F1 according to following key 24=11, 42=10, 03=60 (an array will be longer, thats why IF is not comfortable)The outcome should be $R2 = “10|11|60|10|10|60|11”Thank you! Link to comment Share on other sites More sharing options...
hannes08 Posted February 2, 2012 Share Posted February 2, 2012 Hello Leanna see my solutions: 1: $F1 = StringSplit("24|42|03|24|24|03|42", "|") $F2 = StringSplit( "11|10|60","|") $F3 = StringSplit( "42|24|03","|") Dim $R1[$F1[0] +1] For $i = 1 To $F1[0] For $j = 1 To $F3[0] If $F1[$i] = $F3[$j] Then $R1[$i] = StringFormat("%02s", $j) ExitLoop EndIf Next Next _ArrayDisplay($R1) 2: $string = "24|42|03|24|24|03|42|" StringReplace($string, "24|", "11|") StringReplace($string, "42|", "10|") StringReplace($string, "03|", "60|") $F1 = StringSplit(StringTrimRight($string, 1), "|") As you can see I solved the second Problem without any Arrays affected. Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
Leanna Posted February 2, 2012 Author Share Posted February 2, 2012 (edited) hannes08 Thank you very much! You helped me a lot! Works perfect. Edited February 2, 2012 by Leanna Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now