Next: eigen() Up: MacAnova Help File Previous: dos_windows   Contents

edit()

Usage:
edit(obj [, T] [,stripdol:F]), obj a macro or a REAL variable
edit(0)
edit([stripdol:T])



Keywords: general
                                  Usage
edit(obj) where obj is a REAL vector, matrix, array, or a macro, writes
a temporary file and invokes an editor to edit that file.  When editing
is done, edit() returns as value the edited contents of the file.  For
example, 'mymacro <- edit(mymacro)' allows you to change or correct
macro mymacro().  edit() is implemented as a macro which is pre-defined
only in some non-windowed versions of MacAnova.

When you change the dimensions of a vector, matrix, or array, you must
edit the header line to reflect the change before quitting the editor.

edit(obj,T) is equivalent to 'obj <- edit(obj)'.

                           Keyword 'stripdol'
By default, when editing a macro, trailing '$$' on temporary variables
are stripped off for editing and then restored before returning.  To
suppress this, used edit(mymacro [,T], stripdol:F)

                           Creating new macro
mynewmacro <- edit([stripdol:F]) (with no non-keyword arguments) invokes
an editor on a temporary file with a header specifying a macro with a
single blank line.  You can enter and edit a macro, being sure to change
the number on line 1 to reflect the actual number of lines in the macro.
Unless stripdol:F is an argument, '$$' will be appended to any names
starting with '@'.

                           Creating new vector
x <- edit(0) invokes an editor on an empty temporary file and then
performs vecread() on that file, under the assumption that the user has
edited in data that may be read in this manner.  This allows you to use
an editor to enter data.

                         Changing default editor
You can specify the editor to be used by creating a CHARACTER variable
with name 'EDITOR' by, for example, EDITOR <- "emacs".  When EDITOR has
not been set, the default editor is "vi" on Unix/Linux and "edit" for
DOS.

Macro edit() is pre-defined only in the Unix/Linux versions and in the
extended memory DOS version of MacAnova.  Two forms of edit(), one for
Unix/Linux and one for DOS, are included with names editunix() and
editpc(), in file MacAnova.mac.txt distributed with MacAnova.

                      Editing in windowed versions
To edit a macro, say mymacro(), in a windowed version, first open a new
command/output window using Open on the File menu.  Then print the
macro in the new window in a form you can edit by:

  macrowrite(CONSOLE, mymacro, stripdol:T)

Then edit the macro, copy to the clipboard the entire macro including
the header line (mymacro MACRO DOLLARS) and trailer line (%mymacro%),
and then do the following:

  mymacro <- macroread(string:CLIPBOARD)

Then switch back to your original window to test it and use it.  It's
not necessary to open the extra window, but it makes it easier since you
can separate your editing from the use of the macro.

                            Cross references
See also topics macrowrite(), macroread(), 'CLIPBOARD'.


Gary Oehlert 2006-01-30