The MASM Forum

Projects => MasmBasic & the RichMasm IDE => Topic started by: jj2007 on September 09, 2023, 01:03:25 AM

Title: Average line length of sources
Post by: jj2007 on September 09, 2023, 01:03:25 AM
include \masm32\MasmBasic\MasmBasic.inc
  Init
  GetFiles C:\Masm32\Examples\*.asm|*.inc
  Print Str$("There are %i *.asm and *.inc files in the examples folder\n", eax)
  xor ebx, ebx
  For_ each esi in Files$()
    void Exist(esi)
    push GfSize(-1)
    Recall esi, L$()
    xchg eax, ecx
    pop eax
    cdq
    div ecx
    add ebx, eax
  Next
  mov ecx, Files$(?)
  mov eax, ebx
  cdq
  div ecx
  Inkey Str$("Average line length of *.asm and *.inc sources is %i bytes", eax)
EndOfCode

Output:
There are 416 *.asm and *.inc files in the examples folder
Average line length of *.asm and *.inc sources is 28 bytes