Re: variable value --> property name?
Re: variable value --> property name?
- Subject: Re: variable value --> property name?
- From: julifos <email@hidden>
- Date: Sat, 14 Jun 2003 10:58:59 +0200
>
I do believe that I have seen this question, and I thought I kept a copy of
>
that thread. Alas...I can not seem to find it, nor can I even remember what
>
the proper terminology is to adequately search.
>
>
Can I sell anyone a shiny, new, bottomless bucket? ;)
>
>
#1 --
>
Is it possible to pass a variable value as a property name ... if that is
>
the right way to say it?
>
>
Code Sample:
>
>
script doctyper
>
property |HTML 2.0 Compact| : "dtdRemovedForPosting"
>
property |HTML 3.2 Final| : "dtdRemovedForPosting"
>
-- etc.
>
property |XHTML 1.0 Transitional| : "dtdRemovedForPosting"
>
end script
>
>
doctyper's |HTML 4.0 Transitional|
>
>
Can I get that piped property name from a variable?
Let's see if I understand your question. You wish an user to choose from a
list. Eg:
{"HTML 1","HTML 2","HTML 3"}
--> doctyper's properties are labeled, eg, |HTML 1|, |HTML 2|
Then return the propper value, without a long circuit. Eg:
########### YOU DON'T LIKE THIS ###########
if userInput is "HTML 1" then
return doctyper's |HTML 1|
else if userInput is "HTML 2" then
return doctyper's |HTML 2|
else...
########## END YOU DON'T LIKE THIS ##########
If I understood the question, then you could use this:
############ DO YOU LIKE THIS? ############
script doctyper
property |HTML 1| : "cool!"
end script
set userInput to "HTML 1"
return (run script "my doctyper's |" & userInput & "|")
########### END DO YOU LIKE THIS? ###########
Though I personally would choose "defaults read" and a plist file containing
your "properties":
############ DO YOU LIKE THIS? ############
set userInput to "HTML 1"
do shell script "defaults read 'prefFile'" & quoted form of userInput
########### END DO YOU LIKE THIS? ###########
But this last is only cross-MacOSX...
JJ
>
#2 --
>
In lieu of that, what would you recommend as a suggested approach to provide
>
a handler/script object to quickly return a DTD given a user choice? My
>
design 'hopes' were: portable/reusable, easily replaceable apart from the
>
associated applet, and cross-MacOS.
>
>
Is a script with only properties -- and a handler -- the best way? (Not a
>
text preference file, right?) Just use the list speed hack, in a separate
>
script file, and go with it?
>
--
>
Gary
>
>
MacOS 9.1 / "9 is Fine"
>
OMM: osa:AS 183 / osa:JS 103 / FM 55 / BB601 / Smile 188
>
______________________________________________________________
>
Please reply directly to the list.
>
Incoming messages are auto-deleted. (It's anti-spam, that's all.)
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.