Page 1 of 1

I'm doing wrong here please help me

Posted: Tue Jun 18, 2019 4:23 am
by luanvan24
Not sure what I'm doing wrong here:
CODE: SELECT ALL

answer information dialogData
put word 1 of the dialogData into ttemp
put word 2 of the dialogData into tinterval
answer information ttemp && tinterval
The first answer information shows "15 Day(s)" - that's a space between the two words. The second answer displays "OK".

I'm sure this is something really stupid I'm doing but I've stared at it for too long!

Re: I'm doing wrong here please help me

Posted: Tue Jun 18, 2019 8:17 am
by AndyP
This is probably to do with the separator you are using between the words.

LC normally defaults to a comma as the separator but you can change this by using

Code: Select all

set the itemdel to space
dictionary entry

https://livecode.com/resources/api/#liv ... mdelimiter

Re: I'm doing wrong here please help me

Posted: Tue Jun 18, 2019 10:05 am
by Klaus
Hi luanvan24,

welcome to the forum!
(A little Hello or something would not have hurt for the very first posting 8) )

OK, lets see:

Code: Select all

...
answer information dialogData
...
This line showed -> 15 Day(s)
BUT it will also will OVERWRITE the former dialogdata with the name of the clicked button -> OK,
simply because THAT is now the dialogdata.

Code: Select all

...
put word 1 of the dialogData into ttemp
put word 2 of the dialogData into tinterval
answer information ttemp && tinterval
...
Since "OK" is only one word, the dialog behavior is correct!

Try with this little script:

Code: Select all

on mouseUp pMouseButton
   set the dialogdata to "whatever"
   answer the dialogdata
   put the dialogdata
end mouseUp
You will see OK in the message box.
This is how the dialogs work, this is the last line in the "mouseup" handler of the "Answer dialog" stack:

Code: Select all

...
  set the dialogData to the short name of the target
  ## Means the button the user clicked
end mouseup
Just like IT you should store the dialogdata in another variable before using it again, something like:

Code: Select all

...
## Whatever you did to ANSWER 15 Days
set the dialogdata to "15 Day(s)"
put the dialogdata into theFormerAnswer
answer the dialogdata
answer information theFormerAnswer 
put word 1 of theFormerAnswer into ttemp
put word 2 of theFormerAnswer into tinterval
answer information ttemp && tinterval
...
That should do the trick.


Best

Klaus