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

Username:   Password: 
 RegisterRegister   
 calling info from text files
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
skier




PostPosted: Fri Nov 12, 2004 3:56 pm   Post subject: calling info from text files

does anyone no how to get arrays t save to a text file.i have got it to do single numbers but i cant get it to do arrays.
code:


var fileName : string := "filename.txt"
var file : int
var s : string
var num:int
num:= 5

open : file, fileName, put
put : file, num
close (file)

open : file, fileName, get
get : file, s : *
put s
close (file)


any help?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Fri Nov 12, 2004 4:05 pm   Post subject: (No subject)

well just keep on writing to file and not close it...
code:

for i : 1 .. upper (my_array)
    put : file, my_array (i)
end for
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
skier




PostPosted: Fri Nov 12, 2004 4:14 pm   Post subject: (No subject)

thats what i was doing before and it wasnt working but now it is. maybe i frogot to put in "upper".

how do i call all the info for an array.i tyed just calling th variable but it doesnt work.how do i do this ?
Mr. Glib




PostPosted: Sun Nov 14, 2004 3:27 pm   Post subject: Re: calling info from text files

skier wrote:
does anyone no how to get arrays t save to a text file.i have got it to do single numbers but i cant get it to do arrays.
code:

snip


any help?


With arrays, remember those pesky little index values.

var x : array 1..2 of int
x(1) :=10
x(2) :=3

open : stream, filename, put

for y : 1..2
put : stream, x(y)
end for
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  [ 4 Posts ]
Jump to:   


Style:  
Search: