Skip to content

Instantly share code, notes, and snippets.

@eduard93
Created June 30, 2022 20:07
Show Gist options
  • Save eduard93/bbc62dbfa3981b5a201e178f61a17572 to your computer and use it in GitHub Desktop.
Save eduard93/bbc62dbfa3981b5a201e178f61a17572 to your computer and use it in GitHub Desktop.
Class User.Py
{
ClassMethod Test(arg1, arg2, arg3) As %DynamicArray
{
return [(arg1), (arg2), (arg3)]
}
ClassMethod Test2(arg As %DynamicObject) As %String
{
return arg.Prop
}
ClassMethod Test3(arg As %Stream.Object) As %String
{
set file = ##class(%Stream.FileCharacter).%New()
set file.TranslateTable = "UTF8"
set filename = ##class(%File).ManagerDirectory() _ "test.txt"
do file.LinkToFile(filename)
if $isObject(arg) {
set sc = file.CopyFromAndSave(arg)
} else {
do file.Write(arg)
set sc = file.%Save()
}
if $$$ISERR(sc) {
set jsonret = {"status":0, "payload":($system.Status.GetErrorText(sc))}
} else {
set jsonret = {"status":1}
}
quit jsonret.%ToJSON()
}
ClassMethod Test4(arg As %DynamicArray) As %String
{
return arg.%Get(0)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment