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 works
DefineArray($TestArray,2)
$SearchString = "aaaa"
$TestArray[1] = "<aaaa><bbbb><cccc>"
if($SearchString = SubString($TestArray[1],1,4))
Print("Correct")
endif
This Dont
if($SearchString = SubString($TestArray[1],1,IndexOf($TestArray[1],"><")))
You have one too many closing brackets in this line...
Edit never mind you fixed it...
@RichardR I tried to simplify the expression, and didn't remove the extra closing bracket. But when I did simplify it, it did work.
Still have the issue with the IndexOf with in the expression
If I use a variable in the expression it works.
@rz90208
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:
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.
Avoid nested expressions
Avoid complex scripts when possible
OR
Learn c# and create a plugin
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.
Thanks ptp, 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.
This code works perfect
And so does this, by adding spaces (for some reason) with proper code formatting
If you wish to use javascript, use the javascript plugin from here: https://synthiam.com/redirect/legacy?table=plugin&id=224
@DJ,
To help troubleshoot:
EDIT: I've changed the code with several combinations, a space before the IndexOf does the trick
Okay - i fixed it for next release. There was a goof in the regex
Thank you again DJ. 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