Old 02-25-2020, 04:51 AM   #1
TonyGlover
Human being with feelings
 
TonyGlover's Avatar
 
Join Date: Mar 2016
Posts: 39
Default Global strings variables

Are there global string variables? For example _global.debug = "data string";

I want to use share between more scripts.
TonyGlover is offline   Reply With Quote
Old 02-25-2020, 03:43 PM   #2
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 9,636
Default

Not possible to 'share' variables between scripts at runtime afaik but you could use SetExtState/GetExt for this to write/access a global state/variable (key/value pair) from different scripts I think.
nofish is offline   Reply With Quote
Old 02-26-2020, 01:08 AM   #3
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 9,028
Default

(With EEL) I once used a function converting a string (of fixed length) from/to an array of values (i.e. floats).
I in fact used this to store the string in JSFX sliders (i.e. DAW parameters) but it could also be used with global memory.
-Michael
mschnell is offline   Reply With Quote
Old 02-26-2020, 02:25 AM   #4
TonyGlover
Human being with feelings
 
TonyGlover's Avatar
 
Join Date: Mar 2016
Posts: 39
Default

Quote:
Originally Posted by nofish View Post
Not possible to 'share' variables between scripts at runtime afaik but you could use SetExtState/GetExt for this to write/access a global state/variable (key/value pair) from different scripts I think.
GetExtState() function not defined
TonyGlover is offline   Reply With Quote
Old 02-26-2020, 02:28 AM   #5
TonyGlover
Human being with feelings
 
TonyGlover's Avatar
 
Join Date: Mar 2016
Posts: 39
Default

Quote:
Originally Posted by mschnell View Post
(With EEL) I once used a function converting a string (of fixed length) from/to an array of values (i.e. floats).
I in fact used this to store the string in JSFX sliders (i.e. DAW parameters) but it could also be used with global memory.
-Michael
This sounds great, please you can send me the function converting a string from/to an array of values !?
TonyGlover is offline   Reply With Quote
Old 02-26-2020, 06:29 AM   #6
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,481
Default

Just tried something like this but it didn't work...


jsfx1
Code:
_global.s = "a string";
jsfx2
Code:
gfx_drawstr(_global.s);
jsfx2 just outputs "(bad string)"
IXix is offline   Reply With Quote
Old 02-26-2020, 11:18 AM   #7
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 9,636
Default

I'm slightly confused, are you doing scripts (which language) or JSFX?
nofish is offline   Reply With Quote
Old 02-26-2020, 04:19 PM   #8
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 9,028
Default

Quote:
Originally Posted by TonyGlover View Post
This sounds great, please you can send me the function converting a string from/to an array of values !?
Here you are...
Code:
function encode_string(s) local(c_s, i) (
  i = 0;
  c_s = 0;
  while(
    c_s = c_s << 8;
    c_s = c_s + str_getchar(s, 4-i);  
    i = i+1;
    i < 5;
  );
  c_s;
);

function encode_5(r*, s) (
  r._1 = encode_string(strcpy_substr(#, s, 0, 4));
  r._2 = encode_string(strcpy_substr(#, s, 4, 4));
  r._3 = encode_string(strcpy_substr(#, s, 8, 4));
  r._4 = encode_string(strcpy_substr(#, s, 12, 4));
  r._5 = encode_string(strcpy_substr(#, s, 16, 4));
);

function decode_string(c_s) local (i, c_ss, _) (
  i = 0;
  strcpy (_, "");
  while(
    c_ss = c_s & 0xFF;
    c_s = c_s >> 8;
    c_ss >= 32 ? (
      str_setchar(_, -0.25, c_ss);
        i += 1;
    );  
    (i < 4) & (c_ss >= 32);
  );
  _;
);

function decode_5(r*) (  
  #__ =  decode_string(r._1);
  #__ += decode_string(r._2);
  #__ += decode_string(r._3);
  #__ += decode_string(r._4);
  #__ += decode_string(r._5);
); 
      


...
            encoded._1 = gmem[i  ];
            encoded._2 = gmem[i+1];
            encoded._3 = gmem[i+2];
            encoded._4 = gmem[i+3];
            encoded._5 = gmem[i+4];
            #list_name = decode_5(encoded); 
...

-Michael
mschnell is offline   Reply With Quote
Old 02-28-2020, 01:02 AM   #9
TonyGlover
Human being with feelings
 
TonyGlover's Avatar
 
Join Date: Mar 2016
Posts: 39
Default

Quote:
Originally Posted by mschnell View Post
Here you are...
Code:
function encode_string(s) local(c_s, i) (
  i = 0;
  c_s = 0;
  while(
    c_s = c_s << 8;
    c_s = c_s + str_getchar(s, 4-i);  
    i = i+1;
    i < 5;
  );
  c_s;
);

function encode_5(r*, s) (
  r._1 = encode_string(strcpy_substr(#, s, 0, 4));
  r._2 = encode_string(strcpy_substr(#, s, 4, 4));
  r._3 = encode_string(strcpy_substr(#, s, 8, 4));
  r._4 = encode_string(strcpy_substr(#, s, 12, 4));
  r._5 = encode_string(strcpy_substr(#, s, 16, 4));
);

function decode_string(c_s) local (i, c_ss, _) (
  i = 0;
  strcpy (_, "");
  while(
    c_ss = c_s & 0xFF;
    c_s = c_s >> 8;
    c_ss >= 32 ? (
      str_setchar(_, -0.25, c_ss);
        i += 1;
    );  
    (i < 4) & (c_ss >= 32);
  );
  _;
);

function decode_5(r*) (  
  #__ =  decode_string(r._1);
  #__ += decode_string(r._2);
  #__ += decode_string(r._3);
  #__ += decode_string(r._4);
  #__ += decode_string(r._5);
); 
      


...
            encoded._1 = gmem[i  ];
            encoded._2 = gmem[i+1];
            encoded._3 = gmem[i+2];
            encoded._4 = gmem[i+3];
            encoded._5 = gmem[i+4];
            #list_name = decode_5(encoded); 
...

-Michael
This is great, thanks !
TonyGlover 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 11:15 PM.


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