Session Manager Editing: Difference between revisions

From NARS2000
Jump to navigationJump to search
No edit summary
No edit summary
Line 1: Line 1:
The session manager in NARS2000 allows a wide variety of techniques to perform common tasks.
The session manager in NARS2000 provides a wide variety of techniques to perform common tasks.


* The Session manager window consists of a mixture of input and output.
* The Session manager window consists of a mixture of input and output.
Line 28: Line 28:
</apll>
</apll>


<p>The above example (starting with <apll>h←</apll>) also illustrates how to create a '''multi-statement''' anonymous function or operator (AFO) with comments, where separate physical lines form a single logical line.  Note that this is different from a '''multi-line''' AFO where separate physical lines form separate logical lines &mdash; we don't support that as yet.  In particular, a statement with continued lines is still a single logical line (minus the comments which are handled specially).  If a subsequent continued line does not start with a statement separator, then it is a continuation of the previous statement (as in the example above starting with <apll>f←</apll>), not a new statement.</p>
<p>The above example (starting with <apll>h←</apll>) also illustrates how to create a '''multi-statement''' anonymous function or operator (AFO) with comments, where separate physical lines form a single logical line.  Note that this is different from a '''multi-line''' AFO where separate physical lines form separate logical lines &mdash; we don't support that in Session Manager Editing, but we do in [[Function_Editing|Function Editing]].  In particular, a statement with continued lines is still a single logical line (minus the comments which are handled specially).  If a subsequent continued line does not start with a statement separator, then it is a continuation of the previous statement (as in the example above starting with <apll>f←</apll>), not a new statement.</p>


<p>The only syntax elements that can't be continued to the next line are names and comments &mdash; splitting a name in two creates two separate names; splitting a comment in two does not create one continued comment nor does it create two separate comments.  Instead use a comment symbol to start each comment on separate physical lines.  To create a new statement, use the statement separator (<apll>⋄</apll>).</p>
<p>The only syntax elements that can't be continued to the next line are names and comments &mdash; splitting a name in two creates two separate names; splitting a comment in two does not create one continued comment nor does it create two separate comments.  Instead use a comment symbol to start each comment on separate physical lines.  To create a new statement, use the statement separator (<apll>⋄</apll>).</p>
<p>Another use for Line Continuations is in function headers with a large number of local variables.  The following example is taken from the <apll>ANALYZE</apll> function in the <apll>2by2</apll> workspace:</p>
<apll>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(⎕CR 'ANALYZE')[1;]<br />
gTRACE←{bBstrNums} ANALYZE STRING;TCNL;TCNUL;LSTACK;RSTACK;CUROBJ;REDUCTIONS;OBJ;EVENT;UNK;DOP;DOPN;MOP;MOPN;IDX;F;MF;NF;A;SA;J;EOS;LP;RP;LBK;SEMI;RBK;ARBK;SRBK;LBC;RBC;SP;BSTR;SYNOBJ;RES;FFR;FR;AFR;HFR;GO;NAM;SPA;SPD;SPF;SPM;SPHY;SPNF;CS0;CS1;CSF;CSI;CSIA;CSIV;HY;MR;DR;HR;SPFR;SPMR;SPDR;SPHR;SPMN;SPDN;JD;SOS;LASTRIGHT;AFOG;AFOR;CSEF;CSFN;IO;ISPA;LNR;NNR;NR;SYNR;SYSN;VALR;NVAL;LftStkLen;RhtStkLen;⎕IO
</apll>
<p>which can be rewritten as several short lines</p>
<apll>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(⎕CR 'ANALYZE')[1;]<br />
gTRACE←{bBstrNums} ANALYZE STRING;<br />
<span style="color:blue;">➥</span>TCNL TCNUL LSTACK RSTACK CUROBJ REDUCTIONS<br />
<span style="color:blue;">➥</span>OBJ EVENT UNK DOP DOPN MOP MOPN IDX F MF NF A SA J EOS LP RP<br />
<span style="color:blue;">➥</span>LBK SEMI RBK ARBK SRBK LBC RBC SP BSTR SYNOBJ RES FFR FR AFR<br />
<span style="color:blue;">➥</span>HFR GO NAM SPA SPD SPF SPM SPHY SPNF CS0 CS1 CSF CSI CSIA CSIV<br />
<span style="color:blue;">➥</span>HY MR DR HR SPFR SPMR SPDR SPHR SPMN SPDN JD SOS LASTRIGHT AFOG<br />
<span style="color:blue;">➥</span>AFOR CSEF CSFN IO ISPA LNR NNR NR SYNR SYSN VALR NVAL LftStkLen RhtStkLen ⎕IO
</apll>
<p>which can then be further organized into groups of related local variables along with a trailing comment on each line, as opposed to the typical practice of the function header as a disorganized unordered pile into which names are tossed.</p>
<apll>
gTRACE←{bBstrNums} ANALYZE STRING;<br />
<span style="color:blue;">➥</span>⎕IO BSTR CUROBJ EVENT LASTRIGHT OBJ REDUCTIONS RES SYNOBJ TCNL TCNUL ⍝ Local vars<br />
<span style="color:blue;">➥</span>LftStkLen RhtStkLen LSTACK RSTACK ⍝ Stack vars<br />
<span style="color:blue;">➥</span>A AFOG AFOR AFR ARBK CS0 CS1 CSEF CSF CSFN CSI CSIA CSIV&nbsp;&nbsp;⍝ Syntax objects<br />
<span style="color:blue;">➥</span>DOP DOPN DR EOS F FFR FR GO HFR HR HY IDX IO ISPA J JD&nbsp;&nbsp;&nbsp;&nbsp;⍝ Syntax objects<br />
<span style="color:blue;">➥</span>LBC LBK LNR LP MF MOP MOPN MR NAM NF NNR NR NVAL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;⍝ Syntax objects<br />
<span style="color:blue;">➥</span>RBC RBK RP SA SEMI SOS SP SPA SPD SPDN SPDR SPF SPFR SPHR&nbsp;⍝ Syntax objects<br />
<span style="color:blue;">➥</span>SPHY SPM SPMN SPMR SPNF SRBK SYNR SYSN UNK VALR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;⍝ Syntax objects<br />
</apll>


==Shortcut Keystrokes for Editing==
==Shortcut Keystrokes for Editing==

Revision as of 15:01, 7 July 2016

The session manager in NARS2000 provides a wide variety of techniques to perform common tasks.

  • The Session manager window consists of a mixture of input and output.
  • Input typically starts after a six space indent, output typically appears starting at the left edge.
  • Both input and output are subject to editing and re-execution.
  • The cursor may move about the screen changing text as desired.
    • If you press Enter on a line, the original text of that line is restored, the changed line is copied to a new line at the bottom of the screen buffer and executed.
    • If you press Ctrl-Enter on a line, the original text of that line is restored, the changed line is copied to a new line at the bottom of the screen buffer but is not executed — instead it may be further edited before pressing Enter and executed.
    • If you press Shift-Enter on a line, a new physical line is inserted on the screen immediately below the original line and starts with a Line Continuation marker (by default, '' — U+27A5). If Shift-Enter is pressed while the text cursor is in the middle of a line, the line is split in two at that point. To undo this action use the Backspace key at the start of the new line or the Delete key at the end of the preceding line. This action changes the number of physical lines, but not the number of logical lines.
    • The default Line Continuation marker may be changed by going to "Edit | Customize..." then selecting "User Preferences" and then "Line Continuation".
    • Multiple adjacent continued lines form a block which is treated as a single logical line.
    • If you press Enter on any line in a block, the block is copied to the bottom of the screen buffer and executed. If the block is already at the end of the buffer, the block is not copied; instead it is just executed.
    • If you press Ctrl-Enter on any line in a block, the block is copied to the bottom of the screen buffer but it is not executed — instead it may be further edited before pressing Enter and then executed. If the block is already at the end of the buffer, the block is not copied and not executed — in this case, Ctrl-Enter has no effect.

For example,

       f←{
⍺ ⍝ Left arg
+ ⍝ Function
⍵ ⍝ Right arg
}
       3 f 5
8
       h←{s←(+/⍵)÷2
⋄ √×/s-0,⍵ ⍝ Heron's formula for triangle area
}

The above example (starting with h←) also illustrates how to create a multi-statement anonymous function or operator (AFO) with comments, where separate physical lines form a single logical line. Note that this is different from a multi-line AFO where separate physical lines form separate logical lines — we don't support that in Session Manager Editing, but we do in Function Editing. In particular, a statement with continued lines is still a single logical line (minus the comments which are handled specially). If a subsequent continued line does not start with a statement separator, then it is a continuation of the previous statement (as in the example above starting with f←), not a new statement.

The only syntax elements that can't be continued to the next line are names and comments — splitting a name in two creates two separate names; splitting a comment in two does not create one continued comment nor does it create two separate comments. Instead use a comment symbol to start each comment on separate physical lines. To create a new statement, use the statement separator ().

Shortcut Keystrokes for Editing

  • Del
  • Shift-Del
  • Ctrl-Del
  • Ins
  • Shift-Ins
  • Ctrl-Ins
  • Home
  • Shift-Home
  • Ctrl-Home
  • End
  • Shift-End
  • Ctrl-End
  • Up
  • Shift-Up
  • Ctrl-Up
  • Down
  • Shift-Down
  • Ctrl-Down
  • Left
  • Shift-Left
  • Ctrl-Left
  • Right
  • Shift-Right
  • Ctrl-Right
  • PgDn
  • Shift-PgDn
  • Ctrl-PgDn
  • PgUp
  • Shift-PgUp
  • Ctrl-PgUp