Timmeh041
May 27th, 2008, 10:20 AM
Hello all,
I have an invoice sort of program. The user enters in a command, and then a product and price, another command to enter in the product and its quantity. They then do a command to generate the invoice.
Part of what i want to do is read in from a file. Now currently, i have got it doing this, if and only if, it is the users first attempt at reading the file in.
here is my code. It should be noted that the user can type in any sequence of program commands (all starting with /), as long as product and it's prices (raw prices) are done first. Like i said this all works.
Now the problem.
If the user ran the program and typed in
/read input.txt and input.txt existed all would be sweet
but if they went
/read bat.txt //bat.txt doesn't exist
*here an error message saying such a file doesn't exist correctly appears*
/read input.txt //input.txt does exist
an error message would appear saying that the input.txt file doesn't exist.
I am at a complete loss as to what is happening. I suspect it has something to do with the first file not being closed down properly, but i have placed that file.close() everywhere i can think of with no results.
Any helpful suggestions please?
thanks all
tim
I have an invoice sort of program. The user enters in a command, and then a product and price, another command to enter in the product and its quantity. They then do a command to generate the invoice.
Part of what i want to do is read in from a file. Now currently, i have got it doing this, if and only if, it is the users first attempt at reading the file in.
here is my code. It should be noted that the user can type in any sequence of program commands (all starting with /), as long as product and it's prices (raw prices) are done first. Like i said this all works.
Now the problem.
If the user ran the program and typed in
/read input.txt and input.txt existed all would be sweet
but if they went
/read bat.txt //bat.txt doesn't exist
*here an error message saying such a file doesn't exist correctly appears*
/read input.txt //input.txt does exist
an error message would appear saying that the input.txt file doesn't exist.
I am at a complete loss as to what is happening. I suspect it has something to do with the first file not being closed down properly, but i have placed that file.close() everywhere i can think of with no results.
Any helpful suggestions please?
thanks all
tim