Old 12-18-2013, 07:43 AM   #1
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default JSFX string support discussion thread

Discuss the new JS string support here!

-----

This will end up in the JSFX documentation eventually:


Some other string related functions available:
  • sprintf(str,"string %{varname}d blah");
  • strlen("test") == 4
  • match("*test*", "this is a test") != 0
  • matchi("*tESt*", "this is a test") != 0
    For these you can use simplified regex-style wildcards:
    • * = match 0 or more characters
    • *? = match 0 or more characters, lazy
    • + = match 1 or more characters
    • +? = match 1 or more characters, lazy
    • ? = match one character
    and format specifiers:
    • %s means 1 or more chars
    • %0s means 0 or more chars
    • %5s means exactly 5 chars
    • %5-s means 5 or more chars
    • %-10s means 1-10 chars
    • %3-5s means 3-5 chars.
    • %0-5s means 0-5 chars.
    • (also, x, d, u, f are available, and c too but it can't take length parameters)
    Example:
    Code:
    match("*%4{blah}d*","some four digit value is 8000, I say")==1 && blah == 8000
  • strcpy(str, srcstr);
  • strcat(str, srcstr);
  • strcmp(str, str2);
  • stricmp(str, str2);
  • strncmp(str, str2, maxlen);
  • strnicmp(str, str2, maxlen);
  • strncpy(str, srcstr, maxlen); // maxlen=-1 for unlimited
  • strncat(str, srcstr, maxlen); // maxlen=-1 for unlimited, refers to maximum bytes of srcstr
  • strcpy_from(str,srcstr, offset); // copies srcstr to str, but starts reading srcstr at offset offset
  • str_getchar(str, offset); //returns value at offset offset
  • str_setchar(str, offset, value); //sets value at offset offset (must be within strlen())
  • str_setlen(str, len); // sets length of string (if increasing, will be space-padded)
  • str_delsub(str, pos, len); // deletes len chars at pos
  • str_insert(str, srcstr, pos); //inserts srcstr at pos
  • pre2+:
  • strcpy_fromslider(str, [slider1 or 1-based slider index) // gets the filename if a file-slider, or the string if the slider specifies string translations, otherwise gets an empty string
  • gfx_printf("this is a %{somestring}s"); etc, identical to gfx_drawstr(sprintf(#,"this is a ..."));
  • file_open() can now take a string filename directly, i.e. file_open("whatever.txt") opens Appdata\REAPER\Data\whatever.txt
  • file_string(handle, str) can now be used.
    • If in @serialize and handle is 0, it will read or write a string blob, up to about 16kb of data, which can include NULL characters if need be (it is encoded as size and string).
    • If used with a handle return by file_open(), and not a .wav or .ogg file, it will return a line of text (including any newlines etc), i.e. it mimics fgets().

Variables that reference strings must be set to constant values between 0 and 1023, or to a literal string such as "xyz", or an unnamed mutable string (#), or a named mutable string like #xyz.
Code:
x = strcpy(#, "boo");
y=x; 
strcat(y,"hoo");  // y and x point to the same string, value of which is "boohoo"
or
Code:
x = 500;  // use user string slot 500 
strcpy(x,"boo"); // set value of user string...
y=x; 
strcat(x,"hoo");  // y and x point to the same string, value of which is "boohoo"
It's important to note the difference between #str and str. #str has its own storage for the string, and str is a number that can only point to a string.
Code:
str = "blah blah";
#str = "blah blah"; 
str2 = #str;
strcat(#str, "test"); // valid, #str becomes "blah blahtest", since #str is mutable
strcat(str,"test"); // invalid, will not modify str since str refers to the literal "blah blah"
// str2 also points to "blah blahtest" since it refers to #str
Also, most string functions return the string they modify, so you can do things like:
Code:
gfx_drawstr(sprintf(#, "the value of boo is %{boo}f, and zzz is %{#zzz}s"));

As of 4.59pre2, you can use the string functions in any section.

Last edited by Justin; 12-28-2013 at 09:48 PM. Reason: pre4
Justin is offline   Reply With Quote
Old 12-18-2013, 07:30 PM   #2
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Pulled this from the 4.59pre1 thread, and updated for pre2 -- changes: fixes to string support, threadsafety fixes (this will make strings slightly more slow, but it shouldn't really be a problem if you're not using them in @sample or @block...), added strcpy_fromslider(), file_open(string), gfx_printf(), and file_string().
Justin is offline   Reply With Quote
Old 12-19-2013, 02:15 AM   #3
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

Nothing to report yet, except: Cool!
Tale is offline   Reply With Quote
Old 12-19-2013, 07:30 AM   #4
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Aaargh! I've no time to play (bad time of year!) but this looks very exciting. Can't wait to dive in and see what's what. I can't believe you just implemented all of this out of the blue!
IXix is offline   Reply With Quote
Old 12-19-2013, 09:21 AM   #5
off&on
Human being with feelings
 
off&on's Avatar
 
Join Date: Dec 2008
Posts: 117
Default

Kudos for avoiding syntactic sugar (e.g. C-shell) here, too.
off&on is offline   Reply With Quote
Old 12-19-2013, 09:08 PM   #6
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Quote:
Originally Posted by IXix View Post
I can't believe you just implemented all of this out of the blue!
It came from making midi2osc AKA OSCII-bot...
Justin is offline   Reply With Quote
Old 12-23-2013, 05:45 AM   #7
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

So far so good, although I haven't had time to dig deep.

They say that if you don't ask, you don't get, so is there any chance we could get adjustable text size? How about different typefaces and antialiased text?
IXix is offline   Reply With Quote
Old 12-23-2013, 06:08 AM   #8
EvilDragon
Human being with feelings
 
EvilDragon's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 24,790
Default

Quote:
Originally Posted by IXix View Post
so is there any chance we could get adjustable text size? How about different typefaces and antialiased text?
This would be so awesome.
EvilDragon is offline   Reply With Quote
Old 12-23-2013, 09:41 AM   #9
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Thinking about it a little, I don't think it would be that hard to make a user function that could take a string as input and blit appropriate characters from a typeface image. Hmmm...
IXix is offline   Reply With Quote
Old 12-23-2013, 11:23 AM   #10
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
Default

^^^ true:

__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is offline   Reply With Quote
Old 12-23-2013, 11:33 AM   #11
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
Default

From the pv44.59 pre2 pre-release thread:

Quote:
Originally Posted by DarkStar View Post
To help my failing memory, can all of the new string function start with str_ ?

At the moment we have a mixture, with and without the _. And it's difficult to remember which ones have a _ and which do not.

-------------------------------
Also, I cannot get file_string() to work. I've tried various combinations of

filename:0,file1_DS.txt

@init
handle = file_open(0);
bufferX = 1024;
result = file_string(handle, bufferX[0]);
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is offline   Reply With Quote
Old 12-23-2013, 10:22 PM   #12
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Some updates in pre3: http://forum.cockos.com/showthread.p...37#post1291437

DarkStar, try:

Code:
a = "";
handle = file_open("file1_DS.txt");
file_string(handle,a);
gfx_drawstr(a); // or whatever
Justin is offline   Reply With Quote
Old 12-24-2013, 10:37 AM   #13
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
Default

Thank you. I tried with this, in @init:

Code:
handle  = file_open("file_DS.txt");
bufferX = 1024;
    result1 = file_string (handle, bufferX[0]);
    result2 = file_string (handle, bufferX[1]);
    result3 = file_string (handle, bufferX[2]);
file_rewind(handle);

// I was hoping to read the first 3 lines of text from the file
// but these three lines
    gfx_drawstr(bufferX[0]);
    gfx_drawstr(bufferX[1]);
    gfx_drawstr(bufferX[4]);
// all print the same text (the third line from the file)
So I'm doing something stupid but cannot see what ??

Also:
(a) when I edit the text (even just to add a comment) and press Ctrl+s, the three lines of text disappear. I have to click [Full recompile/reset] to get them back.
(b) all JS FX are taking longer to load
(c) the simplest case: gfx_drawstr('xxxx'); did not work, perhaps I was expecting too much.

Useful? info:
(a) the result of a file_string() operation is the length of the string, including any terminating CR / LF (so when reading from a .txt file, subtract 2 for the length of the string; perhaps those terminators should be excluded from the count?
(b) gfx_drawstr does not change gfx_x but increases gfx_y by 8 - is that intended?
__________________
DarkStar ... interesting, if true. . . . Inspired by ...

Last edited by DarkStar; 12-24-2013 at 10:44 AM.
DarkStar is offline   Reply With Quote
Old 12-25-2013, 09:47 PM   #14
ijijn
Human being with feelings
 
ijijn's Avatar
 
Join Date: Apr 2012
Location: Christchurch, New Zealand
Posts: 482
Default

Quote:
Originally Posted by IXix View Post
Thinking about it a little, I don't think it would be that hard to make a user function that could take a string as input and blit appropriate characters from a typeface image. Hmmm...
Yes .. please! Bitmap fonts FTW!
ijijn is online now   Reply With Quote
Old 12-27-2013, 08:01 PM   #15
jnif
Human being with feelings
 
jnif's Avatar
 
Join Date: Dec 2008
Posts: 2,111
Default

Here is an example how I read a note name file into Sequencer baby

Code:
notename_str = "";
handle = file_open("seqbaby_data/GM Kit.txt");

nn_name=0;
while(
  str_len = file_string(handle,notename_str);
  match("%-3{notename_note}d\t%{notename_name}s*",notename_str) ? (
    notename_note >= 0 && notename_note <= 127 ? (
      strcpy(nn_name, notename_name);
      notenames[notename_note]=nn_name;
      nn_name+=1;
    );
  );
  str_len > 0;
);
It seems to be working.

Thanks for the string support features. Very useful.

jnif

Last edited by jnif; 12-27-2013 at 08:07 PM.
jnif is offline   Reply With Quote
Old 12-28-2013, 02:04 AM   #16
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
Default

^^^^
Thank you jnif for an example. As I understand it:

Code:
For each line in the file:
    read it into notename_str
    do something magic to it, extracting data into notename_note and notename_name
    if notename_note is in range:
        copy the name into nn_name
        insert the nn_name into the indexed note_names array
        increment the nn_name
Is that right?

Some questions:
(a) that match() syntax is a mystery to me - where are the possibilities explained? Justin's notes above did not cover the options you're using
(b) why is the strcpy() needed? Why not just use notename_name?
(c) why increment the nn_name? I's text not a number, isn't it?
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is offline   Reply With Quote
Old 12-28-2013, 03:32 AM   #17
ijijn
Human being with feelings
 
ijijn's Avatar
 
Join Date: Apr 2012
Location: Christchurch, New Zealand
Posts: 482
Default

Quote:
Originally Posted by DarkStar View Post
^^^^
Thank you jnif for an example. As I understand it:

Code:
For each line in the file:
    read it into notename_str
    do something magic to it, extracting data into notename_note and notename_name
    if notename_note is in range:
        copy the name into nn_name
        insert the nn_name into the indexed note_names array
        increment the nn_name
Is that right?

Some questions:
(a) that match() syntax is a mystery to me - where are the possibilities explained? Justin's notes above did not cover the options you're using
(b) why is the strcpy() needed? Why not just use notename_name?
(c) why increment the nn_name? I's text not a number, isn't it?
Great questions DarkStar! It's still early days in the string camp, and it'll be great to spread the word about what can now be done, in language that humans from this world can actually understand.

I'm no expert by any means, but I'll do my best (and if anyone has any corrections/improvements, please feel free to contribute!)...

(a) I'm still wrapping my head around the minutiae of this whole matching wildcard business, so someone else is probably better suited to deal with the specifics, but I'll give it the old college try:
(to understand these mysterious single-character type suffixes that appear after the {variable_names}, resources like http://php.net/sprintf may be useful)

%-3{notename_note}d => 1-3 digit decimal integer for notename_note
\t => tab character
%{notename_name}s => 1+ character string for notename_name
* => 0 or more trailing characters of some sort (not really needed in this case, as the previous string should take everything, but it's there for the sake of comfort and security and is probably a good habit to get into anyway, to protect you if you change the string format of notename_name to be a fixed length, for example)

(b) String variable values can be either literals such as "hamsters rule the world" or integers between 0 and 1023, which point to the available string-specific slots in memory, each in turn holding a string literal of some kind. I think that notename_name holds a string literal, having been extracted from the file via the match logic, and strcpy stores this literal into the integer slot referred to by the integer of nn_name. This is done so that when the process is over, all of these strings will be available sequentially in those integer slots. See also:

(c) Here jnif is starting at string storage slot 0 and working through them in order, as outlined above.

Hope that makes sense. And hope I'm even vaguely accurate!

Last edited by ijijn; 12-28-2013 at 03:39 PM. Reason: second round of tweaking, thanks jnif!
ijijn is online now   Reply With Quote
Old 12-28-2013, 05:28 AM   #18
jnif
Human being with feelings
 
jnif's Avatar
 
Join Date: Dec 2008
Posts: 2,111
Default

Thanks DarkStar and ijijn for trying to explain my example.

There was a bug in my example.

The match function seems to use the string slot 0.
So, nn_name should start from 1.
And the string slot 0 should be cleared after the while loop so that empty entries in the notenames[] array (which have value 0) will reference an empty string, not the last string found by match.

Here is a fixed version of my example:
Code:
notename_str = "";
handle = file_open("seqbaby_data/GM Kit.txt");

nn_name=1; // collect note names to string slots starting from 1 (match is using the slot 0)
while(
  str_len = file_string(handle,notename_str);
  match("%-3{notename_note}d\t%{notename_name}s*",notename_str) ? (
    notename_note >= 0 && notename_note <= 127 ? (
      strcpy(nn_name, notename_name);
      notenames[notename_note]=nn_name;
      nn_name+=1;
    );
  );
  str_len > 0;
);
strcpy(0, ""); // clear string slot 0
I think it would be better, easier to use, if match function did not use any of the string slots 0 to 1023.

Quote:
Originally Posted by ijijn View Post
* => 0 or more trailing characters of some sort (not quite sure where it diverges/separates from the notename_name string: anyone?)
I think the trailing * is not necessary. I can remove it or leave it there, the result seems to be the same. %{notename_name}s will match to the end of line in both cases.

jnif

Last edited by jnif; 12-28-2013 at 05:43 AM.
jnif is offline   Reply With Quote
Old 12-28-2013, 03:36 PM   #19
ijijn
Human being with feelings
 
ijijn's Avatar
 
Join Date: Apr 2012
Location: Christchurch, New Zealand
Posts: 482
Default

Thanks for the clarifications and bug-fixing jnif.

Yeah, last night I ran headlong into the string slot 0 issue myself, and the constant overwriting had me a little puzzled for a while. As it stands, slot 0 isn't really much of a user slot, is it?

Funnily enough, I've also ended up using the *-catch-all-at-the-end technique even when it wouldn't strictly be required. It does become a kind of knee-jerk reaction after a while.

One more trick I've learned from my experiments is that *? (the lazy 0+ character wildcard) is phenomenally useful for allowing a little flexibility of format in terms of spacing, such as x*?=*?123 matching x=123 and x = 123. When I tried it using the non-lazy x*=*123 (especially for long lines of text that require reasonably complex parsing) it wouldn't pick up the patterns properly. I'm trying to understand all of this better as time goes by, but for now I suppose it's a kind of explorer's diary.

Have fun everyone.
ijijn is online now   Reply With Quote
Old 12-28-2013, 06:30 PM   #20
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Quote:
Originally Posted by jnif View Post
I think it would be better, easier to use, if match function did not use any of the string slots 0 to 1023.
It's only using 0 because that's what notename_name is set to. pre4 will have some big changes here: named-strings that will be defined with a # prefix, and the literal strings ("" or "xyz") will be immutable, so maybe don't get too invested in the string coding until this settles more...
Justin is offline   Reply With Quote
Old 12-28-2013, 09:44 PM   #21
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Changes in pre4:
  • The syntax highlighting and error detection in the editor is way better, as is the parentheses and ?: matching. The syntax highlighting will also highlight obvious errors (mismatched () etc).
  • Literal strings are no longer mutable, you can't change them, you can only read from them.
  • If you wish to use a temporary mutable string, you can use # -- the value is only guaranteed to be preserved for the current section, and could be undefined on the next call. Examples:
    Code:
    str = #;
    sprintf(str, "the value of foo is %{foo}f");
    gfx_draw(str);
    or
    Code:
    str = sprintf(#, "the value of foo is %{foo}f");
    gfx_draw(str);
    or
    Code:
    gfx_draw(sprintf(#, "the value of foo is %{foo}f"));
  • If you wish to have named, persistent, more predictable strings, which also appear in the watch window, you can use #name.
    Code:
      strcpy(#mystring, "hello world");
      gfx_draw(#mystring);
      sprintf(#otherstring, "hello: %{#mystring}s");
    You can also do things like:
    Code:
      s = #mystring;
      strcpy(s,"hello");
    Also, I should mention that if a #string is on the left side of = or +=, it will alias to strcpy() or strcat(), so for example:
    Code:
      #str = "hello";
      s = "world";
      #str += " ";
      #str += s;
      // #str is now "hello world"
  • Another thing that changed is you can no longer have expressions like:
    Code:
    1=2;
    This was rarely used, but it breaks two plug-ins (Jonas DrumReaplacer and Vmorph). You can still have more complex expressions like (1 ? 2 : 3) = 4, which is equally meaningless...
Justin is offline   Reply With Quote
Old 12-29-2013, 04:42 AM   #22
ijijn
Human being with feelings
 
ijijn's Avatar
 
Join Date: Apr 2012
Location: Christchurch, New Zealand
Posts: 482
Default

Loving those new pre4 updates Justin!

I've had a go at making a framework for bitmap fonts.

Here's the thread: JS bitmap font framework: humble beginnings
ijijn is online now   Reply With Quote
Old 12-29-2013, 07:40 AM   #23
Tronic
Human being with feelings
 
Tronic's Avatar
 
Join Date: Jan 2012
Posts: 104
Default

so is the support of the incoming midi sysex in JS?
Tronic is online now   Reply With Quote
Old 12-29-2013, 09:15 AM   #24
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
Default

@jnif, I tried your modified example, on a text file that starts:
35 Acoustic Bass Drum
36 Bass Drum 1
37 Side Stick
38 Acoustic Snare
str_len = file_string(handle,notename_str); is always returning a length of 0, so not much else does anything. The handle is a positive integer value so the file is definitely being found.

Is this the right interpretation of %-3{notename_note}d\t%{notename_name}s*
%-3{notename_note}d . . . . . . . put up to 3 characters into notename_note as an integer
\t . . . . . . . . . . . . . . . . . . . . . 'tab' to the next set of characters
%{notename_name}s* . . . . . . put the rest of the line into notename_note

.
__________________
DarkStar ... interesting, if true. . . . Inspired by ...

Last edited by DarkStar; 12-29-2013 at 10:49 AM.
DarkStar is offline   Reply With Quote
Old 12-29-2013, 10:47 AM   #25
EvilDragon
Human being with feelings
 
EvilDragon's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 24,790
Default

Quote:
Originally Posted by Tronic View Post
so is the support of the incoming midi sysex in JS?
Oh, it would be most amazing if sysex would be supported in JS.

I see many things becoming possible in that case.
EvilDragon is offline   Reply With Quote
Old 12-29-2013, 12:09 PM   #26
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

I forgot to mention these updates in pre4:
  • variable names and function names no longer collide -- you can use a name as a variable and as a function, and they work independent of eachother.
  • multiple functions can be defined with the same name and different parameter counts -- it will choose the correct version of the function based on the parameter count.
Justin is offline   Reply With Quote
Old 12-29-2013, 03:16 PM   #27
jnif
Human being with feelings
 
jnif's Avatar
 
Join Date: Dec 2008
Posts: 2,111
Default

Is there a bug in file slider behavior?
I'm trying to use this syntax:
Code:
slider1:/some_path:default_value:slider description
like this:
Code:
slider42:/seqbaby_data:GM Kit.txt:Drum Map Note names
but I can't get the default_value to work properly.

I have these files in the seqbaby_data folder:
Ate Oh Wait Kit.txt
Basic Kit.txt
GM Kit.txt
MK2 Kit.txt
Nein Oh Nein Kit.txt

Only the first file name (Ate Oh Wait Kit.txt) works as default_value. It maps to slider value 0.
Other default_value file names will map to incorrect value, offset by 1, like this:
Ate Oh Wait Kit.txt = 0
Basic Kit.txt = 0
GM Kit.txt = 1
MK2 Kit.txt = 2
Nein Oh Nein Kit.txt = 3

So, this line
Code:
slider42:/seqbaby_data:GM Kit.txt:Drum Map Note names
will set Basic Kit.txt as default.

jnif
jnif is offline   Reply With Quote
Old 12-29-2013, 03:20 PM   #28
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

Quote:
Originally Posted by Justin View Post
  • multiple functions can be defined with the same name and different parameter counts -- it will choose the correct version of the function based on the parameter count.
Function overloading, cool!
Tale is offline   Reply With Quote
Old 12-29-2013, 03:28 PM   #29
jnif
Human being with feelings
 
jnif's Avatar
 
Join Date: Dec 2008
Posts: 2,111
Default

Quote:
Originally Posted by DarkStar View Post
@jnif, I tried your modified example, on a text file that starts:
35 Acoustic Bass Drum
36 Bass Drum 1
37 Side Stick
38 Acoustic Snare
str_len = file_string(handle,notename_str); is always returning a length of 0, so not much else does anything. The handle is a positive integer value so the file is definitely being found.
Here is an updated example that works in pre4.
Code:
  memset(notenames, 0, 128); // clear old note names
  notename_str = #;
  nn_filename = #;
  handle = file_open("seqbaby_data/GM Kit.txt");

  nn_name=1; // collect note names to string slots starting from slot 1, slot 0 is always empty string
  notename_name = #;
  while(
    str_len = file_string(handle,notename_str);
    match("%-3{notename_note}d\t%{notename_name}s",notename_str) ? (
      notename_note >= 0 && notename_note <= 127 ? (
        strcpy(nn_name, notename_name);
        notenames[notename_note]=nn_name;
        nn_name+=1;
      );
    );
    str_len > 0;
  );
  file_close(handle);
Quote:
Originally Posted by DarkStar View Post
Is this the right interpretation of %-3{notename_note}d\t%{notename_name}s*
%-3{notename_note}d . . . . . . . put up to 3 characters into notename_note as an integer
\t . . . . . . . . . . . . . . . . . . . . . 'tab' to the next set of characters
%{notename_name}s* . . . . . . put the rest of the line into notename_name
Yes, that is correct. (There was one typo at the last line. I fixed that.)

jnif
jnif is offline   Reply With Quote
Old 12-29-2013, 04:20 PM   #30
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Quote:
Originally Posted by jnif View Post
Is there a bug in file slider behavior?
I'm trying to use this syntax:
Code:
slider1:/some_path:default_value:slider description
like this:
Code:
slider42:/seqbaby_data:GM Kit.txt:Drum Map Note names
but I can't get the default_value to work properly.

I have these files in the seqbaby_data folder:
Ate Oh Wait Kit.txt
Basic Kit.txt
GM Kit.txt
MK2 Kit.txt
Nein Oh Nein Kit.txt

Only the first file name (Ate Oh Wait Kit.txt) works as default_value. It maps to slider value 0.
Other default_value file names will map to incorrect value, offset by 1, like this:
Ate Oh Wait Kit.txt = 0
Basic Kit.txt = 0
GM Kit.txt = 1
MK2 Kit.txt = 2
Nein Oh Nein Kit.txt = 3

So, this line
Code:
slider42:/seqbaby_data:GM Kit.txt:Drum Map Note names
will set Basic Kit.txt as default.

jnif

Thanks, fixing! This is due to some code from November 2004, running Jesusonic on linux, when these were often controlled by rotary encoders, so there was some logic to nudge the value one way or another... totally obsolete.
Justin is offline   Reply With Quote
Old 12-29-2013, 05:06 PM   #31
ijijn
Human being with feelings
 
ijijn's Avatar
 
Join Date: Apr 2012
Location: Christchurch, New Zealand
Posts: 482
Default

Can %{var}d match negative numbers when a '-' is detected? I'm trying to do that and it seems to be picking out just the positive part every time. Any suggestions?
ijijn is online now   Reply With Quote
Old 12-29-2013, 05:36 PM   #32
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Quote:
Originally Posted by ijijn View Post
Can %{var}d match negative numbers when a '-' is detected? I'm trying to do that and it seems to be picking out just the positive part every time. Any suggestions?
Ah yeah, good idea, I will fix that!
Justin is offline   Reply With Quote
Old 12-29-2013, 05:48 PM   #33
ijijn
Human being with feelings
 
ijijn's Avatar
 
Join Date: Apr 2012
Location: Christchurch, New Zealand
Posts: 482
Default

Quote:
Originally Posted by Justin View Post
Ah yeah, good idea, I will fix that!
Awesome, thanks! Meanwhile I've been adding special match cases with explicit '-'s and that seems to be doing the job.
ijijn is online now   Reply With Quote
Old 12-29-2013, 07:09 PM   #34
ijijn
Human being with feelings
 
ijijn's Avatar
 
Join Date: Apr 2012
Location: Christchurch, New Zealand
Posts: 482
Default

Having the string option for file_open is glorious! Is there any chance of extending that to gfx_blit[ext] for the png side of things? Or is there a way of doing it now that I have yet to discover?

Also, what about the choice of overriding the default folder to allow all associated files (data and png) to be kept together in one place for easier handling? Perhaps this could be signalled with a preceding '/' (which as far as I can tell doesn't make any difference at this stage) for the local Effect folder (e.g. /allmystuff/font.fnt and /allmystuff/font.png), if that doesn't break things?
ijijn is online now   Reply With Quote
Old 12-29-2013, 08:48 PM   #35
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Yeah, something like gfx_loadimage() (as well as gfx_newimage(w,h for that matter) would be useful... and ability to specify data vs effect folder too. I'll investigate these things.
Justin is offline   Reply With Quote
Old 12-29-2013, 08:56 PM   #36
ijijn
Human being with feelings
 
ijijn's Avatar
 
Join Date: Apr 2012
Location: Christchurch, New Zealand
Posts: 482
Default

Quote:
Originally Posted by Justin View Post
Yeah, something like gfx_loadimage() (as well as gfx_newimage(w,h for that matter) would be useful... and ability to specify data vs effect folder too. I'll investigate these things.
Thanks Justin, that would be superb!

EDIT: Actually, thinking about it, with gfx_newimage (and if given the ability to export a png as a file, or even hardcoding that process ourselves) we could end up designing GUIs from within the JS effect itself. Rapid prototyping anyone?!

Last edited by ijijn; 12-30-2013 at 03:32 PM. Reason: i had a thought .. possibly an insane one, but nevertheless..
ijijn is online now   Reply With Quote
Old 12-30-2013, 02:41 PM   #37
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Quote:
Originally Posted by Justin View Post
I forgot to mention these updates in pre4:
  • variable names and function names no longer collide -- you can use a name as a variable and as a function, and they work independent of eachother.
  • multiple functions can be defined with the same name and different parameter counts -- it will choose the correct version of the function based on the parameter count.
How could you just forget to mention that?! I need a few months for my brain to get to grips with the implications of all these new developments!
IXix is offline   Reply With Quote
Old 12-30-2013, 03:16 PM   #38
ijijn
Human being with feelings
 
ijijn's Avatar
 
Join Date: Apr 2012
Location: Christchurch, New Zealand
Posts: 482
Default

Quote:
Originally Posted by IXix View Post
How could you just forget to mention that?! I need a few months for my brain to get to grips with the implications of all these new developments!
He's a sly one, that Justin. I wonder what else slips past our casual notice...
ijijn is online now   Reply With Quote
Old 01-05-2014, 02:15 PM   #39
Tronic
Human being with feelings
 
Tronic's Avatar
 
Join Date: Jan 2012
Posts: 104
Default

Please make this thing possible....

midisyxrecv

this is very useful to create dashboards for every HW very quickly
Tronic is online now   Reply With Quote
Old 01-07-2014, 02:47 AM   #40
ijijn
Human being with feelings
 
ijijn's Avatar
 
Join Date: Apr 2012
Location: Christchurch, New Zealand
Posts: 482
Default

Hi team.

I've been performing another round of experiments with all of this, and I have some questions:
  1. What kind of character set support is available for JSFX strings? And will this change any time soon? Out of interest, I tried using a fairly full ASCII set, and what I've noticed is that characters past '~' start acting a bit strangely. On output, the affected characters will either not be displayed at all (a blank space when using gfx_drawstr) or there will be an 'Â' prefixed to the character, such as '«' for '«', when using custom code along the lines of a bitmap font character lookup table reference, while even later characters in the order resolve to a single 'Ã'. It is eerily similar to the issues stated here and here.
  2. I can't seem to get a successful match using a string that ends with "...xyz%0{var}s" when xyz is at the end of the input string and thus var is the 0-length case. Matches at the start of a string (i.e. "%0{var}sxyz..." resolving var to a 0-length string) aren't a problem. Am I doing something wrong, is this a bug, or are there some limitations I need to consider?
As always, any thoughts are most welcome. Thanks!

Last edited by ijijn; 01-08-2014 at 02:38 PM. Reason: words .. should .. make .. sense
ijijn is online now   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 02:59 AM.


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