Computer Science Canada saving and laoding to files help |
Author: | Boarder16 [ Thu Jan 08, 2004 11:01 pm ] |
Post subject: | saving and laoding to files help |
i did read teh tutorial but am still having this one error problem.... it says after teh program is done running , "Eof attempted on incompatible stream number 2"... it is supposed to write what is in the variables to a file, then put bye, but it dosen't put bye, it stops and this aerror occurs!. i don't know what teh problem is.. if u need the code tell me... thanks |
Author: | Dan [ Thu Jan 08, 2004 11:05 pm ] |
Post subject: | |
i think you are reading past the end of the file. you need to add an "exit when eof(stream)" to it to make it stop b4 it hits the end. |
Author: | Boarder16 [ Thu Jan 08, 2004 11:20 pm ] |
Post subject: | |
i already have that.. heres teh closeing code cls delay (1000) open : stremout, "matt.txt", write exit when eof (stremout) write : stremout, account_information put "Thank you for using Jones Investment Banking" delay (2000) close : stremout Window.Close (w1) and i've tried it like this cls delay (1000) open : stremout, "matt.txt", write write : stremout, account_information exit when eof (stremout) put "Thank you for using Jones Investment Banking" delay (2000) close : stremout Window.Close (w1) i also have the variable called properly at the top 2 |
Author: | Ashkan [ Fri Jan 09, 2004 12:17 am ] | ||
Post subject: | |||
in case you wanna overwrite the previously written data just take off ,mod
|
Author: | AsianSensation [ Fri Jan 09, 2004 7:34 am ] |
Post subject: | |
well, first of all, you are using write with a text file, which is a no no, because write is used with binary files. To just read and write normally with a textfile, use get instead. |
Author: | DanShadow [ Fri Jan 09, 2004 9:37 am ] | ||
Post subject: | |||
Seriously, just do it the easy way, save it under a String Variable.
And im not sure why...but it only displays the first word in the datafile, but meh. Im just giving you a more general/easy idea of how to do it. |
Author: | Boarder16 [ Sat Jan 10, 2004 2:56 pm ] |
Post subject: | |
no its not like that.. here can be no user input.. it opens teh file hwen ran.... and clsoes it when done... but it load the info and saves the info 2 |
Author: | Boarder16 [ Sat Jan 10, 2004 3:30 pm ] | ||
Post subject: | |||
Heres all teh code so far... it won't run.. can you help even with all teh tutorials i read.. istill cn't get it to work.. it hink i was too confused and started mixing the get and read properties together....
to test to see if it does save t oteh file oyu can change teh balance using teh program when it runs then re open it and see if the balance has changed.. but when you rer- un it you will ahev to take the default values for teh variables off..... liek balance : = 10000 and shares1 througgh 4 : = 0... thanks |
Author: | Boarder16 [ Sat Jan 10, 2004 3:31 pm ] | ||
Post subject: | |||
Heres all teh code so far... it won't run.. can you help even with all teh tutorials i read.. istill cn't get it to work.. it hink i was too confused and started mixing the get and read properties together....
to test to see if it does save t oteh file oyu can change teh balance using teh program when it runs then re open it and see if the balance has changed.. but when you rer- un it you will ahev to take the default values for teh variables off..... liek balance : = 10000 and shares1 througgh 4 : = 0... thanks |
Author: | Dan [ Sat Jan 10, 2004 9:01 pm ] | ||||
Post subject: | |||||
i think you whont:
to be
dont need to loop the output and you need spaces or it is all read i as one number next time. |
Author: | Boarder16 [ Sat Jan 10, 2004 9:35 pm ] |
Post subject: | |
i still have teh proble mwith teh get statement.. it says attempted to read past eof... could it be that i have no values on teh text file it is looking in..??? |
Author: | Dan [ Sat Jan 10, 2004 10:05 pm ] |
Post subject: | |
Boarder16 wrote: i still have teh proble mwith teh get statement.. it says attempted to read past eof... could it be that i have no values on teh text file it is looking in..???
probly b/c when i ran your progmae with my chages and my own values in the text file it worked. try cahging your porgame like i side and remaking your txt file, numbers need to have a space or have to be on a difrent line to be read as difrent numbers. |
Author: | Boarder16 [ Sat Jan 10, 2004 11:34 pm ] |
Post subject: | |
is there anyway i can make i don't have to ask if it tehy first time using it type thing... u know what i mean.. if i did it ur way it would require me to change quite a bit.. and its very confusing lol..but i'll give it a shot.. |
Author: | Dan [ Sat Jan 10, 2004 11:35 pm ] |
Post subject: | |
? you just have to delte 3 lines and then add some spaces in another |
Author: | Boarder16 [ Sat Jan 10, 2004 11:43 pm ] |
Post subject: | |
wait i think i understand it, but how would i get it so teh number i read are put back into the variables they once were in? like so after i save like 4, and then open the 4 variables....how will it know which value is to which variable? |
Author: | Boarder16 [ Sat Jan 10, 2004 11:45 pm ] |
Post subject: | |
actually i think i jsut figured tha out oo.. that example u gave me actually was VERY helpful i just t nvere saw it.. tahnks alot... i'd giveu bits...but i'm to cheap ![]() |
Author: | Boarder16 [ Sun Jan 11, 2004 12:04 am ] |
Post subject: | |
yes..YES YES.. igot it to work.. it took me a while but i did it.. .tahnks alot... realized why ikept getting teh same error messgae..its becasue tehre wer no variabels already made in teh file to retrieve but i fixed it so i dumped sum in quickly then it opened them... tehn next tiem i re-ran it i took away teh first part where they get tehir value so it works... |