Get Dyalog version information in function

General APL language issues
Post Reply
bilekflo
Posts: 28
Joined: Wed Mar 12, 2014 10:07 pm

Get Dyalog version information in function

Post 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
User avatar
AndyS|Dyalog
Posts: 263
Joined: Tue May 12, 2009 6:06 pm

Re: Get Dyalog version information in function

Post 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 !
petermsiegel
Posts: 159
Joined: Thu Nov 11, 2010 11:04 pm

Re: Get Dyalog version information in function

Post 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 
bilekflo
Posts: 28
Joined: Wed Mar 12, 2014 10:07 pm

Re: Get Dyalog version information in function

Post 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
Post Reply