⎕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 3element [mixed, nested] vector. 
Monadic Function
Z←⎕EC R 


"R" is executed, and the result Z is a 3item returned 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 = Simple 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 3element 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