Custom properties and getProp

Shao Sean shaosean at unitz.ca
Tue Jun 18 00:09:01 EDT 2002


howabout just using this code in your stack script or as an "inserted" script in your message heirarchy


function monthDays paramMonth, paramYear
  # change the numbers to the string version of the month name you are using
  if (paramMonth is among the items of "1,3,5,7,8,10,12") then
    return 31
  else if (paramMonth is among the items of "4,6,9,11") then
    return 30
  else if ((paramYear MOD 400 = 0) OR ((paramYear MOD 100 <> 0) AND (paramYear MOD 4 = 0))) then
    return 29  -- leap year
  else
    return 28
  end if
end monthDays


----- Original Message ----- 
From: "David Vaughan" <drvaughan55 at mac.com>
To: <use-revolution at lists.runrev.com>
Sent: Tuesday, June 18, 2002 12:27 AM
Subject: Custom properties and getProp


> 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
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution



More information about the use-livecode mailing list