Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help With Writing To A File
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
bizkit




PostPosted: Wed Jan 22, 2003 8:04 am   Post subject: Help With Writing To A File

I am creating a cashier file. With every customer it writes to a log file and then its supposed to shift down to the next line, the only problem is that it overwrites the existing log data and wont shift down the line

my code is as follows:

procedure cashierupdate
open : streamnumber, cashiernumber, put
var number : int
number := 1
loop

put : streamnumber, cashupfilestring (flag2)

number += 1
exit when number = flag2
end loop
close : streamnumber
end cashierupdate

i need help with this asap plz thx alot
bizkit
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Wed Jan 22, 2003 10:38 am   Post subject: (No subject)

there're multiple solutions to your problem.

Each time you open the file, it reads/writes from the beginning... So if you don't close the file at the end of your procedure, it shoud not overwrite existing info.

Another approach (need this is you open up the program again). Run a loop to read through entire file, this will place you at the of of it, so you can continue to add new information.

code:

loop
exit when eof(streamnum)
get : steamnum, variable
end loop
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: