Re: Null
Re: Null
- Subject: Re: Null
- From: "Chris Espinosa" <email@hidden>
- Date: Mon, 6 Jan 2003 15:06:05 -0800
"Steve Roy" <email@hidden> wrote...
>
Hi!
>
>
When a variable hasn't been assigned a value, should we use 'null' or
'missing
>
value'?
Depends on who "we" is, and what you mean by "variable".
For scripters, you don't need to initialize uninitialized variables; you can
just leave them uninitialzed. That way, an error in your script logic (like
using a variable before it's been initialized) will be reported by
AppleScript.
If you want to override this (e.g. you want to check to see whether a
variable has been initialized), use "missing value". There is no globally
defined "null" in AppleScript (though some scripting additions and
applications define one).
If you're not a scripter but rather an application developer, a) you should
be asking this on email@hidden, and b) 'missing
value' (class code 'msng') is the correct thing to return for a request
where some aprts of the request can be satisfied (but not all).
For example, if you have a mailbox full of messages, some sent and some
unsent, if the scripter asks for the addressee of every message but some
messages don't have addressees yet, you should supply "missing value" for
those.
But don't use "missing value" for a general empty reply. If the script asks
for a specific object and it doesn't exist, return error errAENoSuchObject.
If the script has a Whose test of which no elements qualify, return an empty
list.
Chris
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
- Follow-Ups:
- Re: Null
- From: Christopher Nebel <email@hidden>