[jawsscripts] Re: string segment

  • From: "The dark Count" <darkcount1@xxxxxxxxx>
  • To: jawsscripts@xxxxxxxxxxxxx
  • Date: Tue, 17 Nov 2009 15:51:27 -0800

Thanks Doug.
Ms1 is the last line of incoming text in a chat client.
The first part of the line has a user name and it ends with a grader than sign.
there is a space after, then the rest of the line contains the message itself.
So a line may look like so:
Doug> http://www.jfw.com
I want to get rid of doug, and the leading space and keep only the message part 
to be used 
else where.

Ty for your help.


Your unadulterated message follows: 
 Subject: [jawsscripts] Re: string segment 
 Date: 17 Nov 2009

What is the exact value of ms1 when the script is called?

You're asking for the third segment of ms1, as delimited by ">"; but
unless I missed something, there is no ">" symbol in ms1.  That would
indeed give you nothing for the third segment.

Another possibility, depending on the value of ms1 of course, is that
there are ">" symbols right next to each other.  stringSegment("a>>b",
">", i) will return "a" for i=1, "" for i=2 , and "b" for i=3.

If you are using a string more than one character long for argument 2
of stringSegment, note that it is a set of alternative delimiters, not
a single delimiter more than one character long.
stringSegment("a<<b>c", "<>", i) will return "a" for i=1, "" for i=2,
"b" for i=3, and "c" for i=4.

Finally, consider whether your goal is really to get a segment or just
to chop off the beginning of a string.  The difference is in what
should happen if your delimiter occurs again later in the string.  If
you have the string "WT>This only works if a >= 5" and you just want to
remove the "WT>", you can't safely use stringSegment, or you'll
probably get "This only works if a " and lose the end.  In a case like
that, you have to use combinations of stringContains and the
stringChopLeft/Right and other such manipulation functions to get what
you want.

Hth.

On Tue, Nov 17, 2009 at 03:58:56AM -0800, The dark Count wrote:
Hello all.
I am working with an app here that I need for it to give me the last part of a 
string segment.
I am grabbing the line in question and calling ms1.
I am using the string segment to delimit it and give me only the segment aftert 
the delimiters.
When I say it, or spell it, that return that is, it works fine except if there 
are periods or slashes. 
I have not tested with other punctuation, but am wondering if this has to do 
with any changes 
that you may  know about.
So if the message ms1 is "hello world" I get that, But if it is 
"http://www.whatever.com"; it 
returns nothing.
Here is the code.

;global var ms1 is obtained from new text event
Script LastMessage ()
var
string ding
let ding = StringSegment (ms1, ">", 3)
let ding = StringTrimLeadingBlanks (ding)
CopyToClipboard (ding)
;Say (ms1, ot_buffer, 0)
Say (ding, ot_buffer, 0)
SpellString (ding)
EndScript

The segment delimiter is >, and there is a blank space left to chop off.

Tia.

D c

__________?
Visit and contribute to The JAWS Script Repository http://jawsscripts.com

View the list's information and change your settings at 
//www.freelists.org/list/jawsscripts

-- 
Doug Lee, Senior Accessibility Programmer
SSB BART Group - Accessibility-on-Demand
mailto:doug.lee@xxxxxxxxxxxxxxxx  http://www.ssbbartgroup.com
"While they were saying among themselves it cannot be done,
it was done." --Helen Keller
__________
Visit and contribute to The JAWS Script Repository http://jawsscripts.com

View the list's information and change your settings at 
//www.freelists.org/list/jawsscripts

__________ 
Visit and contribute to The JAWS Script Repository http://jawsscripts.com

View the list's information and change your settings at 
//www.freelists.org/list/jawsscripts

Other related posts: