%%%%%%%%%%%%% DISPLAY DATAFILE %%%%%%%%%%%5%
proc writeArrays %display datafile
var count : int := 0
var avgage : real
var spacing : string := ". "
Initial
storeValues
include "colours.t" %include background and colour settings
colorback (40)
color (white)
locate (2, 3)
put "#" : 2, " First name" : 21, "Last name" : 17, "Gender " : 17, "Age" : 15, "Mark" .. %heading
for ctr : 1 .. howMany
if fname (ctr) > "0" then %check if datafile has records
if gender (ctr) = "f" then %capitalize gender on output
gender (ctr) := "F"
elsif gender (ctr) = "m" then
gender (ctr) := "M"
end if
if ctr > 9 then
spacing := ". "
else
spacing := ". "
end if
colorback (black)
locate (ctr + 3, 3) %locate content
put ctr, spacing, fname (ctr) : 20, lname (ctr) : 17, gender (ctr) : 17, age (ctr) : 3, mark (ctr) : 14, "%" .. %display datafile
delay (50)
count += 1
else
colorback (black)
locate (4, 3)
put "Datafile has no student records" ..
locate (5, 3)
put "Please go back and add students to datafile" ..
end if
end for
locate (24, 60)
put "Total students: ", count ..
locate (24, 3)
include "wait1.t" %back to menu
end writeArrays
|