This is a solution using a for loop. I’m supposing the variables are global but if they are local, then the sub-routine should be kept in the same file as the variables.
*label calculate_max_3
*temp array_1 "apples"
*temp array_2 "bananas"
*temp array_3 "pineapples"
*temp array_4 "oranges"
*temp array_5 "kiwis"
*temp array_6 "tomatoes"
*temp max_1 array[1]
*temp max_2 (1-1001)
*temp max_3 (1-1001)
*temp loop_counter 2
*label begin_for_loop
*if {array[loop_counter]} > {max[1]}
*set max[3] max[2]
*set max[2] max[1]
*set max[1] array[loop_counter]
*goto continue_for_loop
*elseif {array[loop_counter]} > {max[2]}
*set max[3] max[2]
*set max[2] array[loop_counter]
*goto continue_for_loop
*elseif {array[loop_counter]} > {max[3]}
*set max[3] array[loop_counter]
*goto continue_for_loop
*else
*goto continue_for_loop
*label continue_for_loop
*set loop_counter +1
*if loop_counter <= 6
*goto begin_for_loop
*comment end_for_loop
*return
