Total Commander Forum Index Total Commander
Форум поддержки пользователей Total Commander
Сайты: Все о Total Commander | Totalcmd.net | Ghisler.com | RU.TCKB
 
 RulesRules   SearchSearch   FAQFAQ   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Single Post  Topic: Посчет числа строк в исходниках 
Author Message
Batya



PostPosted: Wed Mar 04, 2009 17:26    Post subject: Reply with quote

prog_san
Используем Script Content Plugin:
Code:
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
Const ForReading = 1
content = Result
Set FSO = Nothing

Function Result
  If FSO.FileExists(filename) Then
    Result = LinesInFile(filename)
  ElseIf FSO.FolderExists(filename) Then
    Result = LinesInFolder(filename)
  End If
End Function

Function LinesInFile(byVal pFile)
  Dim OTF
  On Error Resume Next
  Set OTF = FSO.OpenTextFile(pFile, ForReading, False)
  If Err.Number = 0 Then
    OTF.ReadAll
    LinesInFile = OTF.Line - 1
    OTF.Close
  Else
    LinesInFile = 0
  End If
  On Error GoTo 0
  Set OTF = Nothing
End Function

Function LinesInFolder(byVal pFolder)
  Dim l, lf, lff
  l = 0
  On Error Resume Next
  Set lff = FSO.GetFolder(pFolder)
  If Err.Number = 0 Then
    For Each lf In lff.Files
      l = l + LinesInFile(lf)
    Next
    For Each lf In lff.SubFolders
      l = l + LinesInFolder(lf)
    Next
    LinesInFolder = l
  Else
    LinesInFolder = 0
  End If
  Set lff = Nothing
End Function

Скорость не самая высокая, но работает Smile
_________________
Нет, я не сплю. Я просто медленно моргаю.


Last edited by Batya on Thu Mar 05, 2009 14:58; edited 2 times in total
View user's profile Send private message


Powered by phpBB © 2001, 2005 phpBB Group