read file
Blitz3D Forums/Blitz3D Beginners Area/read file
| ||
I have been having some trouble geeting readfile and write file to work [code] Function deposit() String$="" howmuch#=Input("How much would you like to deposit?") Print "Make sure a valid flash drive is pluged in!" Print "Press any key" Print " " WaitKey() file$=ReadFile("f:\key.txt") While Not Eof(file) String$=String+ReadString$(file) Wend CloseFile(file) Print contents End Function [code] |
| ||
Help!!! |
| ||
From what I see there, I think this might help. There's no write in the above, adn I should mention that iof you WriteInt, String or Float, then you need to Read Int, String or Float to retieve it. Writefile will wipe your previous entries, so use Openfile to append. I changed the input to float as money usually comes with decimals, but feel free to change it :) BAD ME didnt check code. Fixed below :) |
| ||
Thanks that looks great. I'll try it out right now. www.aj00200.htmlplanet.com AJ00200 |
| ||
What you have looks good, but every time I try to run the program, it says end function without function AJ00200 |
| ||
Remove the EndIf from the second function. You also need to add a Wend in the last function. |
| ||
No thats not it. I already have. It still says that. |
| ||
Your missing the Wend in the third func. Where does it go? Before or after close file? |
| ||
Sorry, I scribbled that out quickly with some copy and pastes. This is correct: Function Withdrawal(fAmount#) Accountfile=OpenFile(Filename$) SeekFile(Accountfile,FileSize(Accountfile)) WriteFloat Accountfile,fAmount# CloseFile Accountfile End Function Function Deposit(fAmount#) Accountfile=OpenFile(Filename$) SeekFile(Accountfile,FileSize(Accountfile)) WriteFloat Accountfile,fAmount# CloseFile Accountfile End Function Function CheckBalance#(fAmount#) Transactions#=0 Accountfile=OpenFile(Filename$) While Not Eof(Accountfile) Transactions#=Transactions#+ReadFloat#(Accountfile) Wend CloseFile Accountfile Return Transactions# End Function |
| ||
Thanks a lot. No errors anymore. AJ00200 |