passing setProp of a property set
zryip theSlug
zryip.theslug at gmail.com
Wed Mar 24 19:24:40 EDT 2010
2010/3/24 Andrew Kluthe <andrew at rjdfarm.com>:
>
> setprop OldData[TenureEndDate] pDate
> replace "-" with "," in pDate
> put item 1 of it into sYear
> put item 2 of it into sMonth
> put item 3 of it into sDay
> put sMonth & "-" & sDay & "-" & sYear into pDate
> pass OldData["TenureEndDate"]
> end OldData[TenureEndDate]
>
> I want to format TenureEndDate of the OldData custom property set.
>
> I am an [X] next to this line on compilation:
>
> pass OldData["TenureEndDate"]
>
> I need to pass the property to enter pDate into it right? Am i doing this
> correctly?
Use the pass command to send a handler to the next object in the hierarchy.
For the Revolution's Native Message Path, have a look to the RIchard
Gaskin's web site here :
http://www.fourthworld.com/embassy/articles/revolution_message_path.html
Now for using setProp and getProp...
Imagine that you have an object myInvoice defined by two dates, an old
date and a new date.
In a process you want to set a new date to the invoice but you want to
keep the old date to revert change in case of an error occurs.
You could define your invoice object like this :
local myInvoiceObject
-- Create the object with a multidimensional array like a property tree
put "theSlug" into myInvoiceObject["client"]["Name"]
put "3/1/2010" into myInvoiceObject["dates"]["old"]
put "3/25/2010" into myInvoiceObject["dates"]["new"]
To keep the Old date you could do that :
set the myInvoiceProp["old date"] to "3-12-2010"
using :
setprop myInvoiceProp [ptheProp] pTheValue
switch ptheProp
case "old date"
set itemDelimiter to "-"
put item 1 of it into sYear
put item 2 of it into sMonth
put item 3 of it into sDay
checkForValidDate -- a handler to check if the date is valid. If
not throws an error
put sMonth & "-" & sDay & "-" & sYear into myInvoiceObject["dates"]["old"]
set itemDelimiter to ","
break
case "new date"
....
case "client"
....
default
answer "Error - property not exists !"
pass myInvoiceProp
end myInvoiceProp
And now to read the old date from the object you could write a getProp like this
getprop myInvoiceProp [ptheProp]
switch ptheProp
case "old date"
return myInvoiceObject["dates"]["old"]
break
case "new date"
.....
end myInvoiceProp
To revert the date you could read the property like this:
put the myInvoiceProp["old date"] into fld "invoice date"
I've not test the code but I hope that the idea of how it works is here.
Regards,
--
-Zryip TheSlug- wish you the best! 8)
http://www.aslugontheroad.co.cc
More information about the use-livecode
mailing list