• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Coerce String to Handler?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Coerce String to Handler?


  • Subject: Re: Coerce String to Handler?
  • From: "Neal A. Crocker" <email@hidden>
  • Date: Tue, 17 Apr 2001 00:30:04 -0500

Thanks for the followup.

the "makereference" handler I posted (included below) works to generate references to properties of scripts and fields of records. In other words, "target" should be a script or record. I figured it would work for handlers of scripts, but it doesn't. I'm not sure what would. (By the way, all the "+" and ";" characters are supposed to chevrons that look like "<<" and ">>".

on makereference(propname, target)
script refscript
--{class:reference,+class form;:+constant ****usrp;, +class want;:+class prop;, +class seld;:propname, +class from;:target}
{class:reference, +class form;:+constant ****usrp;, +class want;:property, +class seld;:propname, from:target} -- this line won't compile. replace with line above to compile
end script
run script refscript
end makereference

set blah to makereference("bar", {bar:2})
{blah, blah + 1} -- {bar of {bar:2}, 3}





I wasn't able to make the above work, but I can see where you
were going, and this is very clever. ;-)


You can deal with the "won't recompile" issues by using properties
like this:

property kLeft : ASCII character 199 -- Email-friendly
property kRight : ASCII character 200 --

property kProp : run script (kLeft & "class prop" & kRight)


somthing like this:

property kLeft : ASCII character 199 -- Email-friendly
property kRight : ASCII character 200 --

property kForm : run script kLeft & "class prop" & kRight

can be abreviated by this:

"prop" as type class





In fact, I find it more convienient to define chevron-items as
properties:

property kLeft : ASCII character 199
property kRight : ASCII character 200

property kForm : run script kLeft & "class form" & kRight
property kWant : run script kLeft & "class want" & kRight
property kSeld : run script kLeft & "class seld" & kRight
property kFrom : run script kLeft & "class from" & kRight

property kUsrp : run script kLeft & "constant ****usrp" & kRight
property kProp : run script kLeft & "class prop" & kRight

on makereference(propname, target)
script refscript
{class:reference, kForm:kUsrp, kWant:kProp} & ,
{kSeld:propname, kFrom:target}
end script

run script refscript

end makereference


> set blah to makereference("bar", {bar:2})
> {blah, blah + 1} -- {bar of {bar:2}, 3}

I get error "Can't make +data obj 00000001... into a number".


(note that in the following discussion, I'm using "<<" and ">>" as visual substitutes for chevrons)

the above version of "makereference" probably doesn't works because while kForm, kWant, kSeld and KFrom may exists as variables whose contents are <<class form>>, <<class want>>, <<class seld>> and <<class from>>, they are not replaced with their contents in a line such as:

{class:reference, kForm:kUsrp, kWant:kProp} & {kSeld:propname, kFrom:target}

Rather, in such a line they are treated literally as record field labels which have no connection to the variables of the same names. Thus such a line is not equivalent to the following line :

{class:reference,<<class form>>:kUsrp, <<class want>>:kProp} & {<<class seld>>:propname, <<class from>>:target}


Neal


  • Prev by Date: Re: Coerce String to Handler?
  • Next by Date: Re: Trapping aete's
  • Previous by thread: Re: Coerce String to Handler?
  • Next by thread: file info on a folder of items (2nd post)
  • Index(es):
    • Date
    • Thread