How to make Truclient synchronous

Hi all

I am using java script in Truclient for executing a business logic.

Step 1: define variable  "interval=5"

Step 2: Evaluating Javascript and and incrementing interval=<dynamic value> based on the javascript logic.

Step 3: printing "interval"

However, when i execute this truclient, the final value it prints is "5" .

Truclient does not wait for step 2 to completely finish and it navigates to step 3 . However, javascript in step 2 still executes .

How can i make sure the javascript in step 2 is completed and only then the control should pass on to step 3?

Any suggestions?