Page 1 of 1
Get Dyalog version information in function
Posted: Fri Jul 28, 2023 1:08 pm
by bilekflo
Dear all,
Is there a way to get the information from ]version in a function. I would like to know at runtime at which OS I am running on.
Kind regards,
Florian
Re: Get Dyalog version information in function
Posted: Sat Jul 29, 2023 8:40 am
by AndyS|Dyalog
That is an interesting question !
At the simplest level you can look
3↑⊃'.'⎕wg'APLVersion'
which will tell you what O/S you're running on: Win, Lin, AIX, Mac.
However it doesn't differentiate between, for example, Linux on x86 and Linux on Arm. The following snippet of code attempts to do this (it's from NonWindows.Setup in the supplied quadna workspace):
:Select 3↑⊃'.'⎕WG'APLversion'
:Case 'AIX'
opsys←'AIX'
:Case 'Mac'
opsys←'Mac'
:Case 'Win'
opsys←'Windows'
:Case 'Lin'
:Select 4↑⊃⎕SH'uname -a'
:Case 'armv'
opsys←'Pi'
:Else
opsys←'Linux'
:EndSelect
:EndSelect
⍝
apledition←⊃(80=⎕DR' ')↓'Classic' 'Unicode'
aplwidth←{z←⍵ ⋄ 2×⍬⍴⎕SIZE'z'}⍬
However, that I now realise has its limitations: on macOS it doesn't distinguish between running on Intel-based Macs or ARM-based Macs under Rosetta (or for the future, a native ARM-based Dyalog running on ARM).
However, let's cross that bridge when we come to it. I'd go with the code above, but make sure that it's in a cover function: watch this space for a possible better solution to this !
Re: Get Dyalog version information in function
Posted: Sun Jul 30, 2023 4:31 am
by petermsiegel
Of course, you can do this (which may not be recommended):
Code: Select all
capture← ⎕SE.UCMD'Version' ⍝ Execute an arbitrary user command
capture
which produces (on a system in a galaxy far away):
Code: Select all
Dyalog 18.2.45405 64-bit Unicode, BuildID a02bc166
OS Darwin 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:22 PDT 2023; root:xnu-8796.121.3~7/RELEASE_X86_64
Link 3.0.19
SALT 2.9
UCMD 2.51
.NET .NET Core 3.1.5
WS 18.2
Re: Get Dyalog version information in function
Posted: Tue Aug 01, 2023 7:32 pm
by bilekflo
Hi Andy,
Great. Thank you for this interesting solution.
I needed it to decide how to issue some correct system commands.
Best regards
Florian