Lines of Code
With a routine like this one, you can quickly calculate how many lines of code you are working with. And it is not only for routines, it works for classes because remember that classes generate routines !
Here you have the routine source code:
LinesOfCode ;
new SQLCODE,tRoutine
set tTotalLOC = 0
&sql(DECLARE ROUTINES CURSOR FOR
SELECT NAME
FROM %Library.RoutineIndex
WHERE TYPE = 'MAC'
ORDER BY NAME)
&sql(OPEN ROUTINES)
&sql(FETCH ROUTINES INTO :tRoutine)
while (SQLCODE=0)
{
write !,$j($i(tCount),5),": ",tRoutine
set tLOC = $get(^rMAC(tRoutine,0,0))
write "("_tLOC_")"
set tTotalLOC = tTotalLOC + tLOC
&sql(FETCH ROUTINES INTO :tRoutine)
}
&sql(CLOSE ROUTINES)
write !!,"Total lines of code = "_tTotalLOC
This is the output in a terminal:
USER>do ^LinesOfCode 1: %ZJRNPURGE(5) 2: LinesOfCode(20) Total lines of code = 25 USER>