📄 medit.src
字号:
#ifDLLCALL
#else
/*
** medit.src
** (C) Copyright 1990, 1991, 1992, 1996 FORWARD Computing and Control Pty. Ltd.
** All Rights Reserved. ACN 003 669 994
** MEDIT V2.02
**
** medit
**
** Purpose: Full-screen editor for matrices with both character and
** numeric elements.
**
** Format: { y,yv,yfmt } = medit(x,xv,xfmt)
**
** Inputs: x LxM matrix to be edited.
**
** xv scalar, vector or matrix. xv is first reshaped into a
** 1xM vector. Then the non-zero elements in xv mark the
** respective columns of x as numeric, 0's mark them as
** character.
**
** xfmt scalar, string or matrix. xfmt sets the initial column
** formats. If xfmt is a scalar then the default formats of
** " lg " 16 8 for numeric columns and "s " 8 8 for
** character columns are used. If xfmt is a string then
** the first 8 characters are used and 8 8 add to give the
** global column format. If xfmt is a matrix it must have
** 3 columns and will be reshaped to a Mx3 format matrix
** for use as the column formats. In all cases the values
** in the xv vector override the formats specified in xfmt.
**
** Outputs: y LxM edited matrix.
**
** yv 1xM vector of one and zeros, 1 if the respective column
** of y is numeric, 0 if it is character.
**
** fmt Mx3 matrix, each row containing format information
** (suitable for use with printfm) for the respective
** column of y.
**
** Remarks:
**
** This function is an option and must be ordered separately. Initially a
** demonstration version of this function is supplied.
**
** The version supplied with GAUSSI only displays the real part of the
** matrix if the imaginary part is missing or all zeros. The display
** changes to complex when an edited element has non-zero imaginary part
** or a row or column is added with a complex fill value.
**
** Alt-X terminates the editor. If you are editing an element or executing a
** command, first press either Esc to abandon the editing or command. When
** Alt-X is used to terminate the editor the resulting matrix, y, is saved in
** the file _medit_x.fmt. Esc also exits from the editor but the results of
** the editing are not returned and the matrix is not saved to the file. The
** original value of the matrix remains unchanged.
**
** The following keys allow you to move around the matrix.
**
** Left Move one cell left
** Right Move one cell right
** Up Move one cell up
** Down Move one cell down
** PgUp Move one page up
** PgDn Move one page down
** Ctrl-Left Move one page left
** Ctrl-Right Move one page right
** Home Beginning of row
** Home Home Beginning of matrix
** End End of row
** End End End of matrix
** Enter Move on one cell
** Backspace Move back one cell
** Ctrl-Enter Toggle the direction of Enter and Backspace
** Alt-G Goto row and column
**
** The following alternate Wordstar keystrokes are supported.
**
** Ctrl-G Del Ctrl-R PgUp
** Ctrl-H Backspace Ctrl-C PgDn
** Ctrl-S Left Ctrl-A Ctrl-Left
** Ctrl-D Right Ctrl-F Ctrl-Right
** Ctrl-E Up Ctrl-Q S Home
** Ctrl-X Down Ctrl-Q D End
**
** The operation of the Enter and Backspace keys depends on the Ctrl-Enter
** setting. Ctrl-Enter toggles the direction of movement for Enter from left
** to down to no movement. Backspace moves in the opposite direction to
** Enter. The arrow at the top left of the matrix indicates the current
** setting.
**
** Alt-G allows you to jump to any element in the matrix. Pressing Alt-G
** prompts you for the row and column to go to. Enter the integer row and
** column numbers separated by either a space or a comma and then press Enter
** to execute the command. Invalid entries will beep and can be edited.
** Pressing Esc will abandon the command.
**
** The following editing keys are available to you when editing a matrix
** element.
**
** Left Move left
** Right Move right
** Del Delete character at cursor
** Backspace Delete character to left of cursor
** Home Move to beginning of input
** End Move to end of input
** Enter Save the new value
** Ctrl-Enter Toggle the direction of movement after Enter
** Alt-P Inserts pi on the input line
** Alt-E Inserts e on the input line
** Esc Abandon editing of the element
**
** The current element is displayed at the top of the screen. Character
** elements are displayed surrounded by " ". Numeric elements are displayed
** in exponential format to full precision. To edit the current element just
** type in the new value. To save the new value press Enter. If the value
** is valid it will be saved. Invalid values will beep and can be edited.
** Pressing Esc abandons the editing and leaves the element unchanged.
**
** Numbers can be entered in either integer, floating point format or
** exponential format. To enter a missing value in a numeric element just
** type . and then press Enter. If the numeric value entered overflows then
** INF with the appropriate sign will be stored. If the numeric value
** entered underflows +0 will be stored.
**
** Complex numbers are of the form NUMBER +/- NUMBER i or NUMBER i.
** E.g. 0.5 - 1i, . + .i, 5i
** Note there must be a number before the i, i.e. 5+i is invalid.
** If the complex part is zero it is not displayed by MEDIT or printed by
** PRINTFM.
**
** Character elements are limited to 8 characters. To enter an empty
** character string press Space and then Backspace to delete the space and
** the press Enter to store the empty string. All strings are padded to 8
** characters with nulls before storing.
**
** The following command keys are available to you when moving around the
** matrix.
**
** Alt-H Help
** Esc Abandon matrix and quit medit
** Alt-X Exit medit. Result saved in _medit_x.fmt
** Alt-R Select rows
** Alt-C Select columns
** Alt-V Set fill value. Use " " for character fill values
** Alt-I or Ins Insert row, column or block
** Alt-F Format column
**
** The Alt-R and Alt-C commands allow a block of rows or columns to be
** selected using any of the cursor movement keys. The selected block can
** then be cut to the scrap buffer using Grey - or copied using Grey + or
** the block can be deleted by pressing Del.
**
** The Alt-F command allows the format of the current column to be changed.
** Alt-F N sets the default numeric format, Alt-F C sets the default
** character format and Alt-F E allows you to edit the column format. The
** variable type vector, yv, and formatting matrix, yfmt, are updated to
** reflect the new format.
**
** Using the format editor the column format can be selected as well as the
** trailing character, column width and precision. The format editor is
** intelligent and will automatically adjust the column width or precision to
** ensure all numbers in the column can be displayed in the selected format.
** Very large numbers in the column will cause the decimal format to
** automatically switch to an exponential format.
**
** printfm can be used to print the matrix in the format displayed by medit.
** e.g.
**
** { x,v,fmt } = medit(x,1,1);
** call printfm(x,v,fmt);
** Note however that unn's in medit are printed as numbers by GAUSS's
** printfm.
**
** The Alt-V sets the fill value to be used for inserting new rows and
** columns. Pressing Alt-V displays the current value and allows a new value
** to be entered. Enclose character values with " ". Character values must
** not exceed 8 characters. Esc abandons the entry of the new value and
** leaves the current fill value unchanged. The default fill value is the
** GAUSS missing value.
**
** The insert commands work with the fill value to insert a new row or column
** into the matrix in front of the current cursor position. The new row or
** column is filled with the current fill value. Alt-I R inserts a new row
** and Alt-I C inserts a new column. For columns the type of the fill value
** determines the type of the column. The Alt-I B command allows a
** previously cut or copied block to be inserted in front of the cursor
** position. Ins can be used instead of Alt-I.
**
** If you have a CGA display adaptor and medit is causing snow or flicker
** when you page up or page down, then edit the medit.a16, medit.a32 or
** medit.i32 file to change CGA to 1.
**
** Example:
**
** { x,v,fmt } = medit(zeros(10,5),1,1);
**
** This example edits an empty matrix and assigns the result to x. The
** second and third arguments are reshaped to the correct size and the column
** formats are set to the default numeric format. These vectors are then
** updated by the format commands during the editing and the results assigned
** to v and fmt.
**
**
** { x,v,fmt } = medit(x,1~0,"le");
**
** This example sets all the odd columns of x to a scientific format and sets
** all the even columns to the default character format.
**
** def_fmt = "-lf,"~4~3;
** { x,v,fmt } = medit(x,1,def_fmt);
**
** This example sets all the columns of x to a numerical decimal format, left
** justified with a trailing ','. It also sets the precision to 3 and the
** minimum width to 4. The necessary width will be automatically
** determined by medit.
**
** See Also: printfm, con, editm
**
** Defines:
**
** _med_esz Size of matrix element in bytes.
** _med_isz Size of integer in bytes.
** _med_pad Padding for matrix alignment and local args.
**
** Globals:
**
** _med_1(), _med_2r(), _med_2c() support procedures
*/
/* ---- Uncomment for Demo Version ---- */
/* #definecs DEMO */
/* ------------------------------------ */
#ifcplx
#definecs _MED_ESZ 16
#ifdef DEMO
#definecs MED_SIZE 10945 /* loadsize for DEMO MEDITI.REX */
#else
#definecs MED_SIZE 10699 /* loadsize for MEDITI.REX */
#endif
#else
#definecs _MED_ESZ 8
#ifdef DEMO
#definecs MED_SIZE 10624 /* loadsize for DEMO MEDIT.REX */
#else
#definecs MED_SIZE 10371 /* loadsize for MEDIT.REX */
#endif
#endif
/* For suppression of interference on
** CGA display adaptors, set CGA to 1
*/
#definecs CGA 0
#definecs _MED_ISZ 4
#definecs _MED_PAD 64
#definecs MAX_SIZE 536870910 /* maximum matrix size */
#definecs GXE_SIZE 0 /* no extra memory needed to re-load .REX file */
/*
** _med_1
**
** Purpose : Calculate the number of matrix elements required for
** x = x[i:j,k:l];
** OR
** y = 0;
** y = x[i:j,k:l];
**
** Format : size = _med_1(row_idx,col_idx,no_rows,no_cols,same);
**
** Inputs : row_idx 2x1 vector, indices of row selection
** OR missing value if x[.,k:l] used.
** col_idx 2x1 vector, indices of col selection
** OR missing value if x[i:j,.] used.
** no_rows rows(x) Do NOT use rows(x) or cols(x) as an argument.
** no_cols cols(x) use temporary variables r=rows(x); c=cols(x);
** and then pass r and c to _med_1().
** same 1 if x=x[i:j,k:l] ie assigning to same matrix.
** 0 if y=x[i:j,k:l] ie assigning to different matrix.
**
** Outputs : size scalar, size in number of matrix elements needed for
** the operation.
**
*/
Proc(1) = _med_1(row_idx,col_idx,no_rows,no_cols,same);
local idx,matr,matc;
idx = 0;
if not(scalmiss(row_idx));
idx = idx + abs(row_idx[2]-row_idx[1]) + 1;
matr = abs(row_idx[2]-row_idx[1]) + 1; /* no rows in result */
else;
matr = no_rows;
endif;
if not(scalmiss(col_idx));
idx = idx + abs(col_idx[2]-col_idx[1]) + 1;
matc = abs(col_idx[2]-col_idx[1]) + 1; /* no cols in result */
else;
matc = no_cols;
endif;
/* add padding for matrix alignment */
if same; /* x = x[i:j,k:l] */
retp((matr*matc + idx*(_MED_ISZ/_MED_ESZ) + _MED_PAD));
endif;
/* else y = x[i:j,k:l] */
retp((2*matr*matc + idx*(_MED_ISZ/_MED_ESZ) + _MED_PAD));
endp;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -