[jawsscripts] Re: determining the first, (leftMost,) character of a string?

  • From: Chad Foster <chad.foster@xxxxxxxxxx>
  • To: jawsscripts@xxxxxxxxxxxxx
  • Date: Mon, 9 Mar 2009 08:44:58 -0400

Not to confuse the situation here, but you could also use
StringContains. This function determines if one string is contained in
another string and if so, returns the position of the string. Without
debugging or compiling the code would look like:

Var String s1, String sChar, Int iPosition

let s1 = GetWord ()
let sChar = ":"
let iPosition = StringContains ( s1 , sChar )
if iPosition == 1 then
;It is found so execute code
endIf


-Chad


On 3/9/09, Paul Magill <magills@xxxxxxxxxxx> wrote:
> Hi Geoff,
>
> You have used the function correctly, but the period needs enclosing in
> quotes as below...
>
> ElIf StringLeft (sValue, 1) == "." then
>
> Regards,
> Paul from Aust
>
> ----- Original Message -----
> From: "Geoff personal" <gch@xxxxxxxxxxxxxxxx>
>
>
> Guys, I'm wondering which optimal function I might use to determine the
> leftMost character of a string?
>
> What I want to do, is take a numeric string, which may or may not start with
> a decimal point, which always represents a price of a product. then, if it
> does begin with a decimal point, I want to add a 0 plus the dollar character
> to it, so that jaws speaks it as xx cents, properly, which it does if the 0
> is inserted between the dollar character, and the decimal point. although it
> doesn't seem to in this outlook express program!
> but normally, if the string ends up as
>
> $.05
>
> Jaws will speak this as, "dollar. zero five."
> whereas if I make the string,
>
> $0.05
>
> then jaws seems to speak this properly as, 5 cents.
>
> so, which functions might I optimally do this with?
>
> I have looked through the string functions that I can see, and none seem to
> do this in an elegant way that I can see?
> I was hoping for something like StringFirstChar,
>
> or something like that, but I can't find anything that looks remotely like
> it could do what I want? which is simply just to check the first leftMost
> character of a string.
>
> the closest I've been able to half see which I thought with some
> monipulation, might, be able to be made to do this,
> was a function called
> stringLeft
>
> and I thought I could use it as below, because it says it returns the string
> with the number of characters listed as the second parameter in the above
> function, but, compiler complains of syntax error in Elif Condition.
> S I'm obviously using it incorrectly somehow? any clues on proper usage of
> this function greatly appreciated.
> The faulty code I've got appears below:
>
>
> if sValue == "" then
>
>
>
> ; it's blank so don't add dollar to it as it wil speak unnecessarily,
> substitute speaking the product from table instead,
>
> ; because that's what type of credit it will be.
>
>
>
> SayString (sProduct)
>
>
>
> ; now check if first char is decimal point, and if so, after it being
> extracted by below function, add it back in,
>
> ; but also add 0 to it so jaws speaks it properly.
>
> ElIf StringLeft (sValue, 1) == . then
>
> ; above line is the one compiler baulks at.
>
> sayString ("Decimal point found!"
>
>
>
> ; starts with decimal point so now add the point back in but add 0 to the
> front as well before dollar sign so it speaks properly.
>
>
>
> SayString ("$0." + sValue)
>
>
>
> else ; doesn't start with decimal so no need to fiddle with it before adding
> the dollar sign
>
>
>
> SayString ("$" + sValue)
>
>
>
> EndIf ; sValue firstChar decimal point, or string blank check.
>
>
>
> Thanks.
>
>
>
> Geoff c.
>
> __________
> Visit and contribute to The JAWS Script Repository http://jawsscripts.com
>
> View the list's information and change your settings at
> http://www.freelists.org/list/jawsscripts
>
>


-- 
Chad Foster
Access Technology Solutions
Leveling The Playing Field Through Technology
http://www.GO-ATS.net
__________ 
Visit and contribute to The JAWS Script Repository http://jawsscripts.com

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

Other related posts: