Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
getl - get count of all lines
#1
well the title says it ...

currently i can't figure out on how to get a total count of lines
in a text file.
pi
#2
Yeah, I was looking for something like that, too. Well, it could be done in a function without too much trouble. (Repeatedly search for a match with “[]”.)
9: ) Lindsey Dubb
#3
yihaa :mrgreen:

Code:
str cgp.getfile("C:\Programme\MYIE2\groups\piblog.cgp")
lpstr lp = cgp; int b
rep
    str s.getl(lp b)        
    if len(s)=0
        break
    b+1
out b
pi
#4
Function NLines

Code:
function lpstr's

int i j n
if(s and s[0])
,for(n 0 1000000000)
,,i=findc(s 10 j)+1; if(!i) break
,,j=i
,if(s[j]) n+1

ret n

Test

Code:
out NLines("one[]two[][]four[]")


Forum Jump:


Users browsing this thread: 1 Guest(s)