netVaria

Overview

This Wiki is about sharing snippets of Dyalog Apl code that are useful when using .Net

.Net version installed

GetNetVersion is used for detecting the .Net version installed on the computer.

 v←GetNetVersion;DI;dir;dirs;⎕USING
 ⍝ Function to Get the Latest .Net Framework Installed on this Computer

 ⍝ Based on: http://msdn.microsoft.com/en-us/library/y549e41e.aspx 
 ⍝ v = Latest Version Installed
 ⍝ v = 0, When There is no Version of .Net Installed

 :Trap 0
     ⎕USING←'System,mscorlib.dll' 'System.IO,mscorlib.dll'
     dir←Environment.ExpandEnvironmentVariables(⊂'%WINDIR%\Microsoft.NET\Framework')
     DI←⎕NEW DirectoryInfo(⊂dir)             ⍝ Get the DirectoryInfo Object for the Directory
     dirs←DI.GetDirectories(⊂'v*')           ⍝ v* is the filter
     dirs←1↓¨dirs.Name                       ⍝ To remove the letter 'v' at the beginning of each directory
     v←+/¨(⊂1 0.1)ר2↑¨⊃¨(//¨'.'⎕VFI¨dirs)   ⍝ To Add the first 2 numbers of each directory
     v←1↑∪v[⍒v]                              ⍝ To order the directory names as numbers and return the highest number
 :Else
    ⍝ There is no .Net installed
     v←0
 :EndTrap

Clear the Application Domain

CloseAppDomain is the equivalent to File --> CloseAppDomain. It is used to remove the dll loaded in the memory of the interpreter. Usefull when experimenting with .Net.

 CloseAppDomain
⍝ To erase all the loaded dll from memory.
 'Closing AppDomain...'
 1 ⎕NQ'⎕SE.mb.file.closead' 'Select'
 'AppDomain Closed'

CategoryDyalogDotNetUtilities