System Function ES

From NARS2000
Jump to navigationJump to search

Quad ES - Event Simulate - ⎕ES     System Function

Event Simulate [with either Error Message(⎕EM) or Event Type(⎕ET)] - for debugging, user alerts, detailed at-length error messaging purposes.

Monadic Function

⎕ES R
R may frequently be one of three distinct Cases: 1) Simple character scalar or vector; 2) Simple two-item vector of integers, 'normally' between -32767 and 32767; or 3) An empty vector.
⎕ES does not have a Z type return argument. It's effect on the APL interpreter is to show on the user's display, certain debugging information, depending on how the call to ⎕ES was made.


Quad ES ⎕ES Event Simulate - sample monadic use/user session(with comments using ⍝ symbol):

      ⎕VR 'ErrorSim'  ⍝Virtual representation of user-function ErrorSim. It has one right argument, A.
    ∇ ErrorSim A
[1]   ⍝Simulate an error.  If the test (next line, just below) inside the parentheses evaluate to True then Event IS simulated.
[2]   ⎕ES(0=A)/'ZERO INVALID'  ⍝Event Simulate occurs here, if A=0 then a user/SysOp error message will appear(in System Variable ⎕EM).
[3]   '⎕ET(Event Type) = ',⎕ET   ⍝ ⎕ES frequently affects sys var quad Event Type ⎕ET, although not presently in NARS.
[4]   '⍴⎕EM(Error Message) = ',(⍴⎕EM),'  ⎕EM:'   ⍝ ⎕EM IS affected in NARS - IF the Error Condition evaluate to True(1).
[5]   ⎕EM
    ∇ 2015 2 20 22 31 5 647 (UTC)

      ErrorSim 45     ⍝ <<< In this event simulation(user types in ErrorSim 45), there should be NO EFFECT since 45 is not equal to 0.
⎕ET(Event Type) =  0 0  ⍝ As mentioned ⎕ET remains unaffected = {0 0}
⍴⎕EM(Error Message) =  3 0   ⎕EM:   ⍝ Since there was NO error(no event simulation) ⎕EM is also unaffected - it has 3 empty rows(0 cols).

      ErrorSim 0    ⍝ <<< In this event simulation(user types in ErrorSim 0); there SHOULD BE an EFFECT; A = 0 (test evaluates to True).
ZERO INVALID        ⍝ Sure enough, the Error Message ⎕EM is returned by NARS/APL with ⎕EM = 'ZERO INVALID'
      ErrorSim 0    ⍝ Normally APL would also return the user-function line number which 'failed' here ⎕ES returns zero.
      ∧
      ⎕EM          ⍝ Sure enough, ⎕EM when typed in by user, shows the most recent simulated error message from ⎕ES.
ZERO INVALID    
      ErrorSim 0
      ∧         
      ⎕ET          ⍝ Also note that ⎕ET was not affected even though in some APL implementations ⎕ES can/will affect ⎕ET.
0 0

When is ⎕ES useful?

  • You want to specifically get the user's attention when a certain error, input error, or other frequent error condition can/could occur.
  • You want to show a More Detailed Error Message when a known error occurs.
  • You are debugging a certain area of APL user-function code and want to test simulating the error condition(s).
  • Since program/code suspension occurs at the CALLING POINT, not within the defined operation/user function per se, it translates to more focus on the input or arguments which may have caused/triggered the event to occur.
  • It can be used, for example, to generate various return codes on system resource limitations encountered, see ⎕ET.

Dyadic Function

Not Currently Documented - Although Dyadic Event Simulate ⎕ES Use is implemented in some APL versions.


Note: ⎕ES is available as both a monadic and dyadic form system function, you cannot assign a value to it.

System Variables (A value may be assigned to these except for ⎕DM)
⎕ALX ⎕CT ⎕DM ⎕DT ⎕ELX ⎕FC ⎕FEATURE ⎕FPC ⎕IC ⎕IO
⎕LR ⎕LX ⎕PP ⎕PR ⎕PW ⎕RL ⎕SA ⎕WSID
Niladic System Functions (a value cannot be assigned to these)
⎕A ⎕AV ⎕EM ⎕ET ⎕LC ⎕NNAMES ⎕NNUMS ⎕SI ⎕SYSID ⎕SYSVER
⎕T ⎕TC ⎕TCBEL ⎕TCBS ⎕TCESC ⎕TCFF ⎕TCHT ⎕TCLF ⎕TCNL ⎕TCNUL
⎕TS ⎕WA
Monadic or dyadic system functions (a value cannot be assigned to these)
⎕AT ⎕CR ⎕DC ⎕DFT ⎕DL ⎕DR ⎕EA ⎕EC ⎕ERROR ⎕ES
⎕EX ⎕FMT ⎕FX ⎕MF ⎕NAPPEND ⎕NC ⎕NCREATE ⎕NERASE ⎕NINFO ⎕NL
⎕NLOCK ⎕NREAD ⎕NRENAME ⎕NREPLACE ⎕NRESIZE ⎕NSIZE ⎕NTIE ⎕NUNTIE ⎕STOP ⎕TF
⎕TRACE ⎕UCS ⎕VR
Note that quad functions and variables (except for the ⎕A family of functions) are case insensitive


See Also
System Commands System Variables and Functions Operators


Keyboard
A+S ⍪ ≡ ≢ ⍒ ⍋ ⌽ ⍉ ⊖ ⍟ ⍱ ⍲ ⍠ ⌹
Alt ⋄ ¨ ¯ < ≤ ∅ ≥ > ≠ ∨ ∧ × ÷
Sh ~ ! @ # $ % ^ & * ( ) _ +
Key ` 1 2 3 4 5 6 7 8 9 0 - =
A+S ⍷ √ ⍨ ⍸ ⍥ ⍣ ⍞ ⍬ ⊣
Alt ? ⍵ ∊ ⍴ § ↑ ↓ ⍳ ○ π ← → ⊢
Sh Q W E R T Y U I O P { } |
Key q w e r t y u i o p [ ] \
A+S ∫ ∂ ⌻ ⍢ ⍙ ⍤ ⍫ ⌷
Alt ⍺ ⌈ ⌊ ∞ ∇ ∆ ∘ ‼ ⎕ ⍎ ⍕
Sh A S D F G H J K L : "
Key a s d f g h j k l ; '
A+S ⊆ ⊇ χ ⍡ ⍭ ⊙
Alt ⊂ ⊃ ∩ ∪ ⊥ ⊤ ⍦ ⍝ ⍀ ⌿
Sh Z X C V B N M < > ?
Key z x c v b n m , . /
{{#ifeq:0|4||title="match" style="border-width:thick; border-color:blue; background-color:yellow;"|≡ {{#ifeq:0|7||title="iota" style="border-width:thick; border-color:blue; background-color:yellow;" |⍳ {{#ifeq:0|9||title="slash" style="border-width:thick; border-color:blue; background-color:yellow;" |/ {{#ifeq:0|11||title="diamond" style="border-width:thick; border-color:blue; background-color:yellow;" |⋄ {{#switch: 0
NARS 2000 Lang
Tool
Bar

{{#ifeq:0|1||title="assign" style="border-width:thick; border-color:blue; background-color:yellow;" |←

→ bgcolor=cyan title="assign" |← → }}

{{#ifeq:0|2||title="plus" style="border-width:thick; border-color:blue; background-color:yellow;" |+

- × ÷ * ⍟ ⌹ ○ ! ? √ bgcolor=cyan title="plus" |+ - × ÷ * ⍟ ⌹ ○ ! ? √ }}

{{#ifeq:0|3||title="mod" style="border-width:thick; border-color:blue; background-color:yellow;" ||

⌈ ⌊ ⊥ ⊤ ⊣ ⊢
⌈ ⌊ ⊥ ⊤ ⊣ ⊢
≢ < ≤ = ≥ > ≠ bgcolor=cyan title="match" |≡ ≢ < ≤ = ≥ > ≠ }}

{{#ifeq:0|5||title="down caret" style="border-width:thick; border-color:blue; background-color:yellow;" |∨

∧ ⍱ ⍲ bgcolor=cyan title="down caret" |∨ ∧ ⍱ ⍲ }}

{{#ifeq:0|6||title="take" style="border-width:thick; border-color:blue; background-color:yellow;" |↑

↓ ⊂ ⊃ ⌷ ⍋ ⍒
↓ ⊂ ⊃ ⌷ ⍋ ⍒
∊ ⍸ ⍷ ∪ ∩ ⊆ ⊇ ~ § π .. bgcolor=cyan title="iota" |⍳ ∊ ⍸ ⍷ ∪ ∩ ⊆ ⊇ ~ § π .. }}

{{#ifeq:0|8||title="comma" style="border-width:thick; border-color:blue; background-color:yellow;" |,

⍪ ⍴ ⌽ ⊖ ⍉
⍪ ⍴ ⌽ ⊖ ⍉
\ ⌿ ⍀ ⊙ ¨ ⍨ ⍤ ⍡ ⍥ ⍦ . ∘ ⍠ ‼ ⌻ ∂ ∫ bgcolor=cyan title="slash" |/ \ ⌿ ⍀ ⊙ ¨ ⍨ ⍤ ⍣ ⍡ ⍥ ⍦ . ∘ ⍠ ‼ ⌻ ∂ ∫ }}

{{#ifeq:0|10||title="quotequad" style="border-width:thick; border-color:blue; background-color:yellow;" |⍞

⎕ ⍎ ⍕
⎕ ⍎ ⍕
⍝ ∇ ∆ ⍙ _ ⍺ ⍵ bgcolor=cyan title="diamond" |⋄ ⍝ ∇ ∆ ⍙ _ ⍺ ⍵ }}

{{#ifeq:0|12||title="neg" style="border-width:thick; border-color:blue; background-color:yellow;" |¯

⍬ ∞ title="neg" |¯ ⍬ ∞ ∅
colspan=8 |Second Row i j k a b e g p r v x z colspan=8 |Second Row i j k a b e g p r v x z colspan=8 |Second Row i j k a b e g p r v x z colspan=6 |Second Row i j k i j k l g p r v x

}}

{{#ifeq:0|0| |}}