Page 1 of 1

Error in range start expression

Posted: Tue Jan 05, 2016 11:56 pm
by A1Qicks
I ask a lot of questions. I hope no one minds - I'm very stupid and very persistent.

I've got this little clause in my code - it's pulling information from a MySQL database and puts it into tName and tMessage for this part, and I'm trying to get it so it posts item 1 of tName, then item 1 of tMessage, then item 2 of tName, and item 2 of tMessage, and so on until it runs out:

else
set itemDelimiter to return
put 1 into tMessageCount
repeat for each item theNames in tName
put "<" && item theNames of tName && ">" after field "textDisplay"
put item tMessageCount of tMessage after field "textDisplay"
add 1 to tMessageCount
end repeat

However I get an error for the illustrated line in "range start expression". The variables all seem to be what they should be at this point. I looked at other people's solutions across the internet and tried "repeat with i = 1 to the number of lines of tName" instead but it didn't change anything. Still got the same error in the same place.

Re: Error in range start expression

Posted: Wed Jan 06, 2016 12:04 am
by dunbarx
Quick look, you are over-thinking, and therefore overCoding.

If you already have a repeat loop that extracts successive items (each instance is "theNames") then you only need to:

Code: Select all

put "<" && theNames && ">" after field "textDisplay" 
Oh, and nobody yet, ever, ever asked too many questions. if you don't, I have to actually work at my job.

Craig Newman

Re: Error in range start expression

Posted: Wed Jan 06, 2016 7:37 pm
by A1Qicks
That works, thank you!

I was about to ask a further question that was tricky, but then I solved it. I love coding! It's like a lateral thinking puzzle. If you don't know the complicated way of doing something, look for an easy solution :D