PFKEY - Programming

Learning APL or new to Dyalog? Ask "silly" questions here, without fear...

PFKEY - Programming

Postby Leo on Thu Mar 22, 2018 2:48 pm

Hello APL user,

a little problem:
Analogous to the example
      Garbage ← ('2 + 2', ⊂'ER ') ⎕PFKEY 3
in "Mastering Dyalog APL " by Bernard Legrand (page 492)
I tried to set the commands )RESET and )SAVE on ⎕PFKEY 4 with the following command:
      PF4 ← (') RESET', ⊂ ') SAVE') ⎕PFKEY 4

The above command does not work.
Where is the mistake?

Best regards
Leo
Leo
 
Posts: 38
Joined: Mon Sep 18, 2017 12:10 pm

Re: PFKEY - Programming

Postby Phil Last on Thu Mar 22, 2018 11:50 pm

The left argument must be a mixture of simple strings with enclosed codes.
What you appear to want is:
      (')RESET',(⊂'ER'),')SAVE ')⎕pfkey 4
which will issue the )RESET command and leave ")SAVE " highlighted on the last line of the session awaiting either a workspace path or just [enter]. I should recommend against including a final [enter] as
      (')RESET',(⊂'ER'),')SAVE ',⊂'ER')⎕pfkey 4
because it's not difficult to hit the wrong function key and accidentally save when you really don't want to.

Also, if the additional blanks in your expression were deliberate, you should know that system commands in Dyalog, unlike some other APLs, do not permit blanks between the right parenthesis and the command name.
User avatar
Phil Last
 
Posts: 628
Joined: Thu Jun 18, 2009 6:29 pm
Location: Wessex

Re: PFKEY - Programming

Postby Leo on Sat Mar 24, 2018 10:01 am

Hello Phil,
Many thanks for the quick answer.
The command
      (') RESET', (⊂'ER '),') SAVE ') ⎕PFKEY 4
works as desired. Many Thanks!
But
      '[1.5]' ⎕PFKEY 24
returns the error message
      [1.5]
SYNTAX ERROR
[1.5]
Why?

best regards
Leo
Leo
 
Posts: 38
Joined: Mon Sep 18, 2017 12:10 pm

Re: PFKEY - Programming

Postby Adam|Dyalog on Sun Mar 25, 2018 7:20 am

Because [1.5] is not valid syntax by itself. I can only think of two very specific contexts when it is valid:

Laminate: Insert new axis between [1] and [2], e.g. RankNarray1,[1.5]RankNarray2

∇ editor: Insert new line between [1] and [2], e.g. [1.5]New line 1.5
User avatar
Adam|Dyalog
 
Posts: 143
Joined: Thu Jun 25, 2015 1:13 pm

Re: PFKEY - Programming

Postby AndyS|Dyalog on Mon Mar 26, 2018 8:12 am

Hi Leo

Just to be clear, did you get the SYNTAX ERROR when you attempted to run
      '[1.5]'⎕pfkey 24

?

If so, then I suspect that you may have managed to get either a non-printing character or a character that appears to be space (⎕ucs 32) in front of '[1.5]' in the session.

If you still have that line in your session, I suggest selecting the entire line (from the leftmost column) and pasting the text into a variable, and then calling
      ⎕ucs varname

and see if there are any values less than 32 in it.
User avatar
AndyS|Dyalog
 
Posts: 263
Joined: Tue May 12, 2009 6:06 pm

Re: PFKEY - Programming

Postby Leo on Mon Mar 26, 2018 3:03 pm

Hello Adam, Hello Phil,

Many thanks for your help!
Unfortunately, I did not understand how to implement the hints.
I've tried a lot, but nothing works as it should.
Nevertheless, the topic is important to me, because with the PFKEYS you can make your work easier. Therefore, I allow myself to ask again.

Lines 20, 21 and 22 show a part of the program with which I programmed the PFKEYS. Lines 21 and 22 work!
Line 20 is faulty.
      [20]   ('[1.5]',⊂'ER')⎕PFKEY 2
[21] ')SI'⎕PFKEY 3
[22] (')RESET',(⊂'ER'),')SAVE')⎕PFKEY 4

A check with ⎕UCS provides the result
      ⎕UCS'[1.5]'⎕PFKEY 2
91 49 46 53 93

where all values are> 32.

Best regards
Leo
Leo
 
Posts: 38
Joined: Mon Sep 18, 2017 12:10 pm

Re: PFKEY - Programming

Postby Adam|Dyalog on Mon Mar 26, 2018 3:34 pm

Don't worry about bothering us. We want to help.

It is unclear to me what you want your F2 button to do. It looks like you make it type "[1.5]" and then press Enter, which as I wrote earlier is only valid in very specific contexts. Is this really what you want?

You write that "Line 20 is faulty." Can you be more specific? In what way does it fail? Does APL stop with an error on that line? Does the key not cause the button presses you expect? Or any button presses? In what context do you press F2? Under program control? In a form? In the session?
User avatar
Adam|Dyalog
 
Posts: 143
Joined: Thu Jun 25, 2015 1:13 pm

Re: PFKEY - Programming

Postby Leo on Tue Mar 27, 2018 11:05 am

Dyalog APL Version: 16.0.31693.0 64 Unicode

Hello Adam,

What I want?
I am relative new to APL. Against languages such. B. Fortran 4 (I belong to the "old" semesters!), I like the short syntax.
My APL problem: - the key search.
My wish: - often occurring syntax sequences such e.g "[1.5]" to lay on PFKEYS.

The following function "Starter", which I programmed, starts automatically when opening the respective workspace and sets the PFKEYS.
      ∇ Starter
[1] ' '
[2] ⍝ Automatischer Start mit: ⎕LX ← 'Starter'
[3] ⍝ Kopieren in andere Workspace: )COPY "D:\DyalogAPL\ws\JBR7" Starter
[4] WSID←⎕WSID ⋄ WSID,'.DWS ------------------- Start-Function: Starter'
[5] ⍝ Speicherplatz, Datum und Zeit:
[6] DA←(2 0⍕⎕TS[3]),'.',(2 0⍕⎕TS[2]),'.',(4 0⍕⎕TS[1]) ⍝ Datum
[7] UH←(3 0⍕⎕TS[4]),':',(2 0⍕⎕TS[5]),':',(2 0⍕⎕TS[6]),'/'(3 0⍕⎕TS[7]) ⍝ Uhrzeit
[8] ' Workspace Size= ',(9 0⍕⎕WA),(' [kB] ************ '),DA,(5⍴' ****'),UH
[9] ' ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯'
[10] '[1.5]'⎕PFKEY 2
[11] ')SI'⎕PFKEY 3
[12] (')RESET',(⊂'ER'),')SAVE')⎕PFKEY 4
[13] ')CONTINUE'⎕PFKEY 5
[14] ')OUT'⎕PFKEY 6
[15] ')COPY'⎕PFKEY 7
[16] ')LIB'⎕PFKEY 8
[17] ')CLEAR'⎕PFKEY 9
[18] ')FNS'⎕PFKEY 10
[19] ')LOAD'⎕PFKEY 11
[20] 'DISPLAY'⎕PFKEY 12
[21] 'Shift+Delete'⎕PFKEY 13
[22] 'Control+Insert'⎕PFKEY 14
[23] 'Shift+Insert'⎕PFKEY 15
[24] ')ERASE'⎕PFKEY 19
[25] ')IN'⎕PFKEY 20
[26] ')VARS'⎕PFKEY 22

If I press "PFKEY 2" the error message appears:
      [1.5]
SYNTAX ERROR
[1.5]

My question: Why does the PFKEY 2 command (line 20) not work?

Thanks again for the help!

best regards
Leo
Leo
 
Posts: 38
Joined: Mon Sep 18, 2017 12:10 pm

Re: PFKEY - Programming

Postby Adam|Dyalog on Wed Mar 28, 2018 9:07 am

Hi Leo,

I have a few tips for you.


Initialise settings upon start-up
Change the name of your "Starter" function to "Setup" and then run:
      ⎕SE.SALT.Save 'Setup ',⎕SE.SALTUtils.USERDIR,'MyUcmds\ -makedir'

It should then run whenever APL starts — no matter which workspace you're using.


Issues with [1.5]
      '[1.5]'⎕PFKEY 2
looks fine, however the code you wrote previously was
      ('[1.5]',⊂'ER')⎕PFKEY 2
which is problematic as it presses Enter after typing "[1.5]", and that's probably not desirable.

I don't know what you use [1.5] for, but you may want to look into monadic ↑ and/or the full-screen )ED editor.


DISPLAY
If you find yourself needing DISPLAY more often than not, consider turning "Boxing" on:
      ⍳2 3
1 1 1 2 1 3
2 1 2 2 2 3
]box on -style=max
┌→─────────────────┐
│Was OFF -style=min│
└──────────────────┘
⍳2 3
┌→──────────────────┐
↓ ┌→──┐ ┌→──┐ ┌→──┐ │
│ │1 1│ │1 2│ │1 3│ │
│ └~──┘ └~──┘ └~──┘ │
│ ┌→──┐ ┌→──┐ ┌→──┐ │
│ │2 1│ │2 2│ │2 3│ │
│ └~──┘ └~──┘ └~──┘ │
└∊──────────────────┘


Cut, Copy, Paste
I'm unsure what you are trying to achieve with the three lines:
      'Shift+Delete'⎕PFKEY 13     
'Control+Insert'⎕PFKEY 14
'Shift+Insert'⎕PFKEY 15

In either case, know that you can assign (additional) custom shortcuts to these actions in Options>Configure...>Keyboard Shortcuts under the Codes CT, CP, and PT. (Optionen>Konfigurieren... if you are using a German session.)


)IN and )OUT
Dyalog APL does not have these system commands, but we do provide alternatives in the form of ]In and ]Out. Note the square brackets in place of the round parentheses.


I hope this helps. Please do not hesitate to ask for more help.
User avatar
Adam|Dyalog
 
Posts: 143
Joined: Thu Jun 25, 2015 1:13 pm

Re: PFKEY - Programming

Postby Leo on Fri Apr 06, 2018 9:14 am

Hello Adam,

Thanks a lot for the tips!!!

First of all, the reference to SALT
      ⎕SE.SALT.Save 'Setup ',⎕SE.SALTUtils.USERDIR,'MyUcmds\ -makedir'
shows, that it is useful to deal with this topic.

Best regards
Leo
Leo
 
Posts: 38
Joined: Mon Sep 18, 2017 12:10 pm


Return to New to Dyalog?

Who is online

Users browsing this forum: No registered users and 1 guest