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

  • From: "Geoff Chapman" <gch@xxxxxxxxxxxxxxxx>
  • To: <jawsscripts@xxxxxxxxxxxxx>
  • Date: Tue, 10 Mar 2009 04:01:30 +1100

ah! fantastic! right. thanks very much paul for this. I had tried it in
Quotes, but, the tricky part for this obvious still newby in this, was, it
gave me another error when I did this, but I hadn't really twigged in my
head that, ... well that it was a different error, so needed a different
solution! like a left-off right parenthisies, was discovered, that had
caused my code, when that period had been enclosed in quotes, to say
something like "unexpected word let," or something crazy like that. so I
stupidly took it back out of quotes again.


Anywayz, your great and timely input yesterday arvo set me back on the right
track again with debugging and looking for that other error mor properly,
and I've got it working now by end of yesterday evening as desired!
so thanks so much for that man! my total scripting helper once again!
I did have a queery about whether in an if statement, this thing actually
really extracts/chops off, the number of characters mentioned in the
parameter of StringLeft, as it appears to me, at least in the context of an
if statement, that it doesn't, whereas I thought it said in it's description
that it did!
but, suffice it to say that it seems to just examine it rather than lopping
the character off, when the parameter is 1, so there was no need to add the
decimal place bak in, when it did find one as first char on left, as I'd
initially thought I'd have to.

Thanks again.

Geoff c.----- Original Message ----- 
From: "Paul Magill" <magills@xxxxxxxxxxx>
To: <jawsscripts@xxxxxxxxxxxxx>
Sent: Monday, March 09, 2009 5:37 PM
Subject: [jawsscripts] Re: determining the first, (leftMost,) character of a
string?


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

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