Custom properties and getProp

David Vaughan drvaughan55 at mac.com
Mon Jun 17 23:31:01 CDT 2002


I have created in a stack a custom property set called "monthDays" with 
Properties Jan-Dec with values 30,31 and 28 as appropriate to the month. 
I use this to look up the number of days in the month in the manner:

put "Jun" into thisMonth
get the monthDays[thisMonth]

which works. To cater for the special case of February, I wrote the 
following getProp handler. It resides in the stack script of the stack 
where the property set is defined.

(field "theDate" contains the abbreviated date)

getProp monthDays,Feb
   put word 3 of item 2 of field "theDate" into theYear
   switch
     case (theYear mod 400) = 0
       put 29 into x
       break
     case (theYear mod 100) = 0
       put 28 into x
       break
     case (theYear mod 4) = 0
       put 29 into x
       break
     default
     put 28 into x
   end switch
   return x
end monthDays

This is fine except it always returns 28 or 29 regardless of the month, 
so what do I do with for the other months? Have a getprop for each one? 
This would rather defeat my evident purpose.

Is "akey" in the dictionary definition of getProp meant to be a 
variable? I tried assuming that with no success.

Another option I considered was that I should be using a property array 
rather than a property set. If so, how do I create a property (not a 
set) as an array in the properties dialogue rather than through 
scripting please? If I were to do the latter then I hardly need the 
property.

thanks
David




More information about the use-livecode mailing list