scripting@wanadoo.nl




GetLineCount()

http://www.scriptlogic.com/kixtart/FunctionLibrary_FunctionList.aspx


actual FunctionLibrary list on 'Scriptlogic' site printer-friendly mirror of UDF topic on 'scripting@wanadoo.nl' site close
13 February 2002 GetLineCount()
AuthorNew Mexico Mark (wmarkh@aol.com)
Action Counts the lines in a given text file.
SyntaxGetLineCount (FileSpec) 
Parameters
  • FileSpec (Required / String) File Specification. 
  • RemarksKeep in mind that KiXtart reads in complete files, so mileage may vary on larger files. 
    ReturnsInteger with number of lines in the file or -1 for error. 
    DependenciesNone. But function uses 7 for file number. Make sure there are no conflicts with open files in your script. 
    Examples
    $Lines=GetLineCount('c:\temp\myfile.txt')
    'Your file has ' + $Lines + ' lines.' ?
    
     
    Source
    FUNCTION GetLineCount ($sfilespec)
      ; $sFileSpec is a string containing a file specification
      ;
      ; GetLineCount() returns an integer with the number of lines in the file or -1 if there is an error.
    
      DIM $vtmp, $ifilenum
      $sfilespec = '' + $sfilespec
      $ifilenum = 7
      $getlinecount = -1
      IF Exist($sfilespec)
        IF Open($ifilenum,$sfilespec) = 0
          $getlinecount = 0
          $vtmp = ReadLine($ifilenum)
          WHILE @error = 0
            $getlinecount = $getlinecount + 1
            $vtmp = ReadLine($ifilenum)
          LOOP
          $vtmp = Close($ifilenum)
        ENDIF
      ENDIF
    ENDFUNCTION ; - GetLineCount -
     
      original source of UDF topic. show actual FunctionLibrary list on Scriptlogic site close top
              printer-friendly mirror of UDF topic on scripting@wanadoo.nl site  




    Copyright © 2003 www.scriptlogic.com & scripting@wanadoo.nl - last updated on 20 May 2003


    Site Meter