Get classname from udl based file
Hello, guys.
I want to add a class to my project. This class is in UDL format.
I know that there is a method: ##class(%Compiler.UDL.TextServices).SetTextFromStream. The problem is that to use this method I need to know the name of the class (including all packages) in advance. But, a class can have any name(I mean C:/source/AAA/BBB/CCC.cls, but the real name is Sample.Human.cls).
For now I found only one way to get to know the name of a class - just parse the class code and search for a word which is followed by "Class" word. Is there any better way to do that?
P.S. There are some problems with my method, such as: the word "Class" can be in comments or the name of a class can be on different line and etc
Comments
In case when you try to load this file via %Compiler.UDL.TextServices you should know this classname, and you can parse original file. But if it possible, better to use $system.OBJ.Load(), in this case you should not pass classname, only lodaded filename.
The problem is that $system.OBJ.Load expects a file which is in xml, %ro and cdl formats. I get "Unknown file type" error for udl.
Yes, because $system.OBJ.Load() started support UDL, only in 2016.2 version
You can determine class based on a path by enforcing one standard of internal<->external name conversion.
So you have two methods:
ClassMethod GetExternalName(InternalName) As %String {}
ClassMethod GetInternalName(ExternalName) As %String {}And the value of expressions:
Write InternalName=..GetInternalName(..GetExternalName(InternalName)) Write ExternalName=..GetExternalName(..GetInternalName(ExternalName))
Is always 1 for any valid InternalName/ExternalName.
Where can find GetInternalName method? My class extends from %SYS.Task.Definition.
And probably the path to the class will be different from the real name of the class. For example, the path is abc/qwe/file.cls but the name of the class is cache.hello.cls
I meant you write them. Here's the reference though.