Page 1 of 1
Problem copyng to the clipboard
Posted: Fri Jan 22, 2010 2:52 am
by phaworth
I'm trying to copy the label of an option menu button to the clipboard with this code:
That results in the runtime error "chunk error in object expression" followed by the text of the button's label.
Is there a way to copy the label of a button onto the clipboard?
Thanks,
Pete
Re: Problem copyng to the clipboard
Posted: Fri Jan 22, 2010 3:32 am
by sturgis
look at the clipboard() function in your dictionary. IT can be used to determine if there is anything in the clipboard, and what type of data it is.
To put something into the clipboard, or get it from the clipboard look at clipboardData
The following puts the data into the clipboard.
set the clipboardData["text"] to the label of button "xyz"
At this point, you can look to see what type of data is in there.
put the clipboard
will return "text" and put it in the message box.
To get stuff back out of the clipboard is pretty straightforward too.
put the clipboardData["text"] into field "abc"
Quite a bit more good information in the dictionary, but this should get you started.
Edit: While it seems it should work as in your example, apparently copy can't figure out what to do with a property return. put char 1 to -1 of the label of button "xyz" works, but when you tack the copy on to the front it doesn't. /shrug. Either way, it still seems easier to me to use clipboardData directly to set and get values. Much more flexible unless you want to copy objects.
If anyone can point out a proper syntax/method to use copy to put label names and the like into a clipboard, i'd be curious to know how. Thx
Re: Problem copyng to the clipboard
Posted: Fri Jan 22, 2010 6:18 am
by phaworth
Thanks, that works perfectly for what I want to do.
Re: Problem copyng to the clipboard
Posted: Fri Jan 22, 2010 5:55 pm
by BvG
you can't copy the label of anything. the syntax in the dict is correct and says:
copy [object [to {card | group | stack} ]] | [chunk of field]
so it's either:
copy <any object> to <either card or group or stack
or
copy <chunk description> of <any field>
examples:
copy line 1 of field 2
copy button "it works" to this card
non working examples:
copy char 12 to 18 of the imagedate of graphic "nope"
copy the hilite of button "can't work" to group "too bad"
Re: Problem copyng to the clipboard
Posted: Fri Jan 22, 2010 6:23 pm
by phaworth
The clipboardData suggestion works fine for what I want to do. Still feel like copy ought to work - as pointed out a couple of posts ago isn't "char 1 to -1 of the label of button "xyz" a chunk? Yet copy won't work with it. No big deal though, all is working fine now.
Pete
Re: Problem copyng to the clipboard
Posted: Sat Jan 23, 2010 2:08 am
by BvG
yes, part one of the source is a chunk. however, part 2 of the chunk is _not_ a field. therefore it doesn't work.