Code: Alles auswählen
Define string.s, string2.s
Define *bytecode, *bytecode2
Define vartype.PBSVarType
; Script 1:
string = #LF$
string + "Global val=0"+#LF$
string + #LF$
string + "While Quit=0"+#LF$
string + " For t=0 To 10 : Next"+#LF$
string + " val+1"+#LF$
string + "Wend"+#LF$
; Script 2:
string2 = #LF$
string2 + "For t=0 To 60000 : Next"+#LF$
string2 + "Quit=1"+#LF$
; Globale Variable Quit für alle Scripts bereitstellen
vartype\type = #PBSType_Integer
PBSCompilerAddVariable("Quit",vartype)
; Threadstart-Procedure
Procedure Start(wert)
PBSStartByteCode(wert)
Debug "Script "+Str(wert)+" beendet."
EndProcedure
; Script 1 kompilieren
*bytecode = PBSCompileScriptString(string)
If (*bytecode = #Null)
MessageRequester("Compiler-Error", PBSGetErrorText())
End
EndIf
; Script 2 kompilieren
*bytecode2 = PBSCompileScriptString(string2)
If (*bytecode2 = #Null)
MessageRequester("Compiler-Error", PBSGetErrorText())
End
EndIf
; Script 1 starten
PBSOpenByteMemory(0, *bytecode)
t1=CreateThread(@Start(),0)
Debug "Script 0 gestartet."
; Script 2 starten
PBSOpenByteMemory(1,*bytecode2)
t2=CreateThread(@Start(),1)
Debug "Script 1 gestartet."
Repeat
If (PBSGetVariableInteger(1, "Quit") = 1)
PBSSetVariableInteger(0, "Quit", 1)
EndIf
Delay(10)
ForEver
PBSCloseByteScript(1)
PBSCloseByteScript(0)
End
edit: so könnte man das z.b. mit jeder globalen variable machen:
Code: Alles auswählen
Global quit
Repeat
For i = 0 To #AnzahlScript-1
If (PBSGetVariableInteger(i, "quit") <> quit)
quit = PBSGetVariableInteger(i, "quit")
For k = 0 To #AnzahlScript-1
If (k <> i)
PBSSetVariableInteger(k, "quit", quit)
EndIf
Next
EndIf
Next
Delay(20)
ForEver