user-interfacescopedialogmaxscriptrollout

Mxs: Rollout control value not defined in scope (filein)


I am trying to acces the state/value of rollout controls (checkboxes, spinners etc.) from inside a nested function (a function I call using the filein() command), however I keep getting the error that the rolout control is undefined.

I've written some simple code to demonstrate the issue:

1) The main script which inputs a file using the filein command:

Rollout exporter "Simple Exporter" width:300 height:610 (
    button btn_do_stuff "Do stuff" pos:[18,14] width:116 height:60 
    checkbox some_option "some_option" pos:[18,100] width:116 height:60

    on btn_do_stuff pressed do(
        filein "printstuff.ms"
    )   
)
createdialog exporter

2) The script file that is being imported using filein() command:

if some_option.checked == true then(
    messagebox "some_option.checked == true"
    )else(
    "some_option.checked == false"
    )

3) Error message :

-- Unknown property: "checked" in undefined <<

The error occurs in the 1st line of the script file that is being imported using filein : error occurs in the following line:

if some_option.checked == true then(

Any help will be greatly appreciated, thank you!


Solution

  • Filein gets evaluated in global scope, it has only access to global variables, not the locals you're trying to access. That said, here the solution is simple as the rollout itself seems to be declared in global scope – instead of some_option.checked use exporter.some_option.checked.