|
-
Jan 15th, 2000, 04:24 AM
#1
Thread Starter
Hyperactive Member
Opening files as #1, #2, etc. is a habit I have from Dos Basic days, but I see a lot of mention against doing this.
Why?
Thanks,
Al.
------------------
A computer is a tool, not a toy.
<A HREF="mailto:[email protected]
[email protected]">[email protected]
[email protected]</A>
-
Jan 15th, 2000, 04:31 AM
#2
-
Jan 15th, 2000, 10:12 AM
#3
Hyperactive Member
By the way, what's wrong with "Go To"?
Bad habits are hard to extirpate!
I personally don't think it to be bad if you open a file as #1, read or write
and close it right before any damage can be done.
[This message has been edited by Juan Carlos Rey (edited 01-15-2000).]
-
Jan 15th, 2000, 10:20 AM
#4
-
Jan 15th, 2000, 09:20 PM
#5
freefile works every time, you must have been doing it wrong.
this is the proper way of using freefile...
Code:
dim MyFile as byte
MyFile = freefile
open "AnyFile.txt" for output as #Myfile
'do your stuff here
close #Myfile
Freefile is a safeguard against damaging files opened in another app.
the thing to remember is that every time you try to open another file (i.e. 2 at once) you need to change the name of the variable to something else, and then make it equal to freefile. The internal freefile value increments by one every time you open a file. and decrements every time a file closes.
you cannot say that it "sux" simply because you lack the programming ability to make it work. if you dont know what your talking about, why are you deliberately misleading people?
------------------
Wossname,
Email me: [email protected] 
[This message has been edited by wossname (edited 01-16-2000).]
-
Jan 15th, 2000, 10:57 PM
#6
Thread Starter
Hyperactive Member
Ok. How would I use FreeFile in the following:
Code:
Open"c:\Daily Transactions" for input as #1
Open"c:\Warehouse Transfers" for Append as #2
Open"c:\Warehouse Scrapped" for Append as #3
While Not EOF(1)
Line Input#1,strTransaction
If Left(strTransaction,8) = "Transfer" then
Print#2,strTransaction
ElseIf Left(strTransaction,8) = "Scrapped" then
Print#3,strTransaction
end If
Wend
Close
Thanks,
Al.
-
Jan 16th, 2000, 01:51 AM
#7
-
Jan 16th, 2000, 02:19 AM
#8
Thread Starter
Hyperactive Member
Ok. I'll accept that. I do see the benifit of FreeFile considering the number of files that VB will allow you to open.
Just for the heck of it, I popped into my old QB program and, Lo and Behold, FreeFile was a function in QB. I didn't know this.
Thanks,
Al.
------------------
A computer is a tool, not a toy.
<A HREF="mailto:[email protected]
[email protected]">[email protected]
[email protected]</A>
-
Jan 16th, 2000, 10:51 AM
#9
Hyperactive Member
-
Jan 16th, 2000, 11:28 AM
#10
Thread Starter
Hyperactive Member
I do remember that goto was frowned upon in Dos Basic circles. The theory was that it was the result of sloppy program structure.
Unless someone cares to differ, I think that it is now an accepted way to branch to another part of a program.
e.g. On Error GoTo...
Al.
------------------
A computer is a tool, not a toy.
<A HREF="mailto:[email protected]
[email protected]">[email protected]
[email protected]</A>
-
Jan 16th, 2000, 11:47 AM
#11
Member
I agree, that goto is a form of sloppy programming and for a loops u should use either a do or a for loop. Just some programming etticut i guess.
-
Jan 16th, 2000, 12:23 PM
#12
PowerPoster
-
Jan 16th, 2000, 05:15 PM
#13
Lively Member
Well surprise for all of you try and read somebody’s code that was done in QBasic, gwBasic or VB and it is a nightmare with keeping the current code functionality in mind and then have to jump to 10 different places in code and still trying to keep track of what this person was trying to achieve. Believe me, what makes it even worse if they used really stupid names for
Variables etc. I have been there and it is hell.
You might not feel it because you wrote the code and know what you were trying to do where. But the other people who have to find errors and bugs in your program will be cursing
for the next 3 hours solid.
Yes to an extend I agree, I use goto on error handlers and I use gosub’s but only when there is now way out of the situation.
------------------
-----------------------
Maartin
[email protected]
-----------------------
-
Jan 17th, 2000, 06:54 PM
#14
Junior Member
What's wrong with sloppy programming??? ;-)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|