there are several ways you can approach this, i would use arrays..
this is just a demonstration off the top of my head
( I'm not a fan of pseudo arrays! eg id%a_index%, c%a_index%, ... )
Code: Select all
v1:=12
v2:=2
v3:=7
v4:=4
v5:=18
; Values used for sorting. id1 represents v1, id2 represents v2 and so on.
id1:=500
id2:=200
id3:=1000
id4:=700
id5:=400
arr := {}
While ( id%a_index% )
arr[ id%a_index% ] := "v" a_index
For Each, Val in arr ; only works for ascending order
{
c%a_index% := Val ; assign the variable id%number% to pseudo array / variable c%number% in order
displaystring .= Val "->"
}
msgbox % Trim( displaystring, "->" ) "`nThe value of C3 is: " C3
In the final you'd want to remove pseudo arrays and just use real arrays ( if possible ).
edit: actually in this case pseudo arrays are ok if you're assigning variables to be used at a later point.