How to )XLOAD (⎕XLOAD) under program control

APL-related discussions - a stream of APL consciousness.
Not sure where to start a discussion ? Here's the place to be
Forum rules
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !

How to )XLOAD (⎕XLOAD) under program control

Postby ray on Sat Aug 28, 2021 9:36 am

Is there a simple way to load a workspace under program control without running the latent expression.

An equivalent of "⎕XLOAD" to ")XLOAD" as "⎕LOAD" is to ")LOAD"

The "-x" option in the APL command line is not an acceptable route.

I have a complicated method (devised in the days of Dyalog version 7, and Windows 3.1) using ")xload" PFkey0 and a simulated key press in the keyboard stack.
This works well under Windows, but I have no equivalent code for Linux. Also it requires "tweaks" with different versions of Windows and Dyalog.

"Why?" you ask.
I use it within some "]UserCommands", dynamically merging workspaces and making backup copies.

(A "-x" option within ⎕LOAD would be great.)

Any suggestions?
Ray Cannon
Please excuse any smelling pisstakes.
User avatar
ray
 
Posts: 192
Joined: Wed Feb 24, 2010 12:24 am
Location: Blackwater, Camberley. UK

Re: How to )XLOAD (⎕XLOAD) under program control

Postby Adam|Dyalog on Sun Aug 29, 2021 6:55 am

As far as I can tell, x-loading a workspace is equivalent to clearing the current one out, and then copying in a new one. This function, which you'll probably want to keep in ⎕SE, should do the trick:
      ∆XLOAD←{
⍺←'⎕LX' '⎕SM' '⎕TRAP' '⎕WSID' '⎕TNAME' '⎕CT' '⎕DIV' '⎕IO' '⎕ML' '⎕PP' '⎕RL' '⎕RTL' '⎕WX' '⎕USING' '⎕AVU' '⎕DCT' '⎕FR'
#.(⎕CY ⍵⊣⍺ ⎕CY ⍵⊣⎕EX ⎕NL-⍳10)
}
User avatar
Adam|Dyalog
 
Posts: 98
Joined: Thu Jun 25, 2015 1:13 pm

Re: How to )XLOAD (⎕XLOAD) under program control

Postby AndyS|Dyalog on Sun Aug 29, 2021 8:39 am

Do you have to )save the workspaces ? Could you 0 ⎕save them instead ?

The interactions between )save and ⎕save and )load and ⎕save are fairly subtle, but are documented ..
User avatar
AndyS|Dyalog
 
Posts: 247
Joined: Tue May 12, 2009 6:06 pm


Return to APL Chat

Who is online

Users browsing this forum: Bing [Bot] and 1 guest