You can only really load script functions containing GScript extensions, [or whatever code allowed in *.avsi scripts],
in main script, must still wrap any GScript extension code.
Not ideal, but there you go
[Gscript("...") and GImport("...") and GEval("...") only affect code that is wrapped in those G thingies]
where Import() is sorta like
Code:
S = RT_ReadTextFromFile(".\SomeScriptFile.avs")
Eval(S)
GImport() is sorta like,
Code:
S = RT_ReadTextFromFile(".\SomeIfElseFile.avs")
GEval(S)
GScript() is sorta like,
Code:
S = "Some If Else stuff"
GEval(S)
You can use eg
Code:
Function FuncNameExists(String Fn) { Try{Eval(Fn+"()")B=True}catch(e){Assert(e.FindStr("syntax")==0,"FuncNameExists: Error in Function Name '"+Fn+"'")B=(e.FindStr("no function named")==0)}Return B}
Function HasGScript() { Return FuncNameExists("GSCript") } # v2.60 std dont have FunctionExist(), so we use above whotsit [which i believe will work ok even in v2.58].
gString =""" Some If Else Stuff"""
(HasGScript) ? GEval(gString) : ? Eval(gString)
Quote:
Originally Posted by VoodooFX
EDIT3:
It doesn't work because if/else is inside eval("""..."""), need to get rid of it.
|
looks like you got it.