Asked
— Edited

I'm getting an error message in one of my scripts that is giving me some trouble. It's a random error meaning that it will happen every few times the command is run. It's set in a loop so it will repeat. Sometimes it will even cause the connection between the EZB and computer to cut off. Here'e the error:
Error on line 25: Missing String Quotes or Invalid Expression at index 14: "
and
Error on line 25: Missing String Quotes or Invalid Expression at index 15: "
Here's the script to happens in. Seems to center around the print commands. Once I removed the print command at line 25 and the error skipped to the next one. I've also expanded the sleep() commands thinking it was running too fast but it does not help. Thanks for looking :
# This Script will return the actual position number of the left catrrage
# #from the Kangaroo withough the 1,p in the begining.
# #Returning feedback with the 1,p causes problems.
# #Do Not Delete. Other scripts depend on this script!
# -------------------------------------
# Get Roo position
uartWrite(2, 2, "2, Getp", 0x0d)
:waitForData
Sleep(30)
$y_lft = UartAvailable(2, 2)
Sleep(30)
print("Bytes in buffer:" + $y_lft)
if ($y_lft < 6)
# Go back and wait for data again because we did not receive the least number of expected bytes.
goto(waitForData)
endif
Sleep(30)
$Get_Lft_Carrage_P = UARTRead(2, 2, $y_lft)
Sleep(30)
print("Received: " + $Get_Lft_Carrage_P)
Sleep( 50 )
# -------------------------------
# Find out and print if the P is upper or lower case.
# Upper case means motor has finished move ans stoped.
# Lower Case means that motor is still moving.
$P_lft_or_p_lft = GetCharAt($Get_Lft_Carrage_P, 2) #Assign a variable to either a capitol P or Small case p returned by Kangaroo.
Print("P_lft_or_p_lft:" + $P_lft_or_p_lft)
# -----------------------------
# Defeat the P_lft_or_p_lft
if ($P_lft_or_p_lft = "p")
Goto(Lower_p_Split)
ELSEif ($P_lft_or_p_lft = "P")
Goto(Upper_P_Split)
endif
Sleep( 50 )
:Lower_p_Split
$Lft_Carrage_Position = Split($Get_Lft_Carrage_P, "p",1) #1,pXXXX is returned. Get everything after the Lower case p (P is case senceitive).
Sleep(30)
print("Received:" + $Lft_Carrage_Position)
Halt()
:Upper_P_Split
$Lft_Carrage_Position = Split($Get_Lft_Carrage_P, "P",1) #1,pXXXX is returned. Get everything after the Upper case P (P is case senceitive).
Sleep(30)
print("Received:" + $Lft_Carrage_Position)
Understood Will. Well Will, will you mind if I assert my will here in all things Will? I insist that Will's project be given full priority if DJ is willing. I'd hate Will to willfully insist that he was first in line. Will , I hear you're a scary and dangerous dude when you're mad and I don't yet have my Will prepared. God willing, it won't have to come to that. (That was a whole lot of Wills)
Ahh yes that was me! Brain fart....can you hear that sound ? That's brain cells dying! Thanks DJ!
Lol Dave!
After working on this issue for the past few days and trying many different things I'm certain the EZB disconnect issue was that I was calling for information from the same Uart port at the same time by two different scripts. After I reset the timing of these commands the disconnect problem went away.
However no matter what I do I cant get the "random" Missing String Quotes or invalided expression" error to go away.
I rewrote my script to determine if the "P" in 1,p820 is upper or lower case. This tells me simply if my move has completed or is still in process. After disabling all the print commands that we thought were the problem I'm now getting this error in other commands. Here's that script:
This is the latest problem command in the above script getting the Missing String Quotes or Invaded Expression error (and it does not have any quotes in it):
It has got to be as DJ says and be the Variables causing an "Invalided Expression". In the above command I'm trying to extract the 3rd character of something that looks this read: 1,p820. I'm trying to pull the "p" out and store it in a variable. I'm basing this on the example in the Scripting Cheat Sheet:
Maybe I'm using the wrong command? should I be using the GetByteAt command? Is 1,p820 outside of readable ASCII?
Any thoughts? confused
It's the wrong UARTRead command. Use UARTReadBinary() and read the data into an array. You split the data into an array anyway.
Here...
OMG thanks! eek You saved me about two days of struggle and probability saved my marriage in the process. LOL.
Looking through your rewrite I was very close. Just missing a few of the right words and proper brackets. LOL. I'll give it a try.
OK, that seems to be running when I test it in the console and ARC is connected to EZB in the robot.
However, I'm getting the number 80 returned instead of the "P" I'm expecting. Do I need to convert this returned number to a letter "P" somehow in the script after it's returned? If so will this number be different if a lower case "p" or some other numberis returned? If the number 80 is equivalent to a "P" and I know it then this will work.
Sorry, I feel like a blind man here. What do the [] do at the end of: $Lft_P_or_p = $Get_Lft_Carrage_P[2] ?
Here is what is returned in the console:
80 is upper case P. 112 is lower case p. See: http://www.asciitable.com/mobile/
Alan