Old 03-16-2007, 07:48 PM   #1
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 15,821
Default JS serialization is confounding, also ref/val confusion

I notice almost none of the included JS effects ever save state beyond the slider settings. I can't figure out how to get presets to work at all for state information beyond the UI.

Here's a simple test effect that sets a single state variable. Set state, save it, hide it, then save the preset. Clear state and load the preset ... no state gets loaded. Why not?

Another very confusing thing is that if the comment is removed [in the (slider2 == 3) block] the state doesn't even get set -- x doesn't persist outside of that block. I think this means that within that block at least, x is just a reference to slider1. Is there a way to valuify x inside that block? Confusing!

Are these two weirdnesses related?

////
desc:serialization test

slider1:0<0,10,1>x
slider2:0<0,5,1{-,show state,hide state,save state,clear state}>action

@init

x = 0;

@serialize

file_var(0, x);

@slider

(slider2 == 1) ? (
slider1 = x;
slider2 = 0;
);

(slider2 == 2) ? (
slider1 = 0;
slider2 = 0;
);

(slider2 == 3) ? (
x = slider1;
// slider1 = 0;
slider2 = 0;
);

(slider2 == 4) ? (
x = 0;
slider1 = 0;
slider2 = 0;
);

Last edited by schwa; 03-16-2007 at 09:33 PM. Reason: clarified
schwa is offline   Reply With Quote
Old 03-16-2007, 08:01 PM   #2
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 15,821
Default

Another thing -- the preset file size does not appear to depend on how much stuff gets serialized. Pretty much my @serialize code is just not getting called. Most likely I will hit myself in the head when somebody shows me what I'm misunderstanding.
schwa is offline   Reply With Quote
Old 03-16-2007, 11:03 PM   #3
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,745
Default

unfortunately @serialize only currently works when saving/loading internal JS presets in the JS effect list or JS standalone (i.e. using S/L in its window)..

At some point in the REAPER 2.x series we will fix this...

-Justin
Justin is offline   Reply With Quote
Old 03-17-2007, 05:18 AM   #4
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 15,821
Default

Thanks for the info. I added this to the Reaper JS wiki page http://www.cockos.com/wiki/index.php..._Documentation to save the next guy some cranial bruising.

Last edited by schwa; 03-17-2007 at 05:30 AM. Reason: future conditional became past perfect
schwa is offline   Reply With Quote
Old 03-17-2007, 05:58 AM   #5
brainwreck
Human being with feelings
 
Join Date: Jul 2006
Posts: 20,859
Default

bummer :^P

thanks again for the effort schwa.
brainwreck is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:13 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.