Question
· Jul 20, 2016

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

Discussion (6)0
Log in or sign up to continue

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.