TaskResult

Function

Syntax

Gives the value that a finished task returned with RETURN.

TaskResult(<handle>)

Parts

<handle>A task handle: a variable filled by STARTTASK.

Returns

The RETURN value of the task. If the task failed, it raises the task's error. If the task is still running or was cancelled, it raises BASIC task has no completed result.

Good to know

  • Read it after AWAITTASK, or once TaskDone() is true.
  • A task that ends with a bare RETURN has no usable result: Str(TaskResult(h)) gives undefined.
  • This is the way to get a task's value: x = AWAITTASK h is not supported.

Example

job AS TASKHANDLESTARTTASK job, RollAWAITTASK jobscore = TaskResult(job) * 10Console("score " + Str(score))   ' score 60ENDRoll:  Wait(0.1)RETURN 6
In the manual : The game loop and tasks