[jawsscripts] Re: the BOOL variable type in Gordons example?

  • From: Jim Bauer <holdsworthfan@xxxxxx>
  • To: jawsscripts@xxxxxxxxxxxxx
  • Date: Fri, 23 Jul 2010 09:10:00 -0500

From a quick test in JAWS 10, bools can be passed as parameters to functions 
and declared globally. Attempting to use a global bool raises a
compile-time error and local declaration (i.e. inside the scope of a script or 
function with "var") is an utter no-go. As function arguments, they're
likely internally type-cast to ints, as they'll happily accept 0 or 10003 as a 
valid value.

Perhaps their implementation has improved in JAWS 11?

On Fri, 23 Jul 2010 23:50:21 +1000, Paul Magill wrote:
> Hi Gordon and all,
> 
> Well, I was most surprised, and pleased, to see the BOOL variable type in 
> your function header below.
> 
> I cant remember it being mentioned before. When did we get the BOOL type?
> 
> In the version 11 documentation, I looked through the FSDN, & the scripting 
> manual, but found no mention of it.
> 
> I tried it as a var declaration:
> 
> Function TestFunction ()
> VAR
> BOOL  OnOff
> 
> and that compiled fine, but I was unable to assign a value to it.
> 
> let OnOff = 1
>  gave the compile error, expected an integer, not a bool.
> 
> Could you provide any further information about the Bool type please...
> 
> Thank you,
> Paul from Aust
> 
> String function GetTimeName(String sTime,int iSegment,String sTimeName,bool
> bShowZero)
> Var
> int iAmount
> 
> ; Turn the string into an integer for easier processing
> let iAmount = StringtoInt(StringSegment (sTime, ":", iSegment))
> 
> ; Is there any time here and do we need to show it?
> if (iAmount == 0) && (bShowZero == false) then
> return ""
> endif
> 
> ; If we've only got 1 then we don't want to pluralise the amount
> if (iAmount == 1) then
> return "1 " + sTimeName
> endif
> 
> ; Return the value with the time interval pluralised
> return IntToString(iAmount) + " " + sTimeName + "s"
> endfunction
> 
> String function StringTime(string sTime)
> Var
> string sresult,
> string sEnd
> 
> ; Make sure we have 3 segments
> while (StringSegmentCount (sTime, ":") < 3)
> let sTime = "00:" + sTime
> endwhile
> 
> ; Get the time in hours and minutes
> let sResult = StringTrimTrailingBlanks (GetTimeName(sTime,1,"hour",false)
> + " " + GetTimeName(sTime,2,"minute",false))
> 
> ; Get the seconds time
> let sEnd = GetTimeName(sTime,3,"second",true)
> 
> ; If we've got only seconds then that's all we send back
> if (sResult == "") then
> return sEnd
> endif
> 
> ; Join the two times together with the word and
> return sResult + " and " + sEnd
> endfunction
> 
> Script Test ()
>    SayString(StringTime("01:42"))
> 
> EndScript
> 
> Gordon Luke
> 
> __________�
> 
> 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: