In this part we will see how we can call code ffor exedcution rom code. This part has the calling for modules, functions and lambda functions, plus subs and simple functions.
Also we will see the use of Variant variable. The return type of a function depend of the type of result, which return through the statement = (the sign of equal as statement is the return from function, and isn't an exit from function, we can execute more commands after the return value passed to an internal buffer. Also we can pass more times a value, and the last one survives for return value)
Just copy these lines in a module A and then press esc and write A and press enter to get the results.
module TestModule (that, num1) {
// the names ThisIsAModule, ThisIsAFunction, ThisIsALambdaFunction, A
// aren't exist before interpreter found as interpret
module ThisIsAModule (that) {
Print "("+that+")"
}
function ThisIsAFunction(that) {
=that
}
ThisIsALambdaFunction = lambda (that) -> {
=that
}
Variant A
A=that
A+="..."
Print A=that+"..."
Print @ThisIsASimpleFunction()=that+"..."
Print ThisIsAFunction(A)=that+"..."
Print ThisIsALambdaFunction(A)=that+"..."
ThisIsASubroutine()
// calling a Module we don't use parenthesis for parameter list
// parameters can be put in stack before call also
ThisIsAModule A
Push A
ThisIsAModule
// we can change type from string to number (by default 100 is a double - 8byte)
A=num1
A++
Print A=num1+1
Print @ThisIsASimpleFunction()=num1+1
Print ThisIsAFunction(A)=num1+1
Print ThisIsALambdaFunction(A)=num1+1
ThisIsASubroutine()
ThisIsAModule A
Push A
ThisIsAModule
// sub or function without {} is an END
// so interpreter at the next statement exit from module
// subs and simple functions run on same namespace as the calling namespace
// so A is not local here
// we have to use LOCAL to define local variables.
sub ThisIsASubroutine()
Print "("+A+")"
end sub
function ThisIsASimpleFunction()
=A
end function
}
ClS 5, 0
PEN 15
TestModule "ok", 100
Module ByPassDeclaration (B) {
Print "This is a ByBass:";B
}
// 50% is a 16bit integer, 50& is 32bit integer
// 50# is Currency type, 50@ is Decimal type, 50! is single
// try those too
// this call has a decoration, which tell that the call has a predefined module
// ThisIsAModule using code from ByPassDeclaration.
// The inner code for ThisIsAModule skipped at execution
// We can do the normal call after this without decoration
TestModule "George", 50%; ThisIsAModule as ByPassDeclaration
// 100&& is long long literal (64bit signed integer)
TestModule "George", 100&&
Δεν υπάρχουν σχόλια:
Δημοσίευση σχολίου
You can feel free to write any suggestion, or idea on the subject.