String parsing with Manuscript

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

String parsing with Manuscript

John Murdoch
I'm looking for something similar to Split(), SubString(), and Trim()
for handling strings. I don't see anything in the Manuscript Technical
Reference--and wonder if I'm just missing something.

Here's what I'm trying to do:

I want to create a plug-in that will iterate over the bars of the system
staff, finding each Metronome Mark, and incrementing (or decrementing)
the tempo by 1.

Thus, if the MetronomeMark.Text is "q = 102" I want to find the int
value at the end of the string, and replace it.

I have figured out that I can use utils.Replace() to replace the numeric
value if I need to; and I could also just use a big switch statement of
likely tempo values if I really had do. But if I had SubString() it
would be so much simpler.

Any ideas?

Thanks,

John Murdoch

_______________________________________________
Plugin-dev mailing list
[hidden email]
http://avid-listsrv1.avid.com/mailman/listinfo/plugin-dev
Reply | Threaded
Open this post in threaded view
|

Re: String parsing with Manuscript

musictranscriber
John,
   I already have a plugin that does this on the market, called Scale Numbers.

 
 
Regards,
  The Music Transcriber
  Roman Molino Dunn
  http://www.themusictranscriber.com
  http://www.mirrortone.com
@musictranscribe
@mirrortonemusic


-----------------------------------------------------------
Any message sent by The Music Transcriber is confidential and may be privileged or otherwise protected. If you receive it in error please inform us and then delete it from your system. The information in this email and any attachments may contain confidential information that is intended solely for the attention and use of the named addressee(s). This message or any part thereof must not be disclosed, copied, distributed or retained by any person without authorization from the addressee. You should not copy it or disclose its contents to anyone. Messages sent to and from The Music Transcriber may be monitored to ensure compliance with internal policies and to protect our business. Emails are not guaranteed to be secure and therefor cannot be guaranteed to be error free. Anyone who communicates with us by email is assumed to have taken to accept these risks. If you are not the intended addressee, or feel you have received this message by mistake, or simply no longer wish to communicate, please notify the sender immediately, and delete this message.


From: John Murdoch <[hidden email]>
To: [hidden email]
Sent: Sunday, June 7, 2015 10:47 PM
Subject: [Plugin-dev] String parsing with Manuscript

I'm looking for something similar to Split(), SubString(), and Trim()
for handling strings. I don't see anything in the Manuscript Technical
Reference--and wonder if I'm just missing something.

Here's what I'm trying to do:

I want to create a plug-in that will iterate over the bars of the system
staff, finding each Metronome Mark, and incrementing (or decrementing)
the tempo by 1.

Thus, if the MetronomeMark.Text is "q = 102" I want to find the int
value at the end of the string, and replace it.

I have figured out that I can use utils.Replace() to replace the numeric
value if I need to; and I could also just use a big switch statement of
likely tempo values if I really had do. But if I had SubString() it
would be so much simpler.

Any ideas?

Thanks,

John Murdoch

_______________________________________________
Plugin-dev mailing list
[hidden email]
http://avid-listsrv1.avid.com/mailman/listinfo/plugin-dev



_______________________________________________
Plugin-dev mailing list
[hidden email]
http://avid-listsrv1.avid.com/mailman/listinfo/plugin-dev
Reply | Threaded
Open this post in threaded view
|

Re: String parsing with Manuscript

Bob Zawalich-3
In reply to this post by John Murdoch
There is already a published plugin Scale Numbers that does what you are suggesting, so you might have a look at it before you write one to avoid duplicating effort.

There is the manuscript function Substring, and look in utils.plg. TrimBlanks can trim spaces
And there is more there.

Good luck!

Sent from my iPad

> On Jun 7, 2015, at 7:47 PM, John Murdoch <[hidden email]> wrote:
>
> I'm looking for something similar to Split(), SubString(), and Trim()
> for handling strings. I don't see anything in the Manuscript Technical
> Reference--and wonder if I'm just missing something.
>
> Here's what I'm trying to do:
>
> I want to create a plug-in that will iterate over the bars of the system
> staff, finding each Metronome Mark, and incrementing (or decrementing)
> the tempo by 1.
>
> Thus, if the MetronomeMark.Text is "q = 102" I want to find the int
> value at the end of the string, and replace it.
>
> I have figured out that I can use utils.Replace() to replace the numeric
> value if I need to; and I could also just use a big switch statement of
> likely tempo values if I really had do. But if I had SubString() it
> would be so much simpler.
>
> Any ideas?
>
> Thanks,
>
> John Murdoch
>
> _______________________________________________
> Plugin-dev mailing list
> [hidden email]
> http://avid-listsrv1.avid.com/mailman/listinfo/plugin-dev

_______________________________________________
Plugin-dev mailing list
[hidden email]
http://avid-listsrv1.avid.com/mailman/listinfo/plugin-dev
Reply | Threaded
Open this post in threaded view
|

Re: String parsing with Manuscript

Bob Zawalich-3
In reply to this post by John Murdoch
Manuscript also has SplitString. Good for parsing..

Sent from my iPad

> On Jun 7, 2015, at 7:47 PM, John Murdoch <[hidden email]> wrote:
>
> I'm looking for something similar to Split(), SubString(), and Trim()
> for handling strings. I don't see anything in the Manuscript Technical
> Reference--and wonder if I'm just missing something.
>
> Here's what I'm trying to do:
>
> I want to create a plug-in that will iterate over the bars of the system
> staff, finding each Metronome Mark, and incrementing (or decrementing)
> the tempo by 1.
>
> Thus, if the MetronomeMark.Text is "q = 102" I want to find the int
> value at the end of the string, and replace it.
>
> I have figured out that I can use utils.Replace() to replace the numeric
> value if I need to; and I could also just use a big switch statement of
> likely tempo values if I really had do. But if I had SubString() it
> would be so much simpler.
>
> Any ideas?
>
> Thanks,
>
> John Murdoch
>
> _______________________________________________
> Plugin-dev mailing list
> [hidden email]
> http://avid-listsrv1.avid.com/mailman/listinfo/plugin-dev
_______________________________________________
Plugin-dev mailing list
[hidden email]
http://avid-listsrv1.avid.com/mailman/listinfo/plugin-dev
Reply | Threaded
Open this post in threaded view
|

Re: String parsing with Manuscript

thomas boulenger
In reply to this post by John Murdoch
Hello

For parsing string you ave méthod of all object :

CharAt(expression,position)
Returns the character from the expression at the given (zero-based) position, e.g. CharAt("Potato",3) would give “a.”

SplitString(expression,[delimiter,][trimEmpty])
Splits a string into an array of strings, using the given delimiter. The delimiter can be a single character or a string containing
several characters – for instance ".," would treat either a comma or full stop as a delimiter. The default delimiter is the space
character. If the trimEmpty parameter is True then this will ignore multiple delimiters (which would otherwise produce some
empty strings in the array). The default value of trimEmpty is False.
s=':a:b:c';
bits=SplitString(s,':', false);
// bits[0] = ''; bits[1] = 'a'; bits[2] = 'b' ...
s='a b c';
bits=SplitString(s,' ', true);
// bits[0] = 'a'; bits[1]='b' ...

Substring(expression,start,[length])
This returns a substring of the expression starting from the given start position (zero-based) up to the end of the expression,
e.g. Substring("Potato",2) would give “tato”. When used with the optional length parameter, Substring returns a substring
of the of the expression starting from the given start position (zero-based) of the given length, e.g. Substring("
Potato",2,2) would give “ta”.


Tomboul
Le 2015-06-08 04:47, John Murdoch a écrit :
I'm looking for something similar to Split(), SubString(), and Trim() 
for handling strings. I don't see anything in the Manuscript Technical 
Reference--and wonder if I'm just missing something.

Here's what I'm trying to do:

I want to create a plug-in that will iterate over the bars of the system 
staff, finding each Metronome Mark, and incrementing (or decrementing) 
the tempo by 1.

Thus, if the MetronomeMark.Text is "q = 102" I want to find the int 
value at the end of the string, and replace it.

I have figured out that I can use utils.Replace() to replace the numeric 
value if I need to; and I could also just use a big switch statement of 
likely tempo values if I really had do. But if I had SubString() it 
would be so much simpler.

Any ideas?

Thanks,

John Murdoch

_______________________________________________
Plugin-dev mailing list
[hidden email]
http://avid-listsrv1.avid.com/mailman/listinfo/plugin-dev





_______________________________________________
Plugin-dev mailing list
[hidden email]
http://avid-listsrv1.avid.com/mailman/listinfo/plugin-dev
Reply | Threaded
Open this post in threaded view
|

Re: String parsing with Manuscript

Bob Zawalich
Watch out for CharAt, though.

It produces a "character" object, which is different from a string. Any single character/digit can be interpreted to be a character object.

There is a manuscript bug where single character literals and other character objects are not properly evaluated in conditional expressions, like

if (foo = "1")

and they give the wrong results.

See the thread:

http://sibelius-manuscript-plug-in-developers.3224780.n2.nabble.com/FW-PLUGIN-DEV-String-to-Number-gotcha-td5137631.html

which suggests that the comparison bug go fixed at some point.
Reply | Threaded
Open this post in threaded view
|

Re: String parsing with Manuscript

Bob Zawalich