[jawsscripts] Re: Making a string title case

  • From: "Martin Slack" <m.g.slack@xxxxxxxxxxxx>
  • To: <jawsscripts@xxxxxxxxxxxxx>
  • Date: Fri, 26 Feb 2010 23:11:52 -0000

Well, you are now asking for functions StringUpper and StringLower to 
operate on pure numbers.  What is the upper case value of 2?

  The best thing to do would be to include some checking code within the 
while loop to decide if the value of sWord is a string of alphabetic 
characters or digits.  If digits, don't call either StringUpper or 
StringLower but pass the number straight through to the output.

  The checking would get very messy very fast if you decided in the future 
you wanted to include words which are made up of both letters and digits.

  I'm using Jaws 10, and when I checked the while loop with your example, I 
didn't get the number replaced with a null string, but with the sum of the 
digits, so your mileage may vary with the next idea.

  I've found a workaround which works with Jaws 10: concatenate each iWord 
with a trailing blank space.  With a number, this seems to fool the 
case-changing functions and the number is passed through unchanged.  It also 
means that you don't have to explicitly add a space when building up the 
output string.

  hth

Martin



----- Original Message ----- 
From: "Michael" <mike_sharp@xxxxxxxxxxxxx>
To: <jawsscripts@xxxxxxxxxxxxx>
Sent: Friday, February 26, 2010 5:23 PM
Subject: [jawsscripts] Re: Making a string title case


> I'm afraid I have another problem with this script in that it does not
> appear to like numbers within the string. For example, if the string is an
> address "24 THE GRANGE" it will convert the uppercase text to title case 
> but
> erase the 24, replacing it with a space.
> Any ideas why it will not work with numbers?
>
> Mike
>
> --------------------------------------------------
> From: "Martin Slack" <m.g.slack@xxxxxxxxxxxx>
> Sent: Wednesday, February 10, 2010 10:12 AM
> To: <jawsscripts@xxxxxxxxxxxxx>
> Subject: [jawsscripts] Re: Making a string title case
>
>> Hi Mike,
>>
>>  Try renaming your StringCountSegment function to StringSegmentCount.
>>
>>  hth
>>
>> Martin
>>
>>
>> ----- Original Message ----- 
>> From: "Mike" <mike_sharp@xxxxxxxxxxxxx>
>> To: <jawsscripts@xxxxxxxxxxxxx>
>> Sent: Wednesday, February 10, 2010 7:03 AM
>> Subject: [jawsscripts] Making a string title case
>>
>>
>>> Hi all,
>>>
>>> I have been using the homer scripts but one function I need to use is
>>> causing me trouble, it is the StringProperWords.
>>> This function is meant to convert a string of text so that the first
>>> letter
>>> of every word is capitalized and lower case for the rest, however, when 
>>> I
>>> use the function the returned string is always blank.
>>> I am not sure if this is something that I am doing wrong or if there is
>>> something wrong in the script so I have pasted it below, I would use it
>>> like
>>> this:
>>>
>>> Let sText = StringProperWords (sText)
>>>
>>> Here is the script:
>>>
>>> String Function StringProperWords(String sText)
>>> ;Capitalize the first letter of each word and lower case the rest
>>> Var
>>> Int iWord, Int iWordCount, Int iLength,
>>> String sWord, String sReturn
>>>
>>> Let iWordCount = StringCountSegment(sText, " ")
>>> Let iWord = 1
>>> While iWord <= iWordCount
>>> Let sWord = StringSegment(sText, " ", iWord)
>>> Let iLength = StringLength(sWord)
>>> Let sWord = StringUpper(StringLeft(sWord, 1)) +
>>> StringLower(Substring(sWord,
>>> 2, iLength - 1))
>>> If iWord == iWordCount Then
>>> Let sReturn = sReturn + sWord
>>> Else
>>> Let sReturn = sReturn + sWord + " "
>>> EndIf
>>> Let iWord = iWord + 1
>>> EndWhile
>>> Return sReturn
>>> EndFunction
>>>
>>> Can anyone see anything obvious with this? Or, is anyone able to try the
>>> script themselves and reply with results?
>>> If there are any other methods to achieve what I need I would be happy 
>>> to
>>> listen to suggestions.
>>>
>>> Many thanks,
>>> Mike
>>> --------------------------------------------------
>>> From: "Holdsworth, Lynn" <Lynn.Holdsworth@xxxxxxxxxxx>
>>> Sent: Thursday, February 04, 2010 9:23 AM
>>> To: <jawsscripts@xxxxxxxxxxxxx>
>>> Subject: [jawsscripts] Re: GetTagIndex function
>>>
>>>> Cheers David. To be honest I'm still not sure what it does. Do you 
>>>> know?
>>>> I'm guessing it returns the 1-based index of the first tag that matches
>>>> the string you send it.
>>>>
>>>> Thanks, Lynn
>>>>
>>>> -----Original Message-----
>>>> From: jawsscripts-bounce@xxxxxxxxxxxxx
>>>> [mailto:jawsscripts-bounce@xxxxxxxxxxxxx] On Behalf Of David Farough
>>>> Sent: 02 February 2010 18:21
>>>> To: jawsscripts@xxxxxxxxxxxxx
>>>> Subject: [jawsscripts] Re: GetTagIndex function
>>>>
>>>> here is an example which uses the GetTagIndex function.  I found this
>>>> example in virtual.jss.
>>>> Also you should check out MoveToTagByIndex and GetListOfTags functions.
>>>>
>>>> HTH
>>>>
>>>> void function SelectATagHelper(string sTag, string sAttrList,string
>>>> sTitle)
>>>> var
>>>> string strBuf,
>>>> string uCaseTag,
>>>> string lCaseAttrs,
>>>> int index,
>>>> int nCurrent
>>>> if InHJDialog () then
>>>> SayFormattedMessage (OT_ERROR, cmsg337_L, cmsg337_S)
>>>> return
>>>> EndIf
>>>> if !IsVirtualPCCursor() then
>>>> SayQuickKeynavigationNotAvailable()
>>>> return; feature not available in non-vpc mode endIf let
>>>> uCaseTag=StringUpper(sTag) let lCaseAttrs=stringLower(sAttrList) let
>>>> strBuf=GetListOfTags(uCaseTag,lCaseAttrs,LIST_ITEM_SEPARATOR)
>>>> if !strBuf then
>>>> SayFormattedMessage(OT_ERROR,formatString(CMSGNoTagsFound_L,ReturnTagTypeLiteral
>>>> (sTag)),formatString(CMSGNoTagsFound_S,ReturnTagTypeLiteral  (sTag)))
>>>> return; no tags found
>>>> endIf
>>>> let nCurrent=GetTagIndex(uCaseTag)
>>>> let index = DlgSelectItemInList (strBuf, sTitle, false,nCurrent) if
>>>> index
>>>> == 0 then
>>>> return; user cancelled operation
>>>> endIf
>>>> if MoveToTagByIndex(index,uCaseTag) then
>>>> sayLine()
>>>> endIf
>>>> endFunction
>>>>
>>>> David Farough
>>>> Application Accessibility Coordinator/coordonateur de l'accessibilité
>>>> Information Technology Services Directorate / Direction des services
>>>> d'information technologiques Public Service Commission / Commission de
>>>> la
>>>> fonction publique Email / Courriel:  David.Farough@xxxxxxxxxxxxx
>>>> Tel. / Tél:    (613) 992-2779
>>>>
>>>>>>> "Holdsworth, Lynn" <Lynn.Holdsworth@xxxxxxxxxxx> 06:43 am Tuesday,
>>>> February 02, 2010 >>>
>>>> Hi,
>>>>
>>>> Do any of you know how the GetTagIndex function works? If so I'd really
>>>> appreciate an example.
>>>>
>>>> Thanks in advance, Lynn
>>>>
>>>>
>>>> --
>>>> DISCLAIMER:
>>>>
>>>> NOTICE: The information contained in this email and any attachments is
>>>>
>>>> confidential and may be privileged.  If you are not the intended
>>>> recipient
>>>> you should not use, disclose, distribute or copy any of the content of
>>>> it
>>>> or of any attachment; you are requested to notify the sender 
>>>> immediately
>>>> of your receipt of the email and then to delete it and any attachments
>>>> from your system.
>>>>
>>>> RNIB endeavours to ensure that emails and any attachments generated by
>>>> its
>>>> staff are free from viruses or other contaminants.  However, it cannot
>>>> accept any responsibility for any  such which are transmitted.
>>>> We therefore recommend you scan all attachments.
>>>>
>>>> Please note that the statements and views expressed in this email and
>>>> any
>>>> attachments are those of the author and do not necessarily represent
>>>> those
>>>> of RNIB.
>>>>
>>>> RNIB Registered Charity Number: 226227
>>>>
>>>> Website: http://www.rnib.org.uk
>>>>
>>>>
>>>>
>>>> This message has been scanned for viruses by Websense Hosted Security -
>>>>
>>>> http://www.websense.com/content/HostedEmailSecurity.aspx
>>>>
>>>> __________á
>>>> 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
>>>>
>>>>
>>>>
>>>> To report this e-mail as Spam, please forward it to:
>>>> spam@xxxxxxxxxxxxxxx
>>>> __________
>>>> 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
>>>
>>
>> __________
>> 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
> 

__________ 
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: