I'm doing wrong here please help me

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
luanvan24
Posts: 1
Joined: Tue Jun 18, 2019 3:50 am
Contact:

I'm doing wrong here please help me

Post by luanvan24 » Tue Jun 18, 2019 4:23 am

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!
Attachments
Capture.JPG

AndyP
Posts: 419
Joined: Wed Aug 27, 2008 12:57 pm
Location: Seeheim, Germany (ex UK)
Contact:

Re: I'm doing wrong here please help me

Post by AndyP » Tue Jun 18, 2019 8:17 am

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
Andy Piddock

http://2108.co.uk/tinyide/ - Mini LC IDE alternative

http://2108.co.uk/script-editor-themer/ - Script Editor colour theming

http://livecodeshare.runrev.com/stack/897/LiveCode-Multi-Search - Search across 8 LC resources

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

Re: I'm doing wrong here please help me

Post by Klaus » Tue Jun 18, 2019 10:05 am

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

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”