Display box encryptionIt's a known issue that substituting display boxes doesn't work in encryption, but I thought I was able to put them into associative arrays and it would work. Maybe I'm just extra bad at my job today. Does anyone have a better way to deal with displaybox encryption that is NOT surfing the display tree? Also holding a here or global variable is a non-starter.
do_something = function ({aa}, {Default Local},
cb = aa["cb2"];
rb = aa["rb"];
show(cb<<CLASS name=""></CLASS>Re: Display box encryptionVince - when you encrypt the script, I think it is probably streaming out the text representation of the display boxes in the associative array. There is no way for that to stream back in and be connected to the actual boxes in memory. (That may not be exactly right; I don't know why it needs to stream them.)
My work-around uses temp=NewNameSpace() with no explicit name. Add the data to temp AFTER creation (temp:b1=box;), then pass temp<etName as the parameter for the callbacks. On the far end, use temp=NameSpace(passedName) to get the namespace back. Finally, add an OnClose handler to the window to delete the namespace.
The unnamed namespaces do get an internal name, like "#37".
So, roughly like this:
do_something = Function( {ns},
{Default Local},
Show( ns );
ns = Namespace( ns );
Show( ns );
cb = ns:cb2;
rb = ns:rb;
Show( cb << class name ); // this works
cb << Set Items( {"1", "2"} ); // but this doesn't????
);
gen_dummy_cb_ui = Function( {},
{Default Local},
vlb = V List Box(
btn = Button Box( "Press me" ),
cb1 = Combo Box( {"Change me", "B"} ),
cb2 = Combo Box( {"This should change"} ),
rb = Radio Box( {"1", "2"} )
);
//aa = Associative Array( {"cb1", "cb2", "rb"}, Eval List( {cb1, cb2, rb} ) );
temp = New Namespace();
temp:cb1 = cb1;
temp:cb2 = cb2;
temp:rb = rb;
Eval(
Substitute(
Expr(
btn << Set Function(
Function( {this},
{cb},
Show( "btn" );
do_something( DV_NS );
)
);
cb1 << Set Function(
Function( {this, index},
{cb},
Show( "cb1" );
do_something( DV_NS );
)
);
),
Expr( DV_NS ), temp << getname
)
);
Return( Eval List( {vlb, temp << getname} ) );
);
{box, ns} = gen_dummy_cb_ui();
New Window( "", box );
Eval(
Eval Expr(
box << onclose(
Delete Namespaces( Expr( ns ) );
1;
)
)
);
Show( Namespace( ns ) );Re: Display box encryption@gzmorgan0, It worked for you even after you encrypted it?
@Craige_Hales , I've done that before similar to Drew's Pseudo Object Oriented style.
The problem I run into is if I have to create a copy of a box dynamically, I have to keep a list of namespaces created in order to delete them later.
And if the button (or whatever it is) that makes the copy of the box isn't talking to the function that creates the main window, it doesn't know what list to add to.
It gets very cludgey very quickly.
This might be a little esoteric, but I run into it all the time.
The thing that REALLY confuses me is why can I call <<
Re: Display box encryptionVince,
Sorry I missed the encryption part.
I suggest you embed your script in a Script Box(), and run the script box. Then encrypt it, It seems to work for me.
jslbox= ScriptBox("\[
do_something = function ({aa}, {Default Local},
cb = aa["cb2"];
rb = aa["rb"];
show(cb<<CLASS name=""></CLASS>
Re: Display box encryptionThat would break all of our unit testing unfortunately. Also it would make it a NIGHTMARE to support since everything is a string.
I'll play with it to see if I can use interesting tidbit to my advantage.
Re: Display box encryption@vince_faller ,
I tested your script on JMP PRO 14.3 and 15.0 and it worked. I then changed the function to make it more apparent that the UI was changing.
I opened new sessions of JMP to test. ??
do_something = function ({aa}, {Default Local},
cb = aa["cb2"];
rb = aa["rb"];
show(cb<<CLASS name="">1,
for(i=1, i<=nitems(ml), i++,
ml[i] = char(num(ml[i]) +1);
),
//else
ml = {"1", "2"}
);
cb << Set Items(EvalList(ml)); // but this doesn't????
);
gen_dummy_cb_ui = Function ({}, {Default Local},
vlb = Vlistbox(
btn = buttonbox("Press me"),
cb1 = Combo Box ({"Change me", "B"}),
cb2 = Combo Box ({"This should change"}),
rb = radiobox({"1", "2"})
);
aa = Associative Array ({"cb1", "cb2", "rb"}, Eval List ({cb1, cb2, rb}));
Eval (Substitute (
Expr (
btn << Set Function (
Function ({this}, {cb},
do_something(DV_AA)
)
);
cb1 << Set Function (
Function ({this, index}, {cb},
do_something(DV_AA)
)
);
)
,
Expr (DV_AA), aa
));
return(vlb);
);
New Window ("",
gen_dummy_cb_ui();
);
</CLASS>