Re: [VB5) Faster way to read a text file?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"Robert Morley" <rmorley@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:OgEyy753HHA.1900@xxxxxxxxxxxxxxxxxxxxxxx
Speaking of which, has anybody taken a look at the code example that goes
along with the Reset help? I can't ever imagine opening and/or closing
files that way.

Ya know, you COULD have posted the example so we all wouldn't need to go
look it up. <g>

Here it is:

-------
Reset Statement Example
This example uses the Reset statement to close all open files and write the
contents of all file buffers to disk. Note the use of the Variant variable
FileNumber as both a string and a number.

Dim FileNumber
For FileNumber = 1 To 5 ' Loop 5 times.
' Open file for output. FileNumber is concatenated into the string
' TEST for the file name, but is a number following a #.
Open "TEST" & FileNumber For Output As #FileNumber
Write #FileNumber, "Hello World" ' Write data to file.
Next FileNumber
Reset ' Close files and write contents
' to disk.
------

I see nothing wrong with the example in *specific* regard to how it's
opening/closing the files. Admittedly, I don't think I've EVER used Reset. I
always use Close. However, I *do* question the use of the Variant and that
the example even points out its use as an apparent "plus".

It'd be almost as bad as using Exit Do! <totally mooning all
non-structured-programming-maniacs out there...which is most of you> :)

I don't think that Exit Do (or Exit For) is necessarily a bad thing. As with
anything, sure, it can be abused/misused and you end up with sloppy code.
But use of it when appropriate, IMO, doesn't make code non-structured. If
the need for looping has ended, then why continue with the loop
unnecessarily? To me, it's GOOD programming to end the loop when whatever
need for the loop has been satisfied. I will say that I think it's better
for the loop condition itself to be met such that the loop ends "naturally",
but that's not always the case.

Let's just say that you need to loop through an array to find a unique value
assigned to an element. And let's also say this array has 1000 elements. And
let's also say the unique value you need to find is assigned to the first
element. Does it really make sense to loop another 999 times after you've
already found what you need? I don't think so.


--
Mike
Microsoft MVP Visual Basic


.



Relevant Pages

  • Re: [VB5) Faster way to read a text file?
    ... I dunno...opening files in a loop (without closing them in the same loop, ... Reset Statement Example ... variable FileNumber as both a string and a number. ...
    (microsoft.public.vb.general.discussion)
  • Re: [VB5) Faster way to read a text file?
    ... I can't ever imagine opening and/or closing ... ' Open file for output. ... FileNumber is concatenated into the string ... Reset ' Close files and write contents ...
    (microsoft.public.vb.general.discussion)
  • Re: one signal set from two processes .....
    ... main: loop ... Isn't the "exit main when reset = '1'" a synchronous reset? ... defense line "the smaller the better" usually drives designers to write ... multi-threaded) computing that can be performed in parallel by an ...
    (comp.lang.vhdl)
  • Re: ISE 10.1
    ... The ISE is looking for .ant file and pointing the errors in .ant file. ... OPTL: In std_logic; ... Reset: In std_logic; ... END LOOP CLOCK_LOOP; ...
    (comp.lang.vhdl)
  • Re: sum of array
    ... SEQ_LOOP is an infinite loop ... only when reset is asserted. ... variable somme: T_chiffre; ... DOULOS - Developing Design Know-how ...
    (comp.arch.fpga)