
PRO
rz90208
USA
Asked
— Edited
Again I cannot see what I am doing wrong.
Is this another bug or am I using the array incorrectly?
This worksCode:
DefineArray($TestArray,2)
$SearchString = "aaaa"
$TestArray[1] = "<aaaa><bbbb><cccc>"
if($SearchString = SubString($TestArray[1],1,4))
Print("Correct")
endif
This DontCode:
if($SearchString = SubString($TestArray[1],1,IndexOf($TestArray[1],"><")))
Code:
***Edit*** never mind you fixed it...
I tried to simplify the expression, and didn't remove the extra closing bracket.
But when I did simplify it, it did work.
Code:
EZ-Script is good for simple scripts, and i believe it was developed for simple statements.
there are no expression trees or byte code translation the script lines/statements are evaluated on the fly using a text parser and the things can get complicated with nested conditions, multiples arguments, operators etc.
with that in mind you have some options:
1) Simplify the expressions like using variables, remember everything is evaluated on the fly so replace multiple function calls assigning the function result to a variable and reusing the variable to check the result.
2) Avoid nested expressions
3) Avoid complex scripts when possible
OR
1) Learn c# and create a plugin
2) use the DJ's Javascript plugin:
https://synthiam.com/redirect/legacy?table=plugin&id=224
the plugin uses a Javascript Interpreter for .NET (Jint) https://github.com/sebastienros/jint
Is not fast as c# code but it's well known, and if you find a language/parser issue you can open a ticket.
I did just that and simplified the script using variables.
It is not easy to build even a simple brain and not write complex scripts.
I do know some JavaScript, would be nice to have a script manager for js as we do for ez-script.
Thanks again for your reply.
Code:
And so does this, by adding spaces (for some reason) with proper code formatting
Code:
If you wish to use javascript, use the javascript plugin from here: https://synthiam.com/redirect/legacy?table=plugin&id=224
To help troubleshoot:
Code:
EDIT: I've changed the code with several combinations, a space before the IndexOf does the trick
My son tells me to start using JavaScript also, but I love using EZ-Script it is so EZ and powerful.
Thank you also ptp