Is the clipboardData really an array?

J. Landman Gay jacque at hyperactivesw.com
Thu Feb 23 21:46:51 CST 2006


David Epstein wrote:
> Using MC 2.5 on Windows XP
> 
> My understanding is that the clipboardData is an array with 1 to 6 keys.
> But it appears to me that
> (1) setting one element of the array can empty out elements previously set;

Only if the new setting is of a different type of data than the old ones.

> (2) there is some problem loading the "image" element;

You can't have both images and text on the clipboard at once, so setting 
one will substitute it for the other. Since text can have various 
formats, all of those can be in the array at the same time. So, if you 
have copied text to the clipboard, it will replace any image that was in 
there, but the text will be in the array as multiple entries: plain 
text, rtf, and html all at once.

> (3) I can't get all of "the keys" of the clipboardData;

Right, it doesn't appear possible "get" the keys as a list. Since the 
keys are preset and known, "getting" them isn't too important. At any 
rate, this doesn't seem to be implemented.

> (4) "the clipboard" only reports the most recently set key (or "text" even
> if "RTF" was most recently set);

"The clipboard" is a different property from "the clipboardData". "The 
clipboard" reports only the general type of data in the clipboard, and 
is limited to only three types: text, image, or object. (Or it can be 
empty.) The "text" type implicitly includes all the various formats that 
text can be stored in. If you want to know the specifics about those 
different text formats, you need to use "the clipboardData" to retrieve 
them.

> (5) I can't put the clipboardData into a variable and then retrieve an array
> element from that variable or get the keys of that variable.

You can't retrieve the keys of the variable, because keys(the 
clipboardData) doesn't put anything into the variable. Also, the script 
asks for "the clipboardData" without including any array key, so the 
engine uses ["text"] as the default. In your example, "put the 
clipboardData into var" will put the default array value of ["text"] 
into the variable, not the entire array.

> 
> So is it not really an array?  Can it store more than one type of data at
> once?

Yes, it's really an array, but you can only store one type of object in 
it at a time. If your object is an image, it won't have any text types. 
If it is text, then the "rtf, html, text" keys will all have content but 
"image" and "object" will not.

> 
> I used the script below to experiment, and tried various changes in the
> order of the first four commands.

Instead, try manually copying some styled text from a field, then click 
a button that has this script:

on mouseup
   put the clipboarddata["text"] into fld 1
   put cr & the clipboarddata["html"] after fld 1
   put cr & the clipboarddata["rtf"] after fld 1
   put cr & the clipboarddata["image"] after fld 1
end mouseup

You'll see that all the text properties are in there, but the image part 
is empty. Now draw an image on the card and copy a portion of it to the 
clipboard. Then run the button again. This time you'll see there are no 
text entries in the clipboard, but the image data is displayed.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com


More information about the metacard mailing list