Next: clipreaddata Up: MacAnova Help File Previous: cimag()   Contents

CLIPBOARD

Usage:
CLIPBOARD <- x   or   x <- CLIPBOARD  or  vecread(string:CLIPBOARD)
x <- fromclip([ncols]), integer ncols > 0
toclip(x), x REAL scalar, vector, matrix or array
SELECTION <- x  or  x <- SELECTION (Motif only)
Type help(CLIPBOARD) for more information.



Keywords: syntax, character variables, input, output
A special CHARACTER variable CLIPBOARD is always defined.  When used in
an expression or as an argument to a function, CLIPBOARD behaves just
like any other variable.  It can be printed, written to a file, or
assigned to a regular variable.

In the windowed versions (Macintosh, Windows and Motif), CLIPBOARD
allows direct access to the system Clipboard.

CLIPBOARD <- x assigns a CHARACTER representation of x to CLIPBOARD.  x
must be a CHARACTER, REAL or LOGICAL variable.

CLIPBOARD[1] <- x and CLIPBOARD[T] <- x do the same, provided x is a
scalar variable.  It is an error if x is not a scalar.

CLIPBOARD[rep(1,k)] <- x is permissible, in which case x must be a
vector of length k and CLIPBOARD will contain a CHARACTER representation
of x[k].

In the windowed versions (Macintosh, Windows and Motif), CLIPBOARD <- x
and CLIPBOARD[1] <- x copy the new value of CLIPBOARD to the system
Clipboard.  And when any text is copied to the system Clipboard using
the Edit Menu in MacAnova or any other program, that text becomes the
value of CLIPBOARD.

In non-windowed versions, CLIPBOARD <- x and CLIPBOARD[1] <- x do
nothing beyond setting CLIPBOARD to CHARACTER representation of
x (to x when x is CHARACTER).

                Details of the CHARACTER representation
After CLIPBOARD <- x, the contents of variable CLIPBOARD (and of the
system Clipboard in the Windowed versions) are as follows:

  When x is a CHARACTER scalar, CLIPBOARD will contain that scalar.
  This is also the case after CLIPBOARD[1] <- x.

  When x is a REAL or LOGICAL scalar, CLIPBOARD will contain a character
  representation of x. This is also the case after CLIPBOARD[1] <- x.
  For example CLIPBOARD is "3.1415926535897931" after either CLIPBOARD
  <- PI or CLIPBOARD[1] <- PI and is "T" after CLIPBOARD <- PI > 3 or
  CLIPBOARD[1] <- PI > 3.

  When x is a vector of length N, CLIPBOARD will contain N lines
  separated by "\n", with line i containing a x[i], when x is CHARACTER,
  or a CHARACTER representation of x[i] otherwise.

  When x is a matrix, CLIPBOARD will contain nrows(x) lines, with line i
  containing CHARACTER representations of x[i,j], j=1,...ncols(x),
  with the elements of each row separated by the tab character "\t".

  When x is an array with 3 or more dimensions greater than 1, it is
  treated as if it were a matrix with nrows(x) = first dimension > 1.

Stated more technically, the value of CLIPBOARD after CLIPBOARD <- x is
what would be produced by
   Cmd> CLIPBOARD <- paste(x,multiline:T,missing:"?",sep:"\t",\
                linesep:"\n", format:"0.17g")

See topic paste() for more information on paste(x,multiline:T,...).

Since MISSING is coded as '?', after CLIPBOARD <- x, where x is REAL
vecread(string:CLIPBOARD), should produce vector(x), including MISSING
values.

Two pre-defined macros, toclip() and fromclip(), are useful when working
with CLIPBOARD.  In particular, toclip() allows for different coding of
MISSING and user specified field separators.  See topics fromclip() and
toclip().

In the windowed versions, because the value of CLIPBOARD is whatever
text the system Clipboard currently contains, CLIPBOARD may not be the
same as what was most recently assigned to it.  This can happen because
of subsequent use of Edit menu items in MacAnova or another program.
This feature allows easy importing of data from other programs,
especially from spreadsheets.  See topic fromclip().

Similarly, in the windowed versions you can easily export data from
MacAnova to another application like a spreadsheet by assigning the
value of a variable to CLIPBOARD.  See toclip().

You can free up the memory used by the contents of CLIPBOARD by
delete(CLIPBOARD).  This has no effect on any system Clipboard.

You probably should not use CLIPBOARD as a name for a structure
component or as a keyword on a computer with an actual Clipboard, as
every mention of CLIPBOARD, even in contexts like str$CLIPBOARD or
CLIPBOARD:T, refreshes special variable CLIPBOARD with stuff from the
Clipboard.

                      Variable SELECTION in Motif
In Motif, selecting text with the mouse provides another method of
communicating between programs.  Briefly, if you select text and then
click in a window using the middle button on the mouse, what was
selected is inserted there.  The Motif version of MacAnova has a special
CHARACTER variable SELECTION which is connected to the current selection
in the same way CLIPBOARD is connected to the Clipboard.  Immediately
after
  Cmd> SELECTION <- x
if you click in a window with the middle button, a character
representation of x is "pasted" into the window.  SELECTION[1] <- x is
permissible if x is a scalar.

Similarly, if you select text in a window,
  Cmd> charx <- SELECTION
creates a CHARACTER variable charx containing the text; if the text is
numerical data,
  Cmd> x <- vecread(string:SELECTION)
creates a REAL vector x.  Use of this feature is somewhat tricky, since
clicking in a window can change the selection.  When you assign
something to SELECTION, you should retrieve it with a middle button
click before doing anything else.  And if you want to assign from or
read from SELECTION, you should type the command without a terminating
Enter, then select what you want to copy, click on the frame of the
MacAnova window, and then press Ctrl+E followed by Return to execute the
command.

On a Macintosh or Windows computer, putting something on the Clipboard
whether by Copy or Cut on the Edit menu or by assigning to CLIPBOARD,
deletes any text that was already there.  In Motif, it goes at the end
of a list of items previously put on the Clipboard.  CLIPBOARD and Paste
on the Edit menu references the last item in the list.  You can edit the
Clipboard and delete obsolete items with X program xclipboard.

See also topics vecread(), matread(), macroread().


Gary Oehlert 2003-01-15