Help with words

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: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Help with words

Post by phaworth » Sun Aug 09, 2009 11:16 pm

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!

Pete

edljr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 56
Joined: Sun Oct 26, 2008 6:47 am
Contact:

Help with words

Post by edljr » Mon Aug 10, 2009 4:56 am

Pete,

What is your goal with this code snippet?

Ed
--
Ed Lavieri
three19
www.three19.com
--

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Post by phaworth » Mon Aug 10, 2009 5:44 am

The code is really trying to figure out what's going on. The real application calls a modal form that returns information in the dialogData (that's the "15 Day(s)" which I then need to separate out into two parts to use within the calling form.
Pete

edljr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 56
Joined: Sun Oct 26, 2008 6:47 am
Contact:

Help with words

Post by edljr » Mon Aug 10, 2009 5:53 am

Pete,

If I understand you correctly, the below code should demonstrate how to parse the input into 2 different chunks. I added extra answer commands to demonstrate the parsing.

Code: Select all

on mouseUp
   local exampleReturnData
   
   put "15 Day(s)" into exampleReturnData
   
   put word 1 of exampleReturnData into tTemp
   put word 2 of exampleReturnData into tInterval
   answer tTemp -- shows the first word was parsed
   answer tInterval -- shoes the second word was parsed
   answer information tTemp && tInterval 
end mouseUp
HTH,
Ed
--
Ed Lavieri
three19
www.three19.com
--

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Post by phaworth » Mon Aug 10, 2009 6:19 am

Hmm, well I'm not seeing any difference between your code and mine except that you're using a local variable instead of dialogData. I tried your code and it works correctly as written. I then changed it to use dialogData instead of exampleReturnData and same thing happens as in my code - ttemp contains "OK" and tinterval is empty.

There's clearly something different about dialogData than other variables/properties but I have no idea what it is!

Pete

edljr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 56
Joined: Sun Oct 26, 2008 6:47 am
Contact:

Help with words

Post by edljr » Mon Aug 10, 2009 6:35 am

Pete,

It would hope to see what code precedes what you posted.

If you merely execute "answer information dialogData" then the only value in dialogData is "OK." If your answer call returns more than just "OK," then you might be able to use something like:

put the first item of the dialogData into tAnswer -- not sure
put the last item of the dialogData into tVar -- this should be the "OK"

If you want further help, please paste additional code or your stack.

Ed
--
Ed Lavieri
three19
www.three19.com
--

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Post by phaworth » Mon Aug 10, 2009 7:06 am

Ed,
There's one line of code before what was in my original post:

go to card "RepeatPrompt" of stack "Prompts" as modal

That card puts the result of user input into dialogData and then closes, at which point I'm back in the original card at the first answer statement. According to the Dictionary, that's what dialogData is for. The first answer information in my original post happens right after the go statement above and it shows that dialogData contains "15 Day(s)", not "OK". It's only after the two put statements that the OK shows up.

Try using the code you posted but just substitute dialogData for the name of the local variable you used and you'll see what I mean.

Very weird.
Pete

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Post by phaworth » Mon Aug 10, 2009 7:39 am

Never mind, got the answer from someone else. The answer information dialog, overwrote what's in dialogData - that's where the OK comes from (the name of the button on the answer information card).
Pete

Post Reply