Skip to content

Commit 76daa84

Browse files
committed
Method QEM added and important bug fix
1 parent 73edf08 commit 76daa84

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+114
-298
lines changed

APLSource/EventCodes-21.aplc renamed to APLSource/EventCodes.aplc

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
:Class EventCodes
22
⍝ This class carries all trappable event codes in Dyalog APL up to -- and including -- version 17.0.\\
3-
⍝ For transforming a number to the symbolic name see function `GetName`.
3+
⍝ For transforming a number to the symbolic name see function `GetName`.\\
4+
⍝ Instead of using `⎕EM` you can use `QEM`: fed with an integer it behaves exactly as `⎕EM`. Fed with an error message
5+
⍝ it transforms this error message into the error code. If the error is unknwon
46

57
⎕IO←1 ⋄ ⎕ML←1
68

@@ -60,15 +62,16 @@
6062

6163
∇ r←Version
6264
:Access Public Shared
63-
r←({⍵}⍕⎕THIS)'1.3.0.1.1' '2018-10-25'
65+
r←({⍵}⍕⎕THIS)'1.4.0.13' '2019-11-06'
6466
6567

6668
∇ History
6769
:Access Public Shared
68-
⍝ * 1.3.0
69-
⍝ * `List` now excepts a left argument: '' (the default) results in the matrix being sorted
70-
⍝ by symbolic name. `⍬` results in it being sorted by number.
71-
⍝ * Bug fix: `List` crashed on a right argument `⍬`.
70+
⍝ * 1.4.0
71+
⍝ * Method `QEM` added. Accepts either a positive integer (same as `⎕EM`) or a character vector
72+
⍝ (error message). In the latter case the error number is returned or, if the error message
73+
⍝ is unknown, and error is thrown.
74+
⍝ * Bug fix: `List` crashed when sorting by number was required.
7275
⍝\\
7376
⍝ For information regarding older versions see <https://github.com/aplteam/EventCodes/releases>
7477
@@ -78,10 +81,10 @@
7881
⍝ * If the right argument is a scalar or a one-element vector then a text vector is returned.
7982
⍝ * If the right argument is a vector then a vector of text vectors is returned.
8083
:Access Public Shared
81-
:If 0∊⍴__eventCode
84+
:If 0=≢__eventCode
8285
__name←''
8386
:Else
84-
__allNumbers←⎕NL-2
87+
__allNumbers←' '~¨⍨↓⎕NL 2
8588
__allNumbers←⍎¨('__'∘≢¨2↑¨__allNumbers)/__allNumbers
8689
__ind←__allNumbers⍳__eventCode
8790
'Unknown event number'⎕SIGNAL 6/⍨__ind∨.>⍴__allNumbers
@@ -90,6 +93,36 @@
9093
:EndIf
9194
9295

96+
∇ __r←QEM __y;__list;__bool
97+
⍝ In case `y` is an integer `r` becomes the associated error message.\\
98+
⍝ In case `y` is a character vector r becomes the associated error number.\\
99+
⍝ If a provided error message is unknown `⍬` is returned. If `y` is empty `r` is empty.
100+
:Access Public Shared
101+
:If 0=1↑0⍴∊__y
102+
:If 0=≢__y
103+
__r←''
104+
:Else
105+
__list←List''
106+
:If 1≠+/__bool←__y=__list[;2]
107+
'Unknown error number'⎕SIGNAL 11
108+
:Else
109+
__r←1⊃__list[__bool⍳1;]
110+
:EndIf
111+
:EndIf
112+
:Else
113+
:If 0=≢__y
114+
__r←⍬
115+
:Else
116+
__list←List''
117+
:If 1≠+/__bool←__y∘≡¨__list[;1]
118+
'Unknown error message'⎕SIGNAL 11
119+
:Else
120+
__r←2⊃__list[__bool⍳1;]
121+
:EndIf
122+
:EndIf
123+
:EndIf
124+
125+
93126
∇ __allNumbers←{__sortType}List __start
94127
⍝ Returns a matrix with all symbolic names and their numbers in case `__start` is empty.\\
95128
⍝ In case `__start` is not empty only the symbolic names that start with `__start` are listed.\\
@@ -100,17 +133,17 @@
100133
:If 0=⎕NC'__sortType'
101134
__sortType←''
102135
:EndIf
103-
__allNumbers←⎕NL-2
136+
__allNumbers←' '~¨⍨↓⎕NL 2
104137
__allNumbers←('__'∘≢¨2↑¨__allNumbers)/__allNumbers
105138
__allNumbers←__allNumbers,[1.5]⍎¨__allNumbers
106139
:If ''≡__sortType
107-
__allNumbers←__allNumbers[⍋__allNumbers[;1];]
140+
__allNumbers←__allNumbers[⍋__allNumbers[;1];]
108141
:ElseIf ⍬≡__sortType
109142
__allNumbers←__allNumbers[⍋__allNumbers[;2];]
110143
:Else
111144
'Invalid sort type: either '''' (alpha) or ⍬ (numeric)'⎕SIGNAL 11
112145
:EndIf
113-
:If ~0∊⍴__start←{1(819⌶)⍕⍵}__start~'*'
146+
:If 0≠≢__start←{1(819⌶)⍕⍵}__start~'*'
114147
__allNumbers←(((⍴,__start)↑[2]↑__allNumbers[;1])∧.=__start)⌿__allNumbers
115148
:EndIf
116149

APLSource/TestCases-11/E-1.aplf

Lines changed: 0 additions & 10 deletions
This file was deleted.

APLSource/TestCases-11/FailsIf-21.aplf

Lines changed: 0 additions & 5 deletions
This file was deleted.

APLSource/TestCases-11/FindSpecialString-811.aplf

Lines changed: 0 additions & 11 deletions
This file was deleted.

APLSource/TestCases-11/G-1.aplf

Lines changed: 0 additions & 8 deletions
This file was deleted.

APLSource/TestCases-11/GoToTidyUp-115.aplf

Lines changed: 0 additions & 10 deletions
This file was deleted.

APLSource/TestCases-11/Initial-1.aplf

Lines changed: 0 additions & 3 deletions
This file was deleted.

APLSource/TestCases-11/L-1.aplf

Lines changed: 0 additions & 17 deletions
This file was deleted.

APLSource/TestCases-11/ListHelpers-11.aplf

Lines changed: 0 additions & 18 deletions
This file was deleted.

APLSource/TestCases-11/PassesIf-41.aplf

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)