Help with Retrieving Data
Author |
Message |
Il Lupo
![](http://compsci.ca/v3/uploads/user_avatars/803204674df6833dd0512.png)
|
Posted: Sat Sep 24, 2011 9:55 pm Post subject: Help with Retrieving Data |
|
|
================================================================================
Issue:
====
I am creating a program for class that involves finding the mark of a person and then evaluating
it using an open/close program. To do this I incoporated arrays with the program. However, I can't retrive
any information from the text-file after inputting the mark. Therefore, I was wondering what the problem
may be - I assuming it is the way the loop has been setup but I am not sure how to fix it.
Program:
======
% Evaluates the mark of the student on what range there
% mark is or if they had failed.
var FileChannel : int
var evaluate : flexible array 1 .. 5 of string
var next : string (1)
var sum : real := 0
var mark : real
put "MARK EVALUATOR:"
put "---------------"
put "A = 80-100%"
put "B = 70-79%"
put "C = 60-69%"
put "D = 50-59%"
put "Fail = 49 & Below"
put "Note: -1 = Exit"
put ""
open : FileChannel, "F:\\SCHOOL\\ICS3U\\Turing 4.1.1\\Retrieve_Store\\Evaluate_Marks.txt", get
loop
put "Mark: " ..
get mark
exit when mark = -1
if mark >= 0 and mark <= 100 then
if mark >= 80 then
get : FileChannel, evaluate (upper (evaluate))
new evaluate, upper (evaluate) + 1
elsif mark >= 70 and mark <= 79 then
get : FileChannel, evaluate (upper (evaluate))
new evaluate, upper (evaluate) + 1
elsif mark >= 60 and mark <= 69 then
get : FileChannel, evaluate (upper (evaluate))
new evaluate, upper (evaluate) + 1
elsif mark >= 50 and mark <= 59 then
get : FileChannel, evaluate (upper (evaluate))
new evaluate, upper (evaluate) + 1
elsif mark <= 49 then
get : FileChannel, evaluate (upper (evaluate))
new evaluate, upper (evaluate) + 1
end if
exit when eof (FileChannel)
end if
end loop
close : FileChannel
Text-File:
======
(Contained the following information)
A - Above Provinicial Standards
B - Provincial Standards
C - About Provinical Standards
D - Below Provinical Standards
Fail - Could Not Meet Provincials Standards
================================================================================
I would like to thank in advance for the help and I apologize in advance for any grammer mistake. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Sat Sep 24, 2011 10:29 pm Post subject: Re: Help with Retrieving Data |
|
|
Il Lupo @ Sat Sep 24, 2011 9:55 pm wrote: I can't retrive
any information from the text-file after inputting the mark.
Is there an error? What does it say? |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
Il Lupo
![](http://compsci.ca/v3/uploads/user_avatars/803204674df6833dd0512.png)
|
Posted: Sun Sep 25, 2011 7:54 am Post subject: Re: Help with Retrieving Data |
|
|
Well, no there isn't any actual error. However, the problem is that everytime I input the mark,
the program finishes without completeing the next sequence. So I was wondering if there
was any mistakes or error on the program that may have caused this. Sorry for the vague
description. |
|
|
|
|
![](images/spacer.gif) |
Il Lupo
![](http://compsci.ca/v3/uploads/user_avatars/803204674df6833dd0512.png)
|
Posted: Mon Sep 26, 2011 5:13 pm Post subject: Re: Help with Retrieving Data |
|
|
Nevermind, I figured out how to execute the program. Sorry about that but, thanks for
the help anyway.
Simplified Program:
=============
var FileChannel : int
var grade : array 1 .. 20 of int
var count : int := 1
var average : real := 0
open : FileChannel, "F:\\SCHOOL\\ICS3U\\Turing 4.1.1\\Retrieve_Store\\Class_Grades.txt", get
put "TDSB CLASS ASSESSMENT"
put "COURSE: ISC-3U1"
put "====================="
loop
put "GRADE: " ..
get : FileChannel, grade (count)
put grade (count)
average := average + grade (count)
count := count + 1
exit when eof (FileChannel)
end loop
put ""
put "CLASS AVERAGE: ", round (average / 20), "%" |
|
|
|
|
![](images/spacer.gif) |
|
|