View Single Post
Old 8th November 2021, 23:15   #74  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
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 View Post
EDIT3:
It doesn't work because if/else is inside eval("""..."""), need to get rid of it.
looks like you got it.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 8th November 2021 at 23:43.
StainlessS is offline   Reply With Quote