KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Looking inwards: How many lines of code are found in the application
PRODUCT: 4D | VERSION: 15.2 | PLATFORM: Mac & Win
Published On: March 25, 2016

Here is a code snippet that returns the total number of lines of code that are found within the application:

// UTIL_LineNumbersInDB
// returns the total number of lines found in all methods
C_LONGINT($total;$count;$result)
ARRAY TEXT($MethodNames_at;0)
ARRAY TEXT($MethodCodes_at;0)
METHOD GET NAMES($MethodNames_at;*)
METHOD GET CODE($MethodNames_at;$MethodCodes_at;*)
$count:=Size of array($MethodNames_at)
$total:=0
For ($a;1;$count)
   $phpOK:=PHP Execute("";"substr_count";$result;$MethodCodes_at{$a};"\r")
   $total:=$total+$result
end for
$0:=$total


If the code snippet above is saved as UTIL_LineNumbersInDB it could then be used like this:

ALERT(String(UTIL_LineNumbersInDB ;"###,###,###,##0")+" lines of code found.")