RosettaCodeData/Task/Scope-modifiers/M2000-Interpreter/scope-modifiers-2.m2000

55 lines
1.2 KiB
Plaintext

Module CheckIt {
Module CheckSub {
Read Z
M=5000
Module CheckThis {
Z=500
Hello("Bob")
}
Function CheckFun {
Z=50
Hello("Mary")
}
Call CheckFun()
CheckThis
Hello("George")
Gosub label1
\\ sub work as exit here
Sub Hello(a$)
\\ any new definition erased at exit of sub
Local M=100
Print "Hello ";a$, Z, M
End Sub
label1:
\\ this light subs have no "erased new definition mode"
\\ they are like code of module
Print Z, M
Return
}
CheckSub 10
Module CheckOther {
Z=1000
Hello("John")
}
\\ we can replace CheckThis with CheckOther
CheckSub 20; CheckThis as CheckOther
}
Call Checkit
Module Alfa {
x=1
Thread {
x++
} as K interval 20
Thread {
PrintMe()
} as J interval 20
Main.Task 20 {
if x>99 then exit
}
Wait 100
Sub PrintMe()
Print x
End Sub
}
Call Alfa