Weird prompt with Answer

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
david_fff
Posts: 29
Joined: Wed Nov 12, 2014 5:29 pm

Weird prompt with Answer

Post by david_fff » Tue Jan 12, 2016 6:47 am

When I first open my stack and run a script to identify non-existent items:
repeat with x = 1 to number of lines of selll
put word 1 of line x of selll into nmm
put "d" & char 1 of nmm into windy
if exists(cd nmm of wd windy) then
else
answer "Item"&&nmm&& "does not exist in stack"&&windy&". Please delete it from your list of selected items." with "OK"
exit mouseup
end if
end repeat
the "answer" prompt formats properly. However, after I run another script, the answer prompt goes berserk. For example, for the answer line above, if, say, nmm = 11111Q,
and windy = d6, it would return with the prompt "Item 11111Q" and the button would not be "OK" but rather "does not exist in stack d6. Please delete it from your list of selected items."
After it begins to act up like this, all of the other scripts with "answer" commands begin to do the same thing, using only the first word or two as the prompt and the rest as the response button title, and dropping the desired title defined with "with".
By the way, this was with LC 7, but I downloaded LC 8 and it is doing the same thing. Grateful for any ideas...

scrabbles
Posts: 25
Joined: Sat Dec 20, 2014 4:32 am
Location: Melbourne, Australia

Re: Weird prompt with Answer

Post by scrabbles » Tue Jan 12, 2016 7:32 am

hi ya,

Just a stab in the dark at this, but does exiting the mouseup from a loop contribute to this behaviour? if you do "exit repeat" instead, and then let the mouseup exit by itself, does it still happen?

- mark

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Weird prompt with Answer

Post by SparkOut » Tue Jan 12, 2016 8:10 am

Check for quotes and odd characters in the list. I think nmm could contain a double quote, which closes the answer statement prompt in the wrong place.

Klaus
Posts: 13821
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Weird prompt with Answer

Post by Klaus » Tue Jan 12, 2016 11:28 am

Hi david_fff,

what SparkOut said!

Little sidenote, your ELSE does not make any sense, so just avoid it!

Code: Select all

...
if NOT exists(cd nmm of wd windy) then
   answer ...
   exit mouseup
end if
...
:D


Best

Klaus

david_fff
Posts: 29
Joined: Wed Nov 12, 2014 5:29 pm

Re: Weird prompt with Answer

Post by david_fff » Tue Jan 12, 2016 7:42 pm

Thank you all so much. I traced the problem to what must have been an invisible quote in my variable. When I erased the source of that variable and retyped it, it worked as it should. :D Thanks again!

david_fff
Posts: 29
Joined: Wed Nov 12, 2014 5:29 pm

Re: Weird prompt with Answer

Post by david_fff » Wed Jan 13, 2016 1:06 am

I played around with this some more and now I really do believe in tech gremlins: the source of that variable was the last line in a field, let's say it looked like it was
12345Q
so I use the message box to get the number of chars of this line and it returns - get this - 7! 7!! So I ask for the chartonum of the last char of that line and it returns 0! 0!!! So I click that last line to edit and the cursor is flat up against the Q, and hit delete, and: NOTHING HAPPENS! At least nothing that I can see happens. But now there are 6 chars, not 7, on this line. Then I hit delete once more and the Q erases, retype the Q and all works as it should. SO the moral of this story is: BEWARE OF INVISIBLE CHARACTERS! ...and tech gremlins.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7228
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Weird prompt with Answer

Post by jacque » Wed Jan 13, 2016 5:46 pm

The invisible character was a null, whose ASCII number is zero. Counting the number of characters in a line will also count the invisible one, so you get 7. Deleting an invisible character won't move the cursor because the character isn't visible but it still removes it, reducing the count to six.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Talking LiveCode”