; JobProgressText Example ; ----------------------- ; Requires Extended mode. Graphics 640,480,0,2 SetBuffer BackBuffer() ; The worker builds a level in three named stages Worker Function BuildLevel(inputBank) For phase=1 To 3 If phase=1 Then stage$="Carving rooms" If phase=2 Then stage$="Digging corridors" If phase=3 Then stage$="Hiding treasure" For toil=1 To 10 ; Busy work standing in for real level generation For dig=1 To 800000 noise#=Sin(dig) Next ; The stage string here is what JobProgressText reports SetJobProgress (phase-1)*10+toil,30L,stage Next Next Return CreateBank() End Function job=StartJob(BuildLevel) While Not KeyDown(1) Cls ; JobProgressText returns a copy of the worker's latest stage text stage$=JobProgressText(job) ; Draw the loading bar so the stage text has context progress=JobProgress(job) Color 60,60,80 Rect 70,220,500,24,True Color 90,200,120 Rect 70,220,progress*500/1000,24,True Color 255,255,255 Rect 70,220,500,24,False Text 0,0,"Esc: exit" Text 70,190,"Watch the stage name change as the worker advances" Text 70,254,"JobProgressText(job) = "+Chr(34)+stage+Chr(34) If JobFinished(job) Then Text 70,274,"Level complete!" Flip Wend FreeJob job End