Created
March 11, 2016 14:55
-
-
Save eduard93/d4827e4f4acf74ee41a7 to your computer and use it in GitHub Desktop.
Choose namespace at session start
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<Export generator="Cache" version="25"> | |
<Routine name="%ZSTART" type="MAC" languagemode="0"><![CDATA[ | |
%ZSTART() { | |
} | |
LOGIN() Public { | |
Set Timeout = 2 | |
Write "Namespace <" _ $Namespace _ ">: " | |
Read Namespace:Timeout | |
Quit:Namespace="" | |
#Dim List As %ListOfDataTypes | |
Set List = $$GetNameSpaceList(Namespace) | |
If List.Count() = 1 { | |
Set Choice = 1 | |
} ElseIf List.Count()>1 { | |
Do DisplayNameSpaceList(List) | |
Write "Select number <1>: " | |
Read Choice:Timeout | |
Set:Choice="" Choice = 1 | |
} Else { | |
// No namespaces found | |
Quit | |
} | |
Zn List.GetAt(Choice) | |
} | |
GetNameSpaceList(Namespace = "*") Public { | |
New $Namespace | |
Set $Namespace = "%SYS" | |
Set List = ##class(%ListOfDataTypes).%New() | |
#Dim ResultSet As %SQL.StatementResult | |
Set SQL = "SELECT Name FROM Config.Namespaces WHERE (SectionHeader='Namespaces') AND (%UPPER(Name) [ %UPPER(?)) AND (%UPPER(Name) != '%ALL')" | |
Set ResultSet = ##class(%SQL.Statement).%ExecDirect(,SQL, Namespace) | |
While ResultSet.%Next() { | |
Do List.Insert(ResultSet.%Get("Name")) | |
} | |
Quit List | |
} | |
DisplayNameSpaceList(List) { | |
#Dim List As %ListOfDataTypes | |
Write ! | |
For i = 1:1:List.Count() { | |
Write i, $C(9), List.GetAt(i), ! | |
} | |
} | |
]]></Routine> | |
</Export> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment