Old 01-16-2014, 04:21 PM   #81
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,653
Default

Nothing, I guess (but what do I know). Anyway...

Code:
textline_str = "lines\t20";
ok = match("%s\t%d", textline_str, TS_name, TS_count);
sprintf(#debug, "\"%s\"|%d", TS_name, TS_count);
If I run this ok == 1, and #debug holds "lines"|20, so it seems to work at my end.
Tale is offline   Reply With Quote
Old 01-16-2014, 06:15 PM   #82
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,746
Default

darkstar, add a * after your %d
Justin is offline   Reply With Quote
Old 01-17-2014, 03:04 AM   #83
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,681
Default

Thank you, that worked.

Is it correct that that last * means "match 0 or more characters after the decimal number' and as I did not specify any destination, they are ignored? And was the cause the CR LF at the end of the line of text?
.
__________________
DarkStar ... interesting, if true. . . . Inspired by ...

Last edited by DarkStar; 01-17-2014 at 09:28 AM.
DarkStar is offline   Reply With Quote
Old 01-18-2014, 10:13 AM   #84
bang
Human being with feelings
 
bang's Avatar
 
Join Date: Jul 2006
Posts: 626
Default

couple o' ?'s:

love the idea of selectable fonts. but it seems a can of cross-platform worms. how can we reliably select fonts that will work on both macs & pcs? could there be a few fonts bundled w/ Reaper somehow?

in the v4.59rc1 release notes i see:

# JS: added new blend modes for gfx_mode, set (1..5)*16, which map to LICE_BLIT_MODE_ADD..HSVADJ

does this enable drawing text using the current gfx_r/g/b/a? if so, how? if not, is there any other way to do this?

tia! /dan
bang is offline   Reply With Quote
Old 01-18-2014, 06:10 PM   #85
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,746
Default

Quote:
Originally Posted by bang View Post
couple o' ?'s:

love the idea of selectable fonts. but it seems a can of cross-platform worms. how can we reliably select fonts that will work on both macs & pcs? could there be a few fonts bundled w/ Reaper somehow?

in the v4.59rc1 release notes i see:

# JS: added new blend modes for gfx_mode, set (1..5)*16, which map to LICE_BLIT_MODE_ADD..HSVADJ

does this enable drawing text using the current gfx_r/g/b/a? if so, how? if not, is there any other way to do this?

tia! /dan
Most common font names should be resolved reasonably well on both OSes. gfx_mode aside, gfx_r/g/b/a should all affect text, do they not?
Justin is offline   Reply With Quote
Old 01-18-2014, 06:23 PM   #86
bang
Human being with feelings
 
bang's Avatar
 
Join Date: Jul 2006
Posts: 626
Default

Quote:
Originally Posted by Justin View Post
Most common font names should be resolved reasonably well on both OSes. gfx_mode aside, gfx_r/g/b/a should all affect text, do they not?
ok. might be nice to have a semi-standard list of common font names then. i can look in to that. and yes, now that i actually think about it, i expect text does respect gfx_?. please excuse the brain fart. enjoy! /dan
bang is offline   Reply With Quote
Old 01-18-2014, 06:41 PM   #87
bang
Human being with feelings
 
bang's Avatar
 
Join Date: Jul 2006
Posts: 626
Default

Quote:
Originally Posted by bang View Post
[...]i expect text does respect gfx_?.[...]
i think i was confused by my previous efforts to blit anti-aliased text in color, which is now obsolete. but i do wonder if there is any easy way to blit using alpha from a source image and color from gfx_r/g/b/a? this could be useful for sprites and gui elements and such. mostly just curious at this point though. the new Js font/shape/image stuff is way more than enough do take Js gui's to another level entirely. and, the aa text hack i came up with does do what i want, if a bit awkwardly. fwiw, /dan
bang is offline   Reply With Quote
Old 01-19-2014, 10:39 PM   #88
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,467
Default

Is there a way to draw a string right justified starting from gfx_x?

I looked at gfx_measurestr(str,x,y)

How is this used? how do I get just the x,y values from it?

Last edited by James HE; 01-19-2014 at 10:50 PM.
James HE is offline   Reply With Quote
Old 01-19-2014, 10:57 PM   #89
mwe
Human being with feelings
 
mwe's Avatar
 
Join Date: Mar 2012
Location: Kentucky, USA
Posts: 254
Default

I think x and y are kinda misleading for gfx_measurestr. I think w and h would be more descriptive. If you subtract the x value from the gfx_x of the right hand limit then it should give you the gfx_x of the starting position.

Last edited by mwe; 01-19-2014 at 11:02 PM.
mwe is offline   Reply With Quote
Old 01-19-2014, 11:04 PM   #90
Tronic
Human being with feelings
 
Tronic's Avatar
 
Join Date: Jan 2012
Posts: 104
Default

Quote:
Originally Posted by James HE View Post
Is there a way to draw a string right justified starting from gfx_x?

I looked at gfx_measurestr(str,x,y)

How is this used? how do I get just the x,y values from it?
it is used to measure how much space your string with a given font and a size.
Tronic is offline   Reply With Quote
Old 01-19-2014, 11:14 PM   #91
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,467
Default

Quote:
Originally Posted by mwe View Post
I think x and y are kinda misleading for gfx_measurestr. I think w and h would be more descriptive. If you subtract the x value from the gfx_x of the right hand limit then it should give you the gfx_x of the starting position.
I don't understand the syntax here. how do I actually use it?


*Ahh! OK I think I got it.

Just put it in the code, and the x and y show up as variables in the variables list.


duh... was trying to set a variable to it. derf.

Last edited by James HE; 01-19-2014 at 11:22 PM.
James HE is offline   Reply With Quote
Old 01-19-2014, 11:29 PM   #92
mwe
Human being with feelings
 
mwe's Avatar
 
Join Date: Mar 2012
Location: Kentucky, USA
Posts: 254
Default

Yeah, it's not the most obvious thing to use the first time around.
mwe is offline   Reply With Quote
Old 01-19-2014, 11:44 PM   #93
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,467
Default

found a small tip with this, actually

If you only need one of the values, just put a zero for the one you don't need. i.e

gfx_measurestr(mystring,mystring_w,0);

only mystring_w will appear in the variables list. keep it neat over there.
James HE is offline   Reply With Quote
Old 01-21-2014, 06:19 AM   #94
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,891
Default

Is there a way to discard whitespace when matching? I can't seem find anything that copes with variable amounts of spaces or tabs separating the fields I'm trying to extract. Should I just use "%s=%s" and then worry about trimming the resulting tokens?

btw. trim(), ltrim() and rtrim() would be handy additions to the string function repertoire.
IXix is offline   Reply With Quote
Old 01-21-2014, 06:16 PM   #95
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,746
Default

Quote:
Originally Posted by IXix View Post
Is there a way to discard whitespace when matching? I can't seem find anything that copes with variable amounts of spaces or tabs separating the fields I'm trying to extract. Should I just use "%s=%s" and then worry about trimming the resulting tokens?

btw. trim(), ltrim() and rtrim() would be handy additions to the string function repertoire.
Yeah, trim/rtrim/ltrim might be nice to have builtin, though they're pretty easy to implement in code...

I suppose full regex (\b* etc) would be nice too.
Justin is offline   Reply With Quote
Old 01-22-2014, 06:16 AM   #96
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,891
Default

Quote:
Originally Posted by Justin View Post
Yeah, trim/rtrim/ltrim might be nice to have builtin, though they're pretty easy to implement in code...
Yes, I just meant that having them built-in would be handy.

Quote:
Originally Posted by Justin View Post
I suppose full regex (\b* etc) would be nice too.
I didn't dare to ask.
IXix is offline   Reply With Quote
Old 01-30-2014, 12:19 PM   #97
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,467
Default

Hopefully I'm missing something obvious...

If I have a string that is Hexadecimal , can I then set a variable to it?
James HE is offline   Reply With Quote
Old 01-30-2014, 12:27 PM   #98
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,653
Default

Quote:
Originally Posted by James HE View Post
If I have a string that is Hexadecimal , can I then set a variable to it?
Like this you mean?

Code:
#str = "0xFF";
matchi("0x%x", #str, x); // Sets x to 0xFF == 255
Tale is offline   Reply With Quote
Old 01-30-2014, 01:53 PM   #99
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,467
Default

Quote:
Originally Posted by Tale View Post
Like this you mean?

Code:
#str = "0xFF";
matchi("0x%x", #str, x); // Sets x to 0xFF == 255
thanks! I totally missed in the doc. that %x, %d, %u, and %f can be used with match.
James HE is offline   Reply With Quote
Old 01-30-2014, 03:41 PM   #100
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,467
Default

hmm... is there an easy way to pad a hex number with leading zero's such that the hex will always have 3 (or x) characters?

10 would be 00A for example, not A.

I'm doing this with a function right now, but if there is a better way to do this within the string output/input itself, it would save me from having to come up with more variable names.
James HE is offline   Reply With Quote
Old 01-30-2014, 04:00 PM   #101
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,653
Default

Code:
sprintf(#str, "%03X", 10); // Sets #str to "00A"
Tale is offline   Reply With Quote
Old 01-30-2014, 04:51 PM   #102
SaulT
Human being with feelings
 
Join Date: Oct 2013
Location: Seattle, WA
Posts: 876
Default

Quote:
ok. might be nice to have a semi-standard list of common font names then.
FWIW I've used this list when it's come to building web pages and whatnot. Of course, I only have Windows, so I can't test on a Mac, but... I guess it would require testing to see. I'd be curious to see if font-families are supported, as it would be easier to implement cross-platform if so, e.g. "monospace" or "sans-serif", etc.

http://www.ampsoft.net/webdesign-l/WindowsMacFonts.html
SaulT is offline   Reply With Quote
Old 01-30-2014, 11:33 PM   #103
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,467
Default

Ok made a breakthrough.
I had been trying to define strings from local() values of a function.


sprintf(#this.x, "%{x}03X"); - this does not work. {} can only be variables global to the effect.

figured out sprintf(#, "%03X", x); does work.

and...
Code:
sprintf(#this.xh, "%03X, %03X, %03X",x,y,r);

//#this.xh  = 124,0B1,021
so wow, I can easily put all of these local variables into a string.
I may abandon the HEX format and just make the string "x=123, y=12, r=4"
or what ever. or perhaps just 123,12,4. it's about 20 variables all together, so maybe packed up HEX is better...

but from there, I'm not sure what to do with the string.

I think I want to be able to copy and paste the string - into a declaration of a function in the JS code. (yes this sounds crazy I guess.. ha ha)

can I write the string to a text file now? the documentation is unclear.
James HE is offline   Reply With Quote
Old 01-31-2014, 02:00 AM   #104
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,653
Default

Quote:
Originally Posted by James HE View Post
can I write the string to a text file now? the documentation is unclear.
I don't think so i.e. I couldn't get it to do so... Anyway, I think you can only write in @serialize, so you can write blobs not files.
Tale is offline   Reply With Quote
Old 01-31-2014, 07:40 PM   #105
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,467
Default

JS drops 0's from hex values.

x=0x100A0B40210E007011; //the value of x is 4294967295.

xx=0x1AB421E711; //also equals 4294967295.

on online hex to decimal calculator gives me 295871647855188900000.

So the '0's are getting dropped, serializing this value as hex actually isn't going to work in this particular case.

I had thought that using integers would not work if they were over the 32bit integer max, but...

Quote:
file_string(handle,str) -- REAPER 4.59+
Reads or writes a string from/to the file handle. If operating on a normal file, the string will be a line of text (possibly including newline or other characters). If in @serialize, the string will be encoded as a blob with length, which means that it is binary-safe (you can include NUL characters within the string etc).
SO, it looks like storing integers would work anyhow. yay. And, besides, the variables for functions only seem to work as integer anyways. I love chasing my tail.


ok, so next question, regarding strings...

my string is an integer. 161018002270007011. -this needs to be broken up into values.

16 10 180 02 270 0 07 01 1

I can do this mathematically, but I'm guessing it would be faster to pull it out in segments from the string with match() or matchi(). (or another method). ( would be interesting to bench mark the difference - not that I'm going to )

Feeling pretty clueless here, as I just can't get my head around what modifiers i would need to do this effectively.

Last edited by James HE; 01-31-2014 at 07:55 PM.
James HE is offline   Reply With Quote
Old 02-01-2014, 03:02 AM   #106
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,653
Default

Quote:
Originally Posted by James HE View Post
I had thought that using integers would not work if they were over the 32bit integer max, but...
I think (hex) integers don't work beyond 32-bit. And no zeros are being dropped, but your numbers are getting clipped at 4294967295 == 0xFFFFFFFF (the highest unsigned 32-bit integer).

Quote:
Originally Posted by James HE View Post
And, besides, the variables for functions only seem to work as integer anyways.


Quote:
Originally Posted by James HE View Post
my string is an integer. 161018002270007011.
Just to make sure you understand: Your string is not an integer, it is a string.

Quote:
Originally Posted by James HE View Post
I can do this mathematically, but I'm guessing it would be faster to pull it out in segments from the string with match() or matchi().
Mathematical operations are almost always faster than parsing strings. However, because your numbers are too large to fit into 32-bit, it might be safer to parse them as strings. You could so something like:

Code:
#str = "161018002270007011";
match("%2d%2d%2d%2d%2d%2d%2d%2d%2d", #str, x1, x2, x3, x4, x5, x6, x7, x8, x9);
However, this only works when there are exactly 9 x 2 decimal characters. I guess looping through the string would be a more elegant solution.
Tale is offline   Reply With Quote
Old 02-01-2014, 06:43 AM   #107
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,467
Default

Quote:
Originally Posted by Tale View Post
I think (hex) integers don't work beyond 32-bit. And no zeros are being dropped, but your numbers are getting clipped at 4294967295 == 0xFFFFFFFF (the highest unsigned 32-bit integer).

OOPs! 0_o.

Thanks for all the help.

the match syntax is exactly what i was looking for...
i tried something similar, but didn't have it quite right.

What I meant by the values for functions needing to be integer (I guess I meant decimal or floating point) is that I haven't been able to successfully have the input be the string.

I think you can reference the string slot number - and have the function call that string slot? will try that.

If not, I can limit the length of the string to avoid rounding errors. - might be the most sane way to go about it.
James HE is offline   Reply With Quote
Old 02-01-2014, 03:04 PM   #108
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,467
Default

an easier way to get the unpacked values seems to be...

Code:
#big="12345678901234567890";

strcpy_substr(#temp,#big, 4, 2);

//#temp is 56
I think I can use fewer variables this way. wish me luck. ha!
James HE is offline   Reply With Quote
Old 02-11-2014, 11:08 AM   #109
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,681
Default

Once more.

What do I need to match() the three items in a .reascale file?
Code:
2	7 Note Scales
0 "Dorian"                      102304050670
0      	"Phrygian"	120304056070
0	"Lydian"         102030450607
The 2 or 3 elements on a line may be separated by 1 or more spaces or a tab. The third element is not a number (it is a series of offsets and can include A or B too).

Also, what is the best way to remove those " ?
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is offline   Reply With Quote
Old 02-21-2014, 04:45 PM   #110
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,681
Default

^^^^
Nobody?

-----------------------------------
Let me try another one, again using the Reaper .reascale files (from ZappaDave):

The files include lines such as:
Code:
0	"Major Triad 1"			100300006000
0	"Alternating TetraMirror 1"	120340000000
0	"Major TetraChord 1"		100030050060
Note that one, two or three <tab> characters separate the scale name and the scale pattern number.

What sort of match pattern would I need to match all these lines? I could not find a way to specify 1,2 or 3 <tab> characters.

I need this for my ScaleMonitor JS FX, as it now takes ages to load (initialising ~30,000 character).
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is offline   Reply With Quote
Old 02-22-2014, 02:48 AM   #111
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,891
Default

Quote:
Originally Posted by DarkStar View Post
What sort of match pattern would I need to match all these lines? I could not find a way to specify 1,2 or 3 <tab> characters
Me neither, although that doesn't mean it's not possible. It's easy with regex but with the simple match syntax I can't figure out how to handle variable whitespace.
IXix is offline   Reply With Quote
Old 02-22-2014, 06:29 PM   #112
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,653
Default

Quote:
Originally Posted by DarkStar View Post
What sort of match pattern would I need to match all these lines? I could not find a way to specify 1,2 or 3 <tab> characters.
Well, I don't know a one-liner that would match/parse those lines, but maybe you could do something like:

Code:
ok = match("%d+", #line, n);
ok &= match("*\"%s\"*", #line, #descr);
ok &= match("*?%12s", #line, #scale);
ok ? (
  // Do something with n, #descr, and #scale.
);
Tale is offline   Reply With Quote
Old 02-23-2014, 02:17 AM   #113
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Here are two functions to remove or replace chars in a string (eel script, but should work in JS if ShowConsoleMsg(...) are removed):

Code:
// remove char(s) from string -> return modified str
function remove_char(string, char) local(c, pos)
(
  pos = 0;
  #temp_string = "";
  while (pos < strlen(string)) (
    (c = str_getchar(string,pos)) != char ? (
      #temp_string += sprintf(#, "%c", c);
    );
    pos += 1;
  );
  #temp_string;
);

// replace char(s) in string -> return modified str
// replaces "char" with "repl_char"
function replace_char(string, char, repl_char) local(c, pos)
(
  pos = 0;
  #temp_string = "";
  while (pos < strlen(string)) (
    (c = str_getchar(string,pos)) != char ? (
      #temp_string += sprintf(#, "%c", c);
    ) : (
    str_setchar(#temp_string, pos, repl_char);
    );
    pos += 1;
  );
  #temp_string;
);

#str1 = "0  ";
#str2 = "\"Major Triad 1\"";
#str3 = "     100300006000";

ShowConsoleMsg("Original: ");
ShowConsoleMsg("\n");
ShowConsoleMsg(#str1); // original string
ShowConsoleMsg("\n");
ShowConsoleMsg(#str2); // original string
ShowConsoleMsg("\n");
ShowConsoleMsg(#str3); // original string
ShowConsoleMsg("\n");
ShowConsoleMsg("\n");

#str1 = remove_char(#str1, '\t'); // remove tabs from #str1
#str2 = remove_char(#str2, '"'); // remove quotes from #str2
#str3 = remove_char(#str3, '\t'); // remove tabs from #str3

//#str2 = replace_char(#str2, ' ', '\t'); // replace "white spaces" with "\t"

ShowConsoleMsg("Modified: ");
ShowConsoleMsg("\n");
ShowConsoleMsg(#str1); // modified string (chars "removed")
ShowConsoleMsg("\n");
ShowConsoleMsg(#str2); // modified string (chars "removed")
ShowConsoleMsg("\n");
ShowConsoleMsg(#str3); // modified string (chars "removed")
ShowConsoleMsg("\n");

Last edited by spk77; 02-24-2014 at 03:07 AM. Reason: "<=" to "<"
spk77 is offline   Reply With Quote
Old 02-23-2014, 02:19 AM   #114
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,681
Default

@ Tale,
Thank you, I did think of doing some multiple combo like that. But, in the end I edited the .reascale file to make it a regular format (and, yes, it still loads in the MIDI Editor).

Perhaps someone could remind me - which, if any, .reascale files are installed with Reaper?
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is offline   Reply With Quote
Old 02-23-2014, 06:00 AM   #115
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Remove adjacent duplicate characters -> return modified str:

Code:
// Remove adjacent duplicate characters -> return modified str
function remove_adj_chars(string, char) local(c, pos, last_char)
(
  pos = 0;
  #temp_string = "";
  while (pos < strlen(string)) (
    c = str_getchar(string, pos);
    (c != char || last_char != char) ? (
      #temp_string += sprintf(#, "%c", c);
    );
    last_char = c;
    pos += 1;
  );
  #temp_string;
);

// example:
#str1 = "0\t\t\t\"Major Triad 1\"\t\t100300006000\n"; // fields are separated by tabs
ShowConsoleMsg(#str1); // original string
#str1 = remove_adj_chars(#str1, '\t'); // remove adjacent duplicate "tabs"
ShowConsoleMsg(#str1); // modified string (duplicate "tabs" removed)
line 1 == original string, line 2 == function output:

Last edited by spk77; 02-24-2014 at 02:01 AM. Reason: pos <= strlen(string) to pos < strlen(string)
spk77 is offline   Reply With Quote
Old 02-23-2014, 07:20 AM   #116
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,891
Default

^^^ Ha, that's cheating!
IXix is offline   Reply With Quote
Old 02-23-2014, 07:53 AM   #117
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by IXix View Post
^^^ Ha, that's cheating!
... and it wasn't working correctly (should work now).

edit: modified it again - not sure anymore if it's working or not. . Don't know how to deal with the "last_char" variable in the script. Should I set some value into it, before the while loop?

Last edited by spk77; 02-23-2014 at 10:23 AM.
spk77 is offline   Reply With Quote
Old 03-12-2014, 02:06 PM   #118
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,467
Default

Just an little thing I discovered that seems to work in regards to formatting temporary strings.

instead of...
Code:
x=#; sprintf(x, format, variable);
gfx_drawstr(x);
this works too.
Code:
sprintf(x=#, format, variable);
gfx_drawstr(x);
seems so minor, but...

I often need a temporary string as an input for a function, (I use this to avoid instance variables in some cases even if I don't print the string) and this helps me keep that all straight in my head if I need to reorder things.
James HE is offline   Reply With Quote
Old 04-06-2014, 12:59 AM   #119
Kite
Human being with feelings
 
Join Date: Apr 2010
Location: Portland OR
Posts: 217
Default

Is it possible using these new string functions to have your JS effect write some numbers to a text file? Other than the preset file written by the @serialize section, of course.
If so, how?
__________________
alt-tuner: a microtonal midi plug-in: www.TallKite.com/alt-tuner.html
The Kite Guitar, a playable 41-ET guitar: www.KiteGuitar.com
Kite is offline   Reply With Quote
Old 04-18-2014, 10:06 AM   #120
Banned
Human being with feelings
 
Banned's Avatar
 
Join Date: Mar 2008
Location: Unwired (probably in the proximity of Amsterdam)
Posts: 4,868
Default

Quote:
Originally Posted by ijijn View Post
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.
Thanks for this hint ijijn! It was quite helpful when I got stuck with match() in OSCII-bot v0.2 not picking up patterns properly too.
Quote:
Originally Posted by Justin View Post
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!
Can this also be fixed for OSCII-bot please? Give some of the string love back where it came from?
Quote:
Originally Posted by Justin View Post
It came from making midi2osc AKA OSCII-bot...
__________________
˙lɐd 'ʎɐʍ ƃuoɹʍ ǝɥʇ ǝɔıʌǝp ʇɐɥʇ ƃuıploɥ ǝɹ,noʎ
Banned 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 02:18 PM.


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