System Function EC: Difference between revisions

From NARS2000
Jump to navigationJump to search
(created quad EC page)
 
No edit summary
 
Line 1: Line 1:
<h1>{quad}EC - Execute Controlled</h1>
<h1>{quad}EC - Execute Controlled</h1>
{{BoxStart|⎕EC
{{BoxStart|<apll>⎕EC</apll>
| Execute Controlled "for a string expression"}}
| Execute Controlled "for a string expression"}}
{{BoxEnd|Z ← ⎕EC R &nbsp; <i>where argument R is a string expression and returned '''Z''' is a 3-element [mixed, nested] vector.</i>}}
{{BoxEnd|<apll>Z←⎕EC R</apll> &nbsp; where argument <apll>R</apll> is a string expression and returned <apll>Z</apll> is a 3-element [mixed, nested] vector.}}


==Monadic Function==
==Monadic Function==
Line 14: Line 14:
       <td></td>
       <td></td>
       <td></td>
       <td></td>
       <td>"R" is executed, and the result Z is a 3-item returned vector.</td>
       <td><apll>R</apll> is executed, and the result <apll>Z</apll> is a 3-item vector.</td>
     </tr>
     </tr>
     </table>
     </table>
Line 20: Line 20:
</tr>
</tr>
<tr>
<tr>
   <td>R should be a string expression. ⎕EC is frequently used for testing and debugging purposes.</td>
   <td><apll>R</apll> should be a string expression. <apll>⎕EC</apll> is frequently used for testing and debugging purposes.</td>
</tr>
</tr>


</table>
</table>
<br />
<br />
Return codes for Z: Normally, the '''first element''' of the return code (in variable '''Z''') represents an integer in the range 0 to 5, where:<br>
Return codes for <apll>Z</apll>: Normally, the first element of the return code (in variable <apll>Z</apll>) represents an integer in the range 0 to 5, where:<br>
0 = Error<br>
0 = Error<br>
1 = Expression with a result which would display (for debugging purposes this means '''OK''', '''R''' was '''not''' problematic.<br>
1 = Expression with a result which would display (for debugging purposes this means '''OK''', <apll>R</apll> was '''not''' problematic.<br>
2 = Expression with a result which would not display<br>
2 = Expression with a result which would not display<br>
3 = Expression with no explicit result<br>
3 = Expression with no explicit result<br>
4 = Branch to a line<br>
4 = Branch to a line<br>
5 = Simple goto / branch<br><br>
5 = Niladic goto / branch<br><br>
The second item in Z (returned) is the value that would be returned by ⎕ET (quad event type, without altering the current value of ⎕ET). The third item returned is the actual result ('''IF''' one is generated); for return code 3 or 5 the third item is 0 0⍴0; for return code 4 the third item is the argument to the branch; for return code 0 the third item is ⎕EM.
The second item in <apll>Z</apll> (returned) is the value that would be returned by <apll>⎕ET</apll> (quad event type, without altering the current value of <apll>⎕ET</apll>). The third item returned is the actual result ('''IF''' one is generated); for return code 3 or 5 the third item is <apll>0 0⍴0</apll>; for return code 4 the third item is the argument to the branch; for return code 0 the third item is <apll>⎕EM</apll>.
<br><br>
<br><br>


'''Quad Execute Controlled ⎕EC''' sample ''monadic'' calls:
'''Quad Execute Controlled <apll>⎕EC</apll>''' sample ''monadic'' calls:
<pre>
<pre>
       Z←⎕EC 'a÷1'  ⍝ Right argument FAILS(a÷1, because variable "a" does NOT exist).
       Z←⎕EC 'a÷1'  ⍝ Right argument FAILS(a÷1, because variable "a" does NOT exist).
Line 75: Line 75:


<br><br>
<br><br>
See also: '''[[System_Function_EA|⎕EA]]'''<br><br>
See also: [[System_Function_EA|<apll>⎕EA</apll>]]<br><br>


{{System Variables}}
{{System Variables}}
{{Article footer}}
{{Article footer}}

Latest revision as of 19:15, 12 December 2017

⎕EC - Execute Controlled

⎕EC Execute Controlled "for a string expression"
Z←⎕EC R   where argument R is a string expression and returned Z is a 3-element [mixed, nested] vector.

Monadic Function

Z←⎕EC R R is executed, and the result Z is a 3-item vector.
R should be a string expression. ⎕EC is frequently used for testing and debugging purposes.


Return codes for Z: Normally, the first element of the return code (in variable Z) represents an integer in the range 0 to 5, where:
0 = Error
1 = Expression with a result which would display (for debugging purposes this means OK, R was not problematic.
2 = Expression with a result which would not display
3 = Expression with no explicit result
4 = Branch to a line
5 = Niladic goto / branch

The second item in Z (returned) is the value that would be returned by ⎕ET (quad event type, without altering the current value of ⎕ET). The third item returned is the actual result (IF one is generated); for return code 3 or 5 the third item is 0 0⍴0; for return code 4 the third item is the argument to the branch; for return code 0 the third item is ⎕EM.

Quad Execute Controlled ⎕EC sample monadic calls:

      Z←⎕EC 'a÷1'   ⍝ Right argument FAILS(a÷1, because variable "a" does NOT exist).
      ⍴Z
3                   ⍝ Thus a standard 3-element vector has been returned in Z
      Z             ⍝ Let's see what Z looks like:
 0  0 0  VALUE ERROR 
         ⍎     a÷1   
               ∧     
      Z[1]     ⍝ first element in Z is the return code, a zero was generated in this case, indicating an error, as listed above.
0
      Z[2]
 0 0
      Z[3]     ⍝ third element returned in Z is the actual nested string error message.
 VALUE ERROR 
 ⍎     a÷1   
       ∧  
 
      ⍝ A different test with "no problems" example:
      Z←⎕EC '6÷0.5' ⍝ RIGHT argument SUCCEEDS(6÷0.5) because 6 can be divided by 0.5; under normal circumstances the answer would be 12.
      ⍴Z
3
      Z
 1  0 0  12
      Z[1]       ⍝ first element in Z is the return code, a one was generated in this case, indicating no problem, as per the list above.
1                ⍝ again, 1 = success, no problems encountered
      Z[2]
 0 0
      Z[3]
12              ⍝ And Z[3] correctly holds the expected answer.

The Execute Controlled system function normally takes a string as its right argument. In particular the left argument string may normally:

  • call a function
  • jump to a particular label
  • perform ANY allowed APL operation (e.g. addition, multiplication, division, subtraction, floor, ceiling, logic test, etc...)
  • assign/set a value



See also: ⎕EA

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
Alt+Shift
Alt ¨ ¯ < > × ÷
Shift ~ ! @ # $ % ^ & * ( ) _ +
Key ` 1 2 3 4 5 6 7 8 9 0 - =
Alt+Shift
Alt ? § π
Shift Q W E R T Y U I O P { } |
Key q w e r t y u i o p [ ] \
Alt+Shift
Alt
Shift A S D F G H J K L : "
Key a s d f g h j k l ; '
Alt+Shift χ
Alt
Shift Z X C V B N M < > ?
Key z x c v b n m , . /
NARS 2000 Lang
Tool
Bar
+ - × ÷ * ! ? |
< = >
~ § π .. ,
/ \ ¨ .
_ ¯
Second Row i j k i j k l g p r v x

[[Category:Mouse Group {{{1}}}|{{{2}}}]]