The scripts run concurrently. If you want to run scripts as a subroutine, and use the values generated by the subroutine, you must wait for the called script to finish before using the variables. Here is a link to a thread that has the code to make the main routine "wait" for the subroutine to finish. The code description starts with my post, about five from the start.
http://forum.mikrotik.com/viewtopic.php?f=9&t=39312