Custom properties and getProp

David Vaughan drvaughan55 at mac.com
Tue Jun 18 02:38:01 CDT 2002


I found these two corrections (line 1 and line -4) to my script which 
got it working:

getProp monthDays[monkey]
   if monkey is "Feb" then
     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
   else
     put the monthDays[monkey] of me into x
   end if
   return x
end monthDays

That leaves me with two general questions which I repeat with slight 
modifications:
Is "akey" in the dictionary definition of getProp meant to be a value or 
a variable? How is it passed and used?

How do I create a property (not a set) as an array in the properties 
dialogue rather than through scripting please?

thanks
David

On Tuesday, June 18, 2002, at 02:27 , David Vaughan wrote:

> 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
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 2640 bytes
Desc: not available
URL: <http://lists.runrev.com/pipermail/use-livecode/attachments/20020618/cab86d0f/attachment.bin>


More information about the use-livecode mailing list