HP3000-L Archives

July 2004, Week 3

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
"Emerson, Tom" <[log in to unmask]>
Reply To:
Emerson, Tom
Date:
Fri, 16 Jul 2004 16:46:24 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (45 lines)
> -----Original Message-----
> From: Keven Miller
> 
> I seem to remember that the old Reflection/DOS package had
> a program that would do what you want. Count records and
> give you record size.

Of course, if that is "all" that you want to determine, it is trivially easy to do this with qbasic/visual-basic/vba:

   open <file> for input as #1
   while not eof(1)
      line input #1, b$
      cnt = cnt + 1
   wend
   print "The file contains " & cnt & " records of length " & len(b$)
   close #1

Of course, this presumes all records are the same size -- if not, you'll have to add code to keep track of the record length, and then report the longest line in the file, the average line length, or ...

This also presumes a "normal" (DOS) line terminator, otherwise "line input" tries to read the entire file -- a friend of mine recently came across a file that had ascii 10's [line-feeds] ONLY as the record terminator; for that I wrote:

   Function GoofyLineInput(f As Integer) As String 
   Dim b As String 
   Dim c As String 
      Do While Not EOF(f) 
         c = Input(1, f) 
         If c = Chr(10) Then Exit Do 
         b = b & c 
      Loop 
      GoofyLineInput = b 
   End Function 

The above routine came about after I had him do the following:

   open <whatever...> for input as #1
   b$=input(256,#1) ' read 256 characters from file number 1
   for i = 1 to len(b$)
      debug.print iif(asc(mid(b$,i,1))<32,"[" & asc(mid(b$,i,1)) & "]",mid(b$,i,1));
   next
 
to see what the actual "record break" characters were -- this basically surrounds any non-printing characters [less than ascii 32] as the ascii code number in brackets -- this is also quite useful for finding NULL characters...

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2