Page 1 of 1

Recalculate on variable change

Posted: Sat Dec 03, 2016 11:46 pm
by RossG
I have a variable which the user can change in a
drop-down list. A change of this variable will
trigger a re-calculation of data.

Can I have code which will start this re-calculation
when the user changes the variable (after a suitable
warning)?

I could use an ask dialogue if I could attach code to
one of the buttons (i.e "OK") else would need the
user to click another button. Would work but not
so "elegant" I feel.

While on the subject of the "ask" dialogue window
is there any way to change the size (in Win) or any
of the other parameters of said window?

I see elsewhere that the "ask" function is regarded
as being out-of-date. What's the best alternative?

Re: Recalculate on variable change

Posted: Sun Dec 04, 2016 1:17 am
by dunbarx
Any clever and fun choosing method will do. A drop down menu that magically appears when you click on the "Press Me" button? A scrolling list field?

Since you are changing a variable from the outside, may I assume this is a global?

In any case. Once you have your selection, you (pseudo)

Code: Select all

global gVar
  on menuPick pItemName
  put pItemName into gVar --if a pull down or similar button
  ---------
  put the selectedText into gVar --for a list field, say
  ---------
  doWhatEverElseMightBeAppropriateForTheMethodYouChose --for whatever

  
Or is any of this related to your problem?

Craig Newman

Re: Recalculate on variable change

Posted: Sun Dec 04, 2016 1:00 pm
by richmond62
Here's a thought:

on menuPick chooseNum
put chooseNum into CHNUM
answer "Do you want to recalculate with the new number?" with "Yes" and "No"
if it is "Yes" then
put ((CHNUM * 3) + 27) into fld "xyz"
end if
end menuPick
NC.png
Number Cruncher.livecode.zip
Here's the stack.
(1.2 KiB) Downloaded 219 times
Needless to say, if you want the menuPick to access a script outwith itself you will
need to put the chosen number into a global you have previously declared, and then
where my script has "put ((CHNUM * 3) + 27) into fld "xyz" " you will have to have something
like:

send "mouseUp" to button "Do It Baby"