[jawsscripts] Re: String Segment Count

  • From: "Martin Slack" <m.g.slack@xxxxxxxxxxxx>
  • To: <jawsscripts@xxxxxxxxxxxxx>
  • Date: Tue, 6 Jul 2010 09:51:47 +0100

Mike,

  One thing I noticed was that your test string had two adjacent spaces 
between two of the names, so one of the segments you were testing would have 
been null.  The other thing to bear in mind is to give ALL your 
StringSegment functions the same set of delimiters.  When I did this, your 
code produced the output:

McDave1 McDave2 McDave3 McDave4 McDave5 McDave6

  Is this what you are looking for?  I'm still not sure how you want to 
handle double-barrelled names.

  Martin


----- Original Message ----- 
From: "Mike" <mike_sharp@xxxxxxxxxxxxx>
To: <jawsscripts@xxxxxxxxxxxxx>
Sent: Tuesday, July 06, 2010 8:39 AM
Subject: [jawsscripts] Re: String Segment Count


Geoff and all.

I tried as suggested and it did not work. Let me explain what I am trying to
achieve and paste the code thus far.
I am capturing names from a screen which need to be formatted in the correct
way. This particular function has to check for names beginning with Mc and
format it in such a way that the name appears like McTavish. My script works
where the string has a blank space between each forename or surname but in
some cases the name may be hyphenated. I need the string segment count to
look for a blank space and a hyphen. Here is my working code so far, maybe
someone can critique what I have done and suggest a way forward.
As always..thanks in advance for the help.

Var
String sData,
String sData2,
String sData3,
String sData4,
String sData5,
String sText,
Int iStart,
Int iFinish,
Int iLength

Let sData = "MCDAVE1  MCDAVE2-MCDAVE3 MCDAVE4 MCDAVE5 MCDAVE6"
Let iStart = 1 Let iFinish = StringSegmentCount (sData, " -") + 1
While iStart < iFinish
Let sText = StringSegment (sData, " ", iStart)
Let iLength = StringLength (sText)
Let sData2 = SubString (sText, 1, 2)
If sData2 == "MC" Then
Let sData2 = StringUpper (StringLeft (sData2, 1)) + StringLower (Substring
(sData2, 2, StringLength (sData2)))
Let sData3 = StringChopLeft (StringLeft (sText, iLength), 2)
Let sData3 = StringUpper (StringLeft (sData3, 1)) + StringLower (Substring
(sData3, 2, StringLength (sData3)))
Let sData4 = (sData2 + sData3)
If iStart == iFinish Then
Let sData5 = sData5 + sData4 Else
Let sData5 = sData5 + sData4 +" "
EndIf
EndIf
Let iStart = iStart + 1
EndWhile
Copytoclipboard (sData5)
--------------------------------------------------
From: "Geoff Chapman" <gch@xxxxxxxxxxxxxxxx>
Sent: Tuesday, July 06, 2010 5:12 AM
To: <jawsscripts@xxxxxxxxxxxxx>
Subject: [jawsscripts] Re: String Segment Count

> Hi Mike.
> well, I stand to be corrected, but my understanding was that you just
> shoved
> all of them next to each other inside quotation marks as the second param
> of
> the function?
> i.e.
>
> StringSegmentCount (MyString, "| ")
>
>
> the multiple delimiters in this case would be vertical bar followed by a
> space, in sequence.
> thus a vertical bar with no space following it, would not be considered
> legal for the above code?
>
> BTW, you can also use, as can be very handy in some situations, and end of
> line character of "\n" as a delimiter as well.
>
> hth..
> ----- Original Message ----- 
> From: "Mike" <mike_sharp@xxxxxxxxxxxxx>
> To: <jawsscripts@xxxxxxxxxxxxx>
> Sent: Tuesday, July 06, 2010 9:10 AM
> Subject: [jawsscripts] String Segment Count
>
>
>> Hi All,
>>
>> I am a bit unsure on how to specify more the one delimiter in the
>> stringsegmentcount function, can someone let me know how it is done?
>>
>> Regards,
>>
>> Mike
>>
>> __________�
>>
>> View the list's information and change your settings at
>> http://www.freelists.org/list/jawsscripts
>>
>
> __________�
>
> View the list's information and change your settings at
> http://www.freelists.org/list/jawsscripts
>
>
__________�

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

__________�

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

Other related posts: