Page 1 of 1

Stream I/O

Posted: Wed May 25, 2005 1:25 pm
by Shmack
right now im learning I/O and i currently dont know what to do lol i looked in the help fild but im supposed to creat a .txt save in it and display info from it if you know any thing could you help me out a little :unsure:

Archived topic from Iceteks, old topic ID:3346, old post ID:27090

Stream I/O

Posted: Wed May 25, 2005 1:45 pm
by Shmack
nvm found some thin

% File I/O
% Basic code
%
% On their own, these pieces don't work, but
% they should be the basis for your file I/O



% Write to a file
var stream : int

% Open a stream to write data to a file
% (can replace filename with real name in quotes)
open : stream, filename, put

% Write the data to the file
put : stream, data

% Close the stream
close : stream



% Read from a file
var stream : int

% Open a stream to read data from a file
% (can replace filename with real name in quotes)
open : stream, filename, get

% Make sure stream is given a value
% (file exists)
assert stream > 0

% Read data in using a loop
loop
% Get out of the loop if we've reached the End Of File
exit when eof (stream)

% Read the data from the file
get : stream, data

% Display it to the screen
put data
end loop

% Close the stream
close : stream


thx any ways

Archived topic from Iceteks, old topic ID:3346, old post ID:27091