Make a PFKEY (Fnn key) always available in new session?

General APL language issues

Make a PFKEY (Fnn key) always available in new session?

Postby Rav on Fri Dec 01, 2023 2:23 am

I'm using Dyalog APL version 18.2 under Windows. Is there a way, in particular a "best" way, to pre-define a PFKEY (function key) so that it's always available when a new APL session starts? For example, if I want the characters "ABCDE" to be displayed when F9 is pressed, I could enter:

'ABCDE' ⎕PFKEY 9

while in an APL session. But I don't want to have to set the value of F9 every time I start an APL session. I want it to be already set whenever a session starts. I've looked at Options > Configure > Keyboard Shortcuts and don't see any way to set such a thing up there. I've looked at modifying the en-US.din file in the C:\Program Files\Dyalog\UnicodeIME\aplkeys directory, but can't find any documentation on how to set such a thing up there. I thought of using the ⎕SE.onCreate event (which runs when a session starts), but that is already set to call function ⎕SE.Dyalog.Callbacks.SECreate. I can modify that function to add a line to set ⎕PFKEY 9, but that seems somewhat dangerous to be modifying a function that could be changed by Dyalog in the future.

If there is a good way to do this, I'd like it to be something that can be set up under program control within an APL function, not something which would require a user to hand-modify some sort of configuration file.

Thanks for any thoughts / Rav
Rav
 
Posts: 26
Joined: Tue Jul 25, 2023 4:41 pm

Re: Make a PFKEY (Fnn key) always available in new session?

Postby AndyS|Dyalog on Fri Dec 01, 2023 8:48 am

Hi Rav

Your best bet is to create a function called "Setup" (the name is important) along the lines of
      Setup;sink
sink←'ABCDE' ⎕PFKEY 9

and then run
      ⎕SE.SALT.Save 'Setup ',⎕SE.SALTUtils.USERDIR,'MyUcmds\ -makedir'

This will create the (text) file C:\Users\<your username>\Documents\MyUcmds\Setup.dyalog which will be run each time you start Dyalog APL.

You can edit Setup.dyalog as and when you want alter or extend the PFKEY definitions - or since it's just an APL function, do whatever you will when starting Dyalog APL. If you right click on the filename in Windows Explorer you'll be given the option to edit it in the Dyalog editor, but you can use whatever editor you prefer to use.

I assigned the result of ⎕pfkey solely to suppress it.

I can't take credit for most of this .. thanks goes to Adam in his post https://forums.dyalog.com/viewtopic.php?f=12&t=1332#p5332
User avatar
AndyS|Dyalog
 
Posts: 263
Joined: Tue May 12, 2009 6:06 pm

Re: Make a PFKEY (Fnn key) always available in new session?

Postby RichardP|Dyalog on Fri Dec 01, 2023 10:16 am

Just an additional reference. Adám also wrote a blog post:

https://www.dyalog.com/blog/2018/09/enh ... tion-keys/
RichardP|Dyalog
 
Posts: 33
Joined: Fri Oct 12, 2018 3:05 pm

Re: Make a PFKEY (Fnn key) always available in new session?

Postby Rav on Fri Dec 01, 2023 7:55 pm

This is great, thanks. One more question: Can there only be ONE named function, ∇Setup, which will automatically be run when Dyalog APL starts, or can there be others? The reason I ask is that I'm creating ∇Setup under program control, and if there's already one there (that presumably someone else wrote that does other types of setup) I don't want to stomp over it by overwriting it with my ∇Setup. And I'm not sure it would be safe to try to modify (under program control) a ∇Setup that someone else has already written to add what my ∇Setup does. If there's a way to have multiple ∇Setup-type functions that all get run when Dyalog APL starts, then if I detect that there's already an existing ∇Setup program I could just call mine something else. Thanks.
Rav
 
Posts: 26
Joined: Tue Jul 25, 2023 4:41 pm


Return to Language

Who is online

Users browsing this forum: Vince|Dyalog and 1 guest