
-----------------------------------
MossyMossy
Wed Feb 24, 2010 10:04 am

HouseLocator
-----------------------------------
What is it you are trying to achieve?
Write a program to prepare a disk file of records called
OnHand suitable for use in the HouseLocator program of this
chapter. In the HouseLocator program the records are read
from the file HouseInfo by the procedure readFile. Change
this procedure so that records for houses are read from the
disk file OnHand. You can use the Turing editor if you are
having difficulty prepare the file OnHand.

What is the problem you are having?
I have no idea how to do this.






% The "HouseLocator" program
% Reads series of records for houses
% Allows questions about records in file
type houseType :
    record
        color : string (10)
        location : string (20)
        price : int
    end record
const maxHouses := 100
var houseFile : array 1 .. maxHouses of houseType
procedure readFile (var entry : array 1 .. * of houseType, var count :
        int)
    % Read houseType records into an array
    var sale : int
    open : sale, "OnHand.txt", get
  assert sale > 0
    count := 0
    loop
        get : sale, skip
        exit when eof (sale)
        count := count + 1
        bind var house to entry (count)
        get : sale, house.color : 10, house.location : 20,
            house.price
    end loop
end readFile
procedure outputRecord (h : houseType)
    put h.color : 10, h.location : 20, h.price : 10
end outputRecord
function wanted (house : houseType, desiredColor, desiredLocation :
        string (*),
        desiredUpperPrice : int) : boolean
    result (house.color = desiredColor or
        desiredColor = "any ")
        and (house.location = desiredLocation
    
        or desiredLocation = "any ")
        and (house.price 