View Full Version : GVMS: Any way to *change* some caracters in a string???
Ron
October 13th, 2002, 12:55 PM
I'm sure it can be done with cut and substr. yeah there might be an easier way in C, but you'll have to do with what we have now. I'm working on implementing a full scripting language.
Ron
October 13th, 2002, 12:55 PM
I'm looking into several scripting languages
lua ( Nice, but has some weird things like no integers only doubles, have working implementation in Girder though) ( GVMS = 100kb, Lua = 170kb !!)
tcl ( too big for my taste )
elasticC ( little bit to early in development but very promising )
Python ( too big )
It would not be a real plugin but currently I can replace the gvms.dll with a different binary and have Lua scripting without modifying girder.
Ron
October 13th, 2002, 12:55 PM
Not meaning to go back ON TOPIC ;)
Hey who said you could do that :-)
Thanks Mark.
Mark F
October 13th, 2002, 12:55 PM
Not meaning to go back ON TOPIC ;) but I've attached a GVMS based file that replaces all occurances of - with : in the variable named filename.
Execute the multi-command to see it work.
I hope this helps. :D
Mark F
October 13th, 2002, 12:55 PM
chrisi-
I'm not sure what you mean.
Do you want to remove N characters from the end of the string? If so, use the strlen(string) command to get the overall length of the string and then use the cut(string source, integer start, integer count) command to trim off the number of characters you want removed.
The following removes 3 characters from the end of a string with no error checking -
int length;
int NumberOfCharactersToRemove;
NumberOfCharactersToRemove = 3;
string str;
str = "abcdefg";
length = strlen(str);
str = cut(str, 0, length-NumberOfCharactersToRemove);
If you are trying to do something else (replace characters with *), please elaborate.
The GVMS Help (http://www.girder.nl/help/registers.php) page has more information and the file I attached above uses some of the string manipulation functions.
chrisi
October 13th, 2002, 12:55 PM
How to clear last caracters in a string?!
Icthus
October 13th, 2002, 12:55 PM
I've done something similar for myself. This is changed to do what you want. I like what Mark did, but I thought this might be helpful also.
It's in a single script, since it assumes a fixed format (Album - Artist - Number - Track).
This example sets the string variable full_name as "Album - Artist - Number - Track". Just make this your track name.
It sets the string variable new_name to the new name (with colons instead of hyphens).
string full_name;
string new_name;
string album;
string artist;
string track;
string number;
int length;
int start_pos;
int return_pos;
int cut_length;
full_name = "Album - Artist - Number - Track";
length = strlen(full_name);
start_pos = 0;
return_pos = substr(full_name,"-",start_pos);
cut_length = return_pos - start_pos;
album = cut(full_name,start_pos,cut_length);
start_pos = return_pos + 1;
return_pos = substr(full_name,"-",start_pos);
cut_length = return_pos - start_pos;
artist = cut(full_name,start_pos,cut_length);
start_pos = return_pos + 1;
return_pos = substr(full_name,"-",start_pos);
cut_length = return_pos - start_pos;
number = cut(full_name,start_pos,cut_length);
start_pos = return_pos + 1;
cut_length = length - start_pos;
track = cut(full_name,start_pos,cut_length);
new_name = album + ":" + artist + ":" + number + ":" + track;
Marsupial
October 13th, 2002, 12:55 PM
Hello everyone!
Question: can we change specific caracters in a string using variable manipulation?
I know it is possible in C/C++ or other langueges, therefore it should have been easily implemented in a script, but this is if it was thinked as usefull... but IT IS usefull, so I wonder if I can. I haven't found a way. It's not mentionned in the GVMS helppage here on girder... there is *some* string manipulation, none I could use.
Here's the idea of what I try to do.
Get the name of a file (e.g. "artist - songname") and SAY it (using the say plug in). it will say all in one breath "artist songname". I would like the say plugin to say artist then songname. this would be possible by sending "artist : songname" as the column makes a delay. I would just plainly have to modify the variable songname that I send to the plugin so the "-" are changed to ":" and then it would be perfect.
Is it possible to change those caracters?
(all of them, for instance if I get a "film soundtrack - artist - album - songname" all are now ":")
it would as well remove the "-word" spelling error made by incoherent dashwords in the understanding english of the speech api.
Hopefully one can give me a hint. :)
thanks.
Marsupial
October 13th, 2002, 12:55 PM
Well, if I could know how many "-" I had before modifying the string, I would use cut and substr, but since I'm using it with as many as the filename have, then I cannot do anything with it. that's why a replace would have been fine.
Question: the new scripting: included in girder or into a plugin? I'm curious how it is going to end up being.
anyhow, thanks. I'll keep up having the weird pronounciation... till new scripting exist :)
was just curious if I missed a function in GVMS. :)
Marsupial
October 13th, 2002, 12:55 PM
Just plainly changing the DLL and it works... looks great!
Backward compatibility?? :)
Marsupial
October 13th, 2002, 12:55 PM
Thanks Icthus, but I prefer Mark's implementation, as a MP3 file can end up having about anything but what you expect, and I don't want to do manipulation on a string when not needed, and do more if more is needed.
Therefore, Mark's implementation is great!
Thanks Mark!
I didn't know I could have a tru false verification with the GVMS... I guess I totally was out of the GVMS philosophy...
With that, you can do about anything...
anyhow, it's great.
thanks a lot.
Powered by vBulletin® Version 4.1.8 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.