Re: lingo-l Help with lists **bad getaProp
But wouldn't [#someProp:0] or [#someProp:VOID] still report that a valid value is there when he seems to be saying that it isn't? roymeo At 12:11 AM 10/22/2002 -0500, you wrote: Lots of hoops for a simple concept. use findPos() Can you store a zero in your list to show the absence of an object, rather than storing VOID as the value? If you can do that, then as Tab said, you can tell the difference between you conditions. You need two checks, first to see if the if the property exists, then if the property exists then you need to check if the value is 0. Something like this: on GetMyValue someProp, aPropList theValue = getAProp(aPropList, someProp) if voidp(theValue) then alert(No such property someProp) return #errorNoSuchProperty -- or do whatever you want for this case end if if theValue = 0 then alert(No object available for someProp) return #errorNoSuchObject -- or do whatever you want for this case end if return theValue -- OK, return the value end Irv [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!] [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]
Re: lingo-l Help with lists **bad getaProp
Oh the havoc caused by depending on getaProp to check for the existence of a property in a list before referencing it... I used it in one of my utilities for merging multiple lists it led to an error that was a little difficult to debug. if getaProp(aPropList, #SomeProp) void then do something with #SomeProp fails when aPropList = [#SomeProp: 0] I've learned the hard way to test with findPos() Mike However, there is a more useful function that does not have these shortcuts. Say you have a situation where the user might try to access pFruits[ pear ], but that is not in the list. If you use [] or getProp (which are synonymous) you will get a script error. Alternatively, you can use getaProp, which does not cause an error, but simply returns VOID if the item is not in the list. [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]
Re: lingo-l Help with lists **bad getaProp
Umm, you could probably do if not voidP(getaProp(aPropList, #SomeProp)) then do something... A test of void/null vs 0 usually comes out equivalent. If (not a) will always be true if a is either 0 or void, but an explicit voidP test should differentiate. - Tab At 08:44 PM 10/21/02, Mike Gralish wrote: Oh the havoc caused by depending on getaProp to check for the existence of a property in a list before referencing it... I used it in one of my utilities for merging multiple lists it led to an error that was a little difficult to debug. if getaProp(aPropList, #SomeProp) void then do something with #SomeProp fails when aPropList = [#SomeProp: 0] I've learned the hard way to test with findPos() Mike However, there is a more useful function that does not have these shortcuts. Say you have a situation where the user might try to access pFruits[ pear ], but that is not in the list. If you use [] or getProp (which are synonymous) you will get a script error. Alternatively, you can use getaProp, which does not cause an error, but simply returns VOID if the item is not in the list. [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]
Re: lingo-l Help with lists **bad getaProp
myListofObjects = [#obj1: void] oops. Umm, you could probably do if not voidP(getaProp(aPropList, #SomeProp)) then do something... A test of void/null vs 0 usually comes out equivalent. If (not a) will always be true if a is either 0 or void, but an explicit voidP test should differentiate. - Tab [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]
Re: lingo-l Help with lists **bad getaProp
Can you store a zero in your list to show the absence of an object, rather than storing VOID as the value? If you can do that, then as Tab said, you can tell the difference between you conditions. You need two checks, first to see if the if the property exists, then if the property exists then you need to check if the value is 0. Something like this: on GetMyValue someProp, aPropList theValue = getAProp(aPropList, someProp) if voidp(theValue) then alert(No such property someProp) return #errorNoSuchProperty -- or do whatever you want for this case end if if theValue = 0 then alert(No object available for someProp) return #errorNoSuchObject -- or do whatever you want for this case end if return theValue -- OK, return the value end Irv At 8:36 PM -0500 10/21/02, Mike Gralish wrote: myListofObjects = [#obj1: void] oops. Umm, you could probably do if not voidP(getaProp(aPropList, #SomeProp)) then do something... A test of void/null vs 0 usually comes out equivalent. If (not a) will always be true if a is either 0 or void, but an explicit voidP test should differentiate. - Tab [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!] -- Lingo / Director / Shockwave development for all occasions. (Home-made Lingo cooked up fresh every day just for you.) [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]
Re: lingo-l Help with lists **bad getaProp
Lots of hoops for a simple concept. use findPos() Can you store a zero in your list to show the absence of an object, rather than storing VOID as the value? If you can do that, then as Tab said, you can tell the difference between you conditions. You need two checks, first to see if the if the property exists, then if the property exists then you need to check if the value is 0. Something like this: on GetMyValue someProp, aPropList theValue = getAProp(aPropList, someProp) if voidp(theValue) then alert(No such property someProp) return #errorNoSuchProperty -- or do whatever you want for this case end if if theValue = 0 then alert(No object available for someProp) return #errorNoSuchObject -- or do whatever you want for this case end if return theValue -- OK, return the value end Irv [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]