%File1.t
reading from a file
var filenum : int
var word : string
var mx, my, mb : int
open : filenum, "file1.txt", put
loop
mousewhere (mx, my, mb)
get word
put : filenum, word ..
exit when mb = 1
end loop
close : filenum
var filenum : int
var ch : string (1)
open : filenum, "file1.txt", get
loop
get : filenum, ch : 1
put ch ..
getch (ch)
end loop
close : filenum
%
%
%File2.t
%writting to a file
var names : array 1 .. 4 of string := init ("Bob", "Sue", "Al", "Jo")
var scores : array 1 .. 4 of int := init (5000, 4800, 4600, 4000)
var outfile : int
open : outfile, "highScore.dat", put
for i : 1 .. 4
put : outfile, names (i) : 20, scores (i) : 20
end for
close : outfile
%file3.t
%reading from our Mega-metafile and drawing on the screen
var x1, y1, x2, y2, c : int
var metafile : int
open : metafile, "pic1.mmf", get
loop
exit when eof (metafile)
get : metafile, x1, y1, x2, y2, c
drawline (x1, y1, x2, y2, c)
end loop
close : metafile
%file4.t
%making our mega-metafile
var x1, y1, x2, y2, c : int
var mm, mb : int
var metafile : int
open : metafile, "pic1.mmf", put
loop
buttonwait ("downup", x1, y1, mb, mm)
exit when hasch
buttonwait ("downup", x2, y2, mb, mm)
exit when hasch
put : metafile, x1 : 4, y1 : 4, x2 : 4, y2 : 4, 7 : 2
drawfillstar (x1, y1, x2, y2, 37)
end loop
close : metafile