Question

The code below work fine, only I want to dynamically change the label text before the rollout is created, not afterwards. I'm trying to pass a variable (rolloutlabel) as a string in the rollout, only I can't seem do that without having to code around it by updating it with a button. The (unhelpful) error I get if uncomment the 6th line is "syntax error: at =, expected name"

rolloutlabel = "label"
rollout rolloutDialog "Rollout" width:100 height:50
(
    label alabel "" pos:[10,10] width:90 height:16
    button updateBTN "Update label" pos:[10,25] width:80 height:16
    -- alabel.text = rolloutlabel as string
    -- this just gets a syntax error if i leave it here uncommented
    on updateBTN pressed do
    (
        alabel.text = rolloutlabel
    )
)
createDialog rolloutDialog

Any idea where I'm going wrong?

Was it helpful?

Solution

Take a look at the rollout open clause:

rolloutlabel = "label"
rollout rolloutDialog "Rollout" width:100 height:50
(
    label alabel "" pos:[10,10] width:90 height:16
    button updateBTN "Update label" pos:[10,25] width:80 height:16
    -- alabel.text = rolloutlabel as string
    -- this just gets a syntax error if i leave it here uncommented

    on rolloutDialog open do
    (
        alabel.text = rolloutlabel
    )


    on updateBTN pressed do
    (
        alabel.text = rolloutlabel
    )
)
createDialog rolloutDialog

OTHER TIPS

You can keep the same script, but instead of the empty double quotes after alabel you can simply write rolloutlabel. The script will be like this:

rolloutlabel = "label"
rollout rolloutDialog "Rollout" width:100 height:50
(
    label alabel rolloutlabel pos:[10,10] width:90 height:16
    button updateBTN "Update label" pos:[10,25] width:80 height:16
    --alabel.text = (rolloutlabel as string)
    -- this just gets a syntax error if i leave it here uncommented
    on updateBTN pressed do
    (
        alabel.text = rolloutlabel
    )
)
createDialog rolloutDialog
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top