answer text as constant and the quotation marks?

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
pgerrish
Posts: 4
Joined: Thu Dec 12, 2013 5:45 pm

answer text as constant and the quotation marks?

Post by pgerrish » Thu Dec 12, 2013 7:12 pm

New to coding and to LiveCode. Have the text for answer box that is used in many places and trying to use a constant placed in card script to hold the appropriate text.
The statement directly placed in a button script works.
answer "Current activity being timed - Finish timing and start new activity or cancel new one" with "Finish" or "Cancel"
I would like to be able to put in the button script
answer value(ActivityTimingInProcess)
and in maincard script define a constant
constant ActivityTimingInProcess="Current activity being timed - Finish timing and start new activity or cancel new one" with "Cancel" or "Finish"
This does not work but following without buttons texts does.
constant ActivityTimingInProcess="Current activity being timed - Finish timing and start new activity or cancel new one"

I am having trouble with the various extra sets of quotation marks for buttons. Have tried double sets in various places and single+double around the cancel etc.. Have run out of ideas. This is simple issue but if anybody could help or say it is not possibile then would be grateful. Di I need to be doing soem construction with &&?

Thanks

Paul

Paul

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: answer text as constant and the quotation marks?

Post by Klaus » Thu Dec 12, 2013 7:23 pm

Hi Paul,

1. welcome to the forum! :D

2. Declar a constant at the top of your stack script:

Code: Select all

constant ActivityTimingInProcess= "Current activity being timed - Finish timing and start new activity or cancel new one"
 
on openstack
  ###
end openstack

## Then create a handler for this, so you can execute this everywhere in your stack!
function answer_the_contant
  answer ActivityTimingInProcess with "Cancel" OR "New"
  return it
end answer_the_contant
Then, on any card you can:

Code: Select all

on mouseup
  put answer_the_contant() into what_the_user_answered
  if what_the_user_answered = "cancel" OR what_the_user_answered = EMPTY then
     exit mouseup
  end if

   ## user selected NEW, act accordingly here:
   ## :-)
end mouseup
Hope that helps!


Best

Klaus

pgerrish
Posts: 4
Joined: Thu Dec 12, 2013 5:45 pm

Re: answer text as constant and the quotation marks?

Post by pgerrish » Thu Dec 12, 2013 7:28 pm

Klaus

Very Helpful thank you - will try that.

thanks

Paul

pgerrish
Posts: 4
Joined: Thu Dec 12, 2013 5:45 pm

Re: answer text as constant and the quotation marks?

Post by pgerrish » Thu Dec 12, 2013 8:07 pm

Klaus

All works fine. It has also helped me understand approaches. All my 9 buttons behave when clicked except they put their own label into field CurrentActivity. I have been unable to access the label property of the button except from with the button scrip itself using put the label of me into field "CurrentActivity" . Apart from this I could put the whole button script in one place handler in the card script and then reference it in each button with one call. My problem is the label of me is interpreted at the card level as the label of the card not the button clicked. Do you know if it is possible to have it detect the label of the button that was clicked generically from a card script?

Understand if you are too busy to reply to another question not original topic. Feel making progress in my first day of coding!

thanks

Paul

Button Script currently

on mouseUp
if field "CurrentActivity" is empty then
put the label of me into field "CurrentActivity"
StartActivityTiming
else
put answer_the_constant() into user_response
if user_response="Cancel" OR user_response=EMPTY then
exit mouseUp
end if
EndActivityTiming
put the label of me into field "CurrentActivity"
StartActivityTiming
end if
end mouseUp

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: answer text as constant and the quotation marks?

Post by Klaus » Thu Dec 12, 2013 10:14 pm

Hi Paul,

well, I live here, so no other important things to do! :D
Apart from this I could put the whole button script in one place handler in the card script and then reference it in each button with one call.
Very good!
My problem is the label of me is interpreted at the card level as the label of the card not the button clicked
Just pass a parameter to the call -> the label of the button clicked!

Card script:

Code: Select all

command cardLevelMouseup tLabel
  ## do your "generic"stuff with tLabel here!
   ...
   put tLabel into field "CurrentActivity"
   ...
end cardLevelMouseup
Button script(s)

Code: Select all

on mouseup

  ## Let the button pass its LABEL
  cardLevelMouseup the label of me
end mouseup
I think this will fit your needs :D


Best

Klaus

pgerrish
Posts: 4
Joined: Thu Dec 12, 2013 5:45 pm

Re: answer text as constant and the quotation marks?

Post by pgerrish » Thu Dec 12, 2013 11:29 pm

Brilliant. I am still coming to terms with the much looser natural language e.g label of me. Had not thought of the parameters idea - measure of my inexperience.

Thanks

Post Reply