Seems like a pointless exercise to me. A question to ask is what is the objective for this?
There is a quick way to do this but it depends on how accurate you want the count to be. In the Management Portal, under System Explorer, Classes there is the option to export classes to an external XML file; there is also the option to include/exclude system classes and select individual or all classes.
This will export the classes into an XML file which you can open in a text file editor to get the number of lines. Note though, the XML export adds additional lines for tags to differentiate the code sections so the count will be greater than the actual lines shown when actually editing the code in the usual editor.
But it could be an option for you.
You need to understand the difference between $order and $query; they both handle globals/arrays differently for different purposes.$order is the more straightforward to use (and more commonly used); it scans down a particular node of a global/array. For example for your example:
set n=$order(^TestGlobal("Not Configured",n))
; do something with n
$query is more useful if the global structure is unknown or less structured. It starts at the top of the global and returns the entire subscript string at a given level. So again for your example, the first $query would return ("Not Configured","Value 1"). You could then use $QL to get the number of subscripts at that level (2 in this case), and $qs(subscripts,position) to get the value of the subscript.
("Not Configured","Value 1")
w node ; this would return TestGlobal("Not Configured","Value 1")
w $ql(node) ; this would return 2
w $qs(node,1) ; this would return "not configured"
w $qs(node,2) ; this would return "Value 1"
w @node ; returns the data at that node; in this example null
TestGlobal("Not Configured","Value 1")
$order is the more commonly used.
You need to understand how to use globals and arrays to efficiently store data, and how to traverse them using $order. Globals and arrays are handled the same except globals are store on disk (persistant/permanent) and arrays are stored in memory (volatile/temporary).
Hope this helps.
Interesting article, thanks Rob.
Have you written any documents (or aware of any documentation) that details how the globals work in the background? I know when I started coding Mumps in the early 90's, I assumed that every time you referred to a global in the code the data was being accessed directly from the disk. However I know that isn't the case and have a vague understanding that the global data is stored in data blocks stored in a b-tree structure but I would like a deeper understanding of how globals are actually stored and managed.
Log in or create a new account to continue