attempt to read past eof
Author |
Message |
bharath1000
|
Posted: Fri Jan 13, 2012 11:30 am Post subject: attempt to read past eof |
|
|
Its saying there is an attempt to read past eof if you press the delivery button and go to check out
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing: |
%imports the GUI for use later
import GUI
GUI.SetBackgroundColour (41)
%Memory cells
var font, font1, font2, deliverycharge, pizzadeal, fileno : int
var Name, Address, Pnumber, order : string
%declaration of memory cells
font := Font.New ("sans serif:24:bold,underline")
font1 := Font.New ("sans serif:16:bold")
font2 := Font.New ("sans serif:12:bold")
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Procedures%%%%%%%%%%%%%%%%%%%%%%%%%
proc CheckOut
cls
open : fileno, "f:/Final PRJ/order.txt", get
for a : 1 .. 79
get : fileno, order
locate (15, 1 + a )
put order
end for
close : fileno
end CheckOut
proc menu
cls
drawfillbox (0, 0, maxx, maxy, 41)
Font.Draw ("Sam's Wakedywack Pizza!", 150, 375, font, red)
Font.Draw ("Food", 50, 330, font, red)
Font.Draw ("Drinks", 500, 330, font, red)
Font.Draw ("Small Pizza.......$7.50($0.30 for each topping)", 00, 300, font2, red)
Font.Draw ("Medium Pizza.......$10.50($0.50 for each topping)", 0, 280, font2, red)
Font.Draw ("Large Pizza.......$12.50($0.65 for each topping)", 0, 260, font2, red)
Font.Draw ("Extra Large Pizza.......$14.00($0.75 for each topping)", 0, 240, font2, red)
Font.Draw ("Garlic Bread.......$2.50", 0, 220, font2, red)
Font.Draw ("Garlic Bread w/cheese.......$5.50", 0, 200, font2, red)
Font.Draw ("Coffee.......$1.00", 450, 300, font2, red)
Font.Draw ("Tea.......$1.00", 450, 280, font2, red)
Font.Draw ("Small Pop.......$1.10", 450, 260, font2, red)
Font.Draw ("Large Pop.......$1.80", 450, 240, font2, red)
Font.Draw ("2L Pop.......$2.25", 450, 220, font2, red)
Font.Draw ("Please select what you would like to order", 100, 150, font1, red)
Font.Draw ("Type in 1 to stop ordering", 100, 130, font2, red)
open : fileno, "f:/Final PRJ/order.txt", put
loop
colourback (41)
locate (18, 14)
get order : *
Draw.ThickLine (100, 120, 640, 120, 10, 41)
put : fileno, order
exit when order = "1"
end loop
close : fileno
var CheckOut : int := GUI.CreateButton (500, 0, 0, "CheckOut", CheckOut )
loop
exit when GUI.ProcessEvent
end loop
end menu
%Delivery procedure for when button is clicked
procedure Delivery
cls
drawfillbox (0, 0, maxx, maxy, 41)
Font.Draw ("Please enter your name.", 200, 300, font1, red)
locate (8, 26)
colourback (41)
get Name : *
Font.Draw ("Please enter your address.", 200, 250, font1, red)
locate (11, 26)
colourback (41)
get Address
Font.Draw ("Please enter your phone number.", 200, 200, font1, red)
locate (14, 26)
colourback (41)
get Pnumber
cls
menu
end Delivery
%Eat In procedure for when button is clicked
procedure EatIn
cls
drawfillbox (0, 0, maxx, maxy, 41)
Font.Draw ("Please enter your table number.", 200, 300, font1, red)
locate (8, 26)
colourback (41)
get Name : *
end EatIn
%Takeout procedure for when button is clicked
procedure TakeOut
cls
drawfillbox (0, 0, maxx, maxy, 41)
Font.Draw ("Please enter your name.", 200, 300, font1, red)
locate (8, 26)
colourback (41)
get Name : *
Font.Draw ("Please enter your address.", 200, 250, font1, red)
locate (11, 26)
colourback (41)
get Address : *
Font.Draw ("Please enter your phone number(no dashes).", 200, 200, font1, red)
locate (14, 26)
colourback (41)
get Pnumber : *
cls
menu
end TakeOut
proc Quit
end Quit
proc start
%title
Font.Draw ("Sam's Wakedywack Pizza!", 125, 350, font, red)
Font.Draw ("Please select one of the options or quit.", 150, 170, font1, red)
%buttons for title screen
var Delivery : int := GUI.CreateButton (100, 100, 0, "Delivery", Delivery )
var EatIn : int := GUI.CreateButton (300, 100, 0, "Eat In", EatIn )
var TakeOut : int := GUI.CreateButton (500, 100, 0, "Take Out", TakeOut )
var Quit : int := GUI.CreateButton (0, 375, 0, "Quit", Quit )
loop
exit when GUI.ProcessEvent
end loop
end start
start
|
Please specify what version of Turing you are using
<Answer Here> |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Dreadnought
|
Posted: Fri Jan 13, 2012 12:39 pm Post subject: Re: attempt to read past eof |
|
|
You haven't actually stated why you made this post, but I will assume want to know what the error "attempted to read past eof" means.
The eof is the End Of File. You the error is saying you tried to read past the end of the file. In other words you used get when there was nothing to "get".
Make sure that your text file is as long as you think it is, or ask Turing to check if you have reached the end of file before each get statement. |
|
|
|
|
|
Beastinonyou
|
Posted: Sat Jan 14, 2012 6:53 am Post subject: Re: attempt to read past eof |
|
|
Using eof, when you open your files and get info, it will have to look something like this:
Turing: |
open : file, "something.txt", get
loop
exit when eof (file )
% Code
end loop
|
|
|
|
|
|
|
mirhagk
|
Posted: Sat Jan 14, 2012 10:35 am Post subject: RE:attempt to read past eof |
|
|
@Beastinyou, in this circumstance he just has to ensure that there are 80 strings to get in the file. |
|
|
|
|
|
|
|