[jawsscripts] Re: Represent null in a comparison

  • From: Andrew Hart <ahart@xxxxxxxxxxxxx>
  • To: jawsscripts@xxxxxxxxxxxxx
  • Date: Thu, 08 Nov 2012 12:58:05 -0300

Var can only be used inside functions.  Outside of functions you use 
Globals.

Your first example is correct provided it is inside a function body. 
Your second example should look like

Globals
   Object vs_addon

Var is not a valid variable type.

Hth,
Andrew.

On 8/11/2012 12:22 PM, Andy B. wrote:
> That's what I thought. BTW, what is the required file to include to get the 
> keyword Var? Doing
>
> Var
> Object vs_addon
> //or
>
> Globals
> Var
> Object vs_addon
>
> Either one results in an error. The first one reports that Var is an 
> unexpected string, and the second one reports an unexpected string globals. 
> Just doing:
>
> Include "hjconst.jss"
> Globals
> Object vs_addon
>
> Function AutoStartEvent()
> Vs_addon = GetObject("VS_JAWS.Connect")
> If !vs_addon then
> SayMessage(OTJAWS_MESSAGE, "The addon cannot be found!")
> EndIf
> EndFunction
>
> Compiles just fine, so I guess I don't understand the keyword Var and 
> why/when it is used.
>
> -----Original Message-----
> From: jawsscripts-bounce@xxxxxxxxxxxxx 
> [mailto:jawsscripts-bounce@xxxxxxxxxxxxx] On Behalf Of Andrew Hart
> Sent: Thursday, November 08, 2012 10:08 AM
> To: jawsscripts@xxxxxxxxxxxxx
> Subject: [jawsscripts] Re: Represent null in a comparison
>
> The usual way of doing this in JAWS script is to do something like this:
>
> Var
> Object oMyObject
>
> If !oMyObject Then
>     SayString("Error!  The object does not exist.") EndIf
>
> This has always worked for me.  I'm guessing you could also compare the 
> object var with the return from the Null function, e.g.,
>
> if oMyObject==Null() Then
>     SayString("Error!  The object does not exist.") EndIf
>
> Though the first method is neater and faster imho.  Don't waste your time 
> doing other kinds of comparisons.  The only comparison that makes sense of 
> Object variables is zero/non-zero.
>
> The following should also work in theory, but I have never tried it.  It 
> depends how clever/fussy that Script compiler type-checking/type-casting is.
>
> if oMyObject!=0 Then
>     SayString("Error!  The object does not exist.") EndIf
>
> btw, I should mention that null and empty are not the same concepts in VB.  
> Is Nothing is testing if an object variable or database entry is not set to 
> any value, indicating an undefined object pointer or db entry.  vbEmpty, on 
> the other hand, applies to strings and is equivalent to "".  In JAWS script, 
> if you want to check if a String is empty, it is best to use
>
> If Length(mystring)==0 Then
> ...
> EndIf
>
> Although in mor recent versions of JAWS (since JAWS 13 if I remember 
> correctly), the following should work:
>
> If mystring=="" Then
> ...
> EndIf
>
> It is safer to test the length of the string as this works in all versions of 
> JAWS.
>
> Hth,
> Andrew.
>
> On 8/11/2012 10:50 AM, Andy B. wrote:
>> In most languages, you can test for a null, nothing in VB, or empty
>> object by doing this:
>>
>>
>> C#: if (!vs_addon) {do something if it doesn't exist}
>>
>> VB: if vs_addon is nothing then do something if it doesn't exist end
>> if
>>
>>
>>
>> How would you do this in a jaws script?
>>
>>
>>
>>
>>
>> __________
>>
>> 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: