
PRO
rz90208
USA
Asked
— Edited
I receive the error: Error on line 7: Missing ) in Expression
$HumanSaid = "How far is the earth from the moon"
$URL="http://api.brainshop.ai/get?bid=xxx&key=xxxxxxxxxx&uid=1&msg=" + $HumanSaid
$URL = $URL + "Hello There"
sleep(3000)
$Answer = HttpGet($URL)
$StringLength = length($Answer)
$MessageLength = $StringLength - 14
$APIResponse = SubString($Answer,11,$MessageLength)
Say($APIResponse)
The variable $Answer = "{"cnt":"The moon is 252,088 miles (405,696 km) from Earth."}" If $Answer does not contain the character ( , the code works fine.
Typo the line $URL = $URL + "Hello There" should not be there, I used it for testing.
I'm not a coding expert and I haven't messed with ez code for a while so I'm rusty. But.. I know ez script is very sensitive about spaces. I see that in your first $URL statement there is no space on either side of the = .
Also I don't see how you could have two variables, $URL, in the same script with two different explanations and not confuse the script.
OK. That explains the extra line.
Try adding a space before the = in the $URL line.
I'll get that exception on some of my scripts sometimes. I haven't been able to stop them. I had thought it was a timing issue at one time. I was able to make the problem better by adding some sleep commands but I can't confirm that's what helpped.
@rz90208,
It's a string limitation, some characters e.g. "(", new line characters aren't supported.
check the threads: https://synthiam.com/Community/Questions/8278
https://synthiam.com/Community/Questions/8172
https://synthiam.com/Community/Questions/9006
btw the response text can be more complicated...
try on your browser:
http://api.brainshop.ai/get?bid=nnn&key=xxxxx&uid=1&msg=what%20means%20handsome?
@DJ Any chance we can get this patched?
I read in one of the posts that the 4.x/2 update in march would correct it.
I tried doing a search of the string using the contains($x,$y), in hope I can just delete the (
But get the same error.
@rz90208 That's the problem with the left paren error. It can sit there in a string and be just fine, but as soon as you try to do any operation on the variable that contains the string, it crops up. Even if that operation is trying to remove, or replace the left paren. That's the Catch-22. What would be nice would be to have a file operation which would filter out (or replace) that sort of thing as it loads the up variable. But we don't have such a thing, and I don't have the inclination to make one.
What I do have is an external program that do all that. I simply gave up on ever having this problem fixed by EZ-Robot. It's been over a year now, after all. It was originally done as a temporary work-around. But programmers can't ever leave well enough alone. In it's latest incarnation, it can be set to filter out or replace any character (or group of characters) in the text. Additionally it can be set to look for key phrases to give it a starting place where to begin gathering the text from the web page, and a length of text to gather. That can drastically reduce the amount of text you (and the program) have to deal with. Once you send out a command to it (via a text file) it does all that and produces a text file as a result. You then bring in that text file instead of directly using the HTTPGet control.
The bad news is that I also used that project as a test bed to try out a new method of scripting that works more like other languages, complete with Function calls and a form of parameter passing. So there would be a bit of a learning curve to using it. The good news is that it only takes a few statements in this new style to implement it in any script. You can use the new methods and the current scripting methods together in one script. However you have to load up several script managers worth of scripts to your project to make it all work. This can be done via the "Merge" process in EZ-Script. They can be placed in another virtual window to get them out of the way. They are just a means to an end.
So it will solve your problem but take a bit more to implement. I should make a version that doesn't need the Merge and all that I guess, but I don't have the time at the moment. If you can wait for a week or so, I can probably do it then. If you are interested let me know.
@WBS Waiting is getting to be a habit. Waiting for the new EZB controller, the new EZB communications board, the new little EZB controller, waiting for EZ-AI. I'm not complaining well maybe a little. But ya, I'm interested. I will add you to my list.
Thank you for the response.
LOL, ya, I hate the waiting game. However I've learned that these things take time to develop and deploy. The only way around the flustration for the huddled masses is for the designers and manufacturers not to announce until the product is ready for sale. Where's the fun in that? We'd all lose interest and move on to whatever is available at the time. I remember waiting for the V4 and was one of the first to get one. It was more than worth the year + wait and frustrations with all the missed deadlines. I'm sure my wait on the new products coming out soon will be the same.