Scripting Dyalog

General APL language issues

Scripting Dyalog

Postby paulmansour on Fri May 22, 2020 12:42 pm

The question: how do I modify the below function to make it asynchronous and have a window? That is, I want to launch a new APL session, feed it stuff to enter and execute in the session, and then leave it up so I can see it and interact with it. I really have no idea how to do this.

In the version below, there is no window, and whether or not an explicit )Off is issued, the process terminates.

Here is the function, which I developed a while back, with much help from Stefano and Gil:

      ExecuteAPL←{
⍝ ⍺ ←→ Command Line Arguments e.g.: '-b maxws=1g default_io=1'
⍝ ⍵ ←→ One or more expressions to execute
⍝ ← ←→ Exit Code, Session Output
⍺←'ShowStatusOnError=0'
in←∊(⊆⍵),¨⎕UCS 13
⎕USING←'System'∘,¨'' '.IO' '.Diagnostics,System.dll'
p←⎕NEW Process
i←p.StartInfo
i.FileName←2 ⎕NQ'.' 'GetCommandLine'
i.Arguments←⍺
i.RedirectStandardOutput←1
i.RedirectStandardInput←1
i.RedirectStandardError←1
i.UseShellExecute←0
_←p.Start ⍬
sw←⎕NEW StreamWriter p.StandardInput.BaseStream
op←{6::0 ⋄ ⍺⍺ ⍵}
_←sw.Write op⊂in
_←{6::0 ⋄ z←sw.Close}0
r←⎕NS''
sr←⎕NEW StreamReader p.StandardError.BaseStream
r.SessionOutput←sr.ReadToEnd
_←p.WaitForExit op ⍬
r.ExitCode←p.ExitCode
r
}


For example:

      R←ExecuteAPL  ']box on' 'V←⍳10' ']Display ⊂V'  '⎕OFF'
R.ExitCode
0
R.SessionOutput
Dyalog APL/W-64 Version 17.0.34173
Serial No : 000360
Unicode Edition
Fri May 22 08:36:24 2020
Was OFF

┌───────────────────────┐
│ ┌→──────────────────┐ │
│ │0 1 2 3 4 5 6 7 8 9│ │
│ └~──────────────────┘ │
└∊──────────────────────┘
paulmansour
 
Posts: 420
Joined: Fri Oct 03, 2008 4:14 pm

Re: Scripting Dyalog

Postby paulmansour on Wed May 27, 2020 1:48 pm

Norbert has researched this, and apparently it is not possible. UseShellExecute must be 0 in order redirecting input and output, and you can't get a window unless UseShellExecute is 1.
paulmansour
 
Posts: 420
Joined: Fri Oct 03, 2008 4:14 pm


Return to Language

Who is online

Users browsing this forum: No registered users and 1 guest