Notifications
Clear all

[Closed] Rollouts Construction

Hi,

In a rolloutfloater with for example 2 subrollouts, is it possible to dynamically update one of the subrollout according to the changes made in the other.
For example if i have a spinner in the first rollout and change its value, i would like that another spinner in the 2nd rollout updates dynamically.

Thanks

4 Replies

Sure. If the subrollouts were declared as global, just reference the subrollout property as you would a rollout property.

– in subrollout sro1
on spn changed val do sro2.spn.value = val

I’m not sure right now what the differences are (if there are any) if you’re in macro-scope.

Thanks,

I was stupid; i’ve tried it before posting but i had forgotten to DECLARE the subrollout as a global variable.

Thanks again


  global rlt_Main
  global rlt_Sub
  
  rollout rlt_Main (
       spinner spn_Main "Value:"
  
       on spn_Main changed val do rlt_Sub.spn_Sub.val = val
  )
  
  rollout rlt_Sub (
       spinner spn_Sub "Value:"
  
  )

Wow I’m on a roll of possibly applicable scripts this week from scripts I wrote in the last two weeks. Just in case you need to take your spinner linking to a whole new level:


[left] spinners = #(0.0,0.0)
Rollout linkedrollout "Linked Spinners" 
(
 checkbox link12 "Link12"
 radiobuttons GA_12 labels:#("Geo", "Arithmatic")
 spinner spin1 "Spinner 1" 
 spinner spin2 "Spinner 2"

 on linkedrollout open do
 (
  spin1.value = spinners[1]
  spin2.value = spinners[2]
 )
 
 on spin1 changed true do
 (
  if GA_12.state == 1 and link12.checked != false then
  (
   if spinners[1] != 0 and spin2.value != 0 then
   (
	Spin2.value = ((spin1.value/spinners[1])*spinners[2])
	spinners[1] = spin1.value
	spinners[2] = spin2.value
   )
   else if link12.checked != false then
   (
	spinners[1] = spin1.value
   )
  )
  else if GA_12.state == 2 and link12.checked != false then
  (
   Spin2.value = ((spin1.value-spinners[1])+spinners[2])
   spinners[1] = spin1.value
   spinners[2] = spin2.value
  )
  else
  (
   spinners[1] = spin1.value
   spinners[2] = spin2.value
  )
 )
 
 on spin2 changed true do
 (
  if GA_12.state == 1 and link12.checked != false then
  (
   if spin1.value != 0 and spinners[2] != 0 then
   (
	Spin1.value = ((spin2.value/spinners[2])*spinners[1])
	spinners[1] = spin1.value 
	spinners[2] = spin2.value
   )
   else
   (
	spinners[2] = spin2.value
   )
  )
  else if GA_12.state == 2 and link12.checked != false then
  (
   Spin1.value = ((spin2.value-spinners[2])+spinners[1])
   spinners[1] = spin1.value
   spinners[2] = spin2.value
  )
  else
  (
   spinners[1] = spin1.value
   spinners[2] = spin2.value
  )
 )
)
createdialog Linkedrollout [/left]