whats up guys?
i need some help here desperately before new years day 2007.
The program was written in Turbo Pascal 7.0
The program asks the user a series of questions (each on a different screen) where the user either has to input Y or N (for yes or no).
However i am trying to figure out a way for the user to go back to the previous question at anytime and also a seperate function to exit to the main menu at any time...any ideas?
this is for a school project which has to be submitted before new years day.
thanks
Comments
:
: i need some help here desperately before new years day 2007.
: The program was written in Turbo Pascal 7.0
:
: The program asks the user a series of questions (each on a different screen) where the user either has to input Y or N (for yes or no).
: However i am trying to figure out a way for the user to go back to the previous question at anytime and also a seperate function to exit to the main menu at any time...any ideas?
:
: this is for a school project which has to be submitted before new years day.
: thanks
:
Depending on the rest of the code, you could keep track of the index of the current question. Then returning to the previous question will be as simple as decreasing the index and showing the current question.
Exiting from the current question, can be accomplished by presenting a 3rd choice to each question. This choice jumps back to the main menu.
: :
: : i need some help here desperately before new years day 2007.
: : The program was written in Turbo Pascal 7.0
: :
: : The program asks the user a series of questions (each on a different screen) where the user either has to input Y or N (for yes or no).
: : However i am trying to figure out a way for the user to go back to the previous question at anytime and also a seperate function to exit to the main menu at any time...any ideas?
: :
: : this is for a school project which has to be submitted before new years day.
: : thanks
: :
: Depending on the rest of the code, you could keep track of the index of the current question. Then returning to the previous question will be as simple as decreasing the index and showing the current question.
: Exiting from the current question, can be accomplished by presenting a 3rd choice to each question. This choice jumps back to the main menu.
:
thanks .....but the program sructure is pretty simple and does not have indexing as such...pls see a sample...of one of the procedures..
what happens is depending on the number of Y or N answers inputed by the user, the prgram would call the next appropriate procedure....the results are not stored in anyway...it is jus done via a counter...take a look:
procedure cataractinference;
begin
clrscr; pageheader('Cataract Testing - Inference');
if count >=4 then
begin
gotoxy(20,10);writeln('suspect cataract');
gotoxy(20,12);writeln('assign patient to cataract specialist');
readln;
end
else
uveitistest; {another procedure}
end;
procedure cataracttest;
begin
count := 0;
screenname := 'Cataract Testing';
askquestion(screenname,'Are you diabetic? Y/N');
askquestion(screenname,'Do colours appear to be faded or dull? Y/N');
askquestion(screenname,'Have you been overexposed to the sun in the past? Y/N');
askquestion(screenname,'Do lights appear to be too bright, or is there a halo around light? Y/N');
askquestion(screenname,'Do you have to change your eye prescription regularly? Y/N');
askquestion(screenname,'Do you have double vision? Y/N');
cataractinference;
end;
so as you can see, it is very difficult in this lay out to be able to go back to a prv question...any suggestions?
: : :
: : : i need some help here desperately before new years day 2007.
: : : The program was written in Turbo Pascal 7.0
: : :
: : : The program asks the user a series of questions (each on a different screen) where the user either has to input Y or N (for yes or no).
: : : However i am trying to figure out a way for the user to go back to the previous question at anytime and also a seperate function to exit to the main menu at any time...any ideas?
: : :
: : : this is for a school project which has to be submitted before new years day.
: : : thanks
: : :
: : Depending on the rest of the code, you could keep track of the index of the current question. Then returning to the previous question will be as simple as decreasing the index and showing the current question.
: : Exiting from the current question, can be accomplished by presenting a 3rd choice to each question. This choice jumps back to the main menu.
: :
:
:
: thanks .....but the program sructure is pretty simple and does not have indexing as such...pls see a sample...of one of the procedures..
:
: what happens is depending on the number of Y or N answers inputed by the user, the prgram would call the next appropriate procedure....the results are not stored in anyway...it is jus done via a counter...take a look:
:
: procedure cataractinference;
: begin
:
: clrscr; pageheader('Cataract Testing - Inference');
: if count >=4 then
: begin
: gotoxy(20,10);writeln('suspect cataract');
: gotoxy(20,12);writeln('assign patient to cataract specialist');
: readln;
: end
: else
: uveitistest; {another procedure}
: end;
:
:
: procedure cataracttest;
: begin
: count := 0;
: screenname := 'Cataract Testing';
: askquestion(screenname,'Are you diabetic? Y/N');
: askquestion(screenname,'Do colours appear to be faded or dull? Y/N');
: askquestion(screenname,'Have you been overexposed to the sun in the past? Y/N');
: askquestion(screenname,'Do lights appear to be too bright, or is there a halo around light? Y/N');
: askquestion(screenname,'Do you have to change your eye prescription regularly? Y/N');
: askquestion(screenname,'Do you have double vision? Y/N');
: cataractinference;
: end;
:
:
: so as you can see, it is very difficult in this lay out to be able to go back to a prv question...any suggestions?
:
:
Use a repeat-until loop around the askquestion() calls. Then using a case-of statement you can create the index method easily. This is not a very neat way to do, but it works. Example:
[code]
index := 0;
screenname := 'Cataract Testing';
repeat
case index of
0: askquestion(screenname,'Are you diabetic? Y/N');
1: askquestion(screenname,'Do colours appear to be faded or dull? Y/N');
2: askquestion(screenname,'Have you been overexposed to the sun in the past? Y/N');
{ Etc. }
5: askquestion(screenname,'Do you have double vision? Y/N');
else Exit; { Jump back to main menu }
end;
until index = 6 {number of questions };
cataractinference;
[/code]
: : : :
: : : : i need some help here desperately before new years day 2007.
: : : : The program was written in Turbo Pascal 7.0
: : : :
: : : : The program asks the user a series of questions (each on a different screen) where the user either has to input Y or N (for yes or no).
: : : : However i am trying to figure out a way for the user to go back to the previous question at anytime and also a seperate function to exit to the main menu at any time...any ideas?
: : : :
: : : : this is for a school project which has to be submitted before new years day.
: : : : thanks
: : : :
: : : Depending on the rest of the code, you could keep track of the index of the current question. Then returning to the previous question will be as simple as decreasing the index and showing the current question.
: : : Exiting from the current question, can be accomplished by presenting a 3rd choice to each question. This choice jumps back to the main menu.
: : :
: :
: :
: : thanks .....but the program sructure is pretty simple and does not have indexing as such...pls see a sample...of one of the procedures..
: :
: : what happens is depending on the number of Y or N answers inputed by the user, the prgram would call the next appropriate procedure....the results are not stored in anyway...it is jus done via a counter...take a look:
: :
: : procedure cataractinference;
: : begin
: :
: : clrscr; pageheader('Cataract Testing - Inference');
: : if count >=4 then
: : begin
: : gotoxy(20,10);writeln('suspect cataract');
: : gotoxy(20,12);writeln('assign patient to cataract specialist');
: : readln;
: : end
: : else
: : uveitistest; {another procedure}
: : end;
: :
: :
: : procedure cataracttest;
: : begin
: : count := 0;
: : screenname := 'Cataract Testing';
: : askquestion(screenname,'Are you diabetic? Y/N');
: : askquestion(screenname,'Do colours appear to be faded or dull? Y/N');
: : askquestion(screenname,'Have you been overexposed to the sun in the past? Y/N');
: : askquestion(screenname,'Do lights appear to be too bright, or is there a halo around light? Y/N');
: : askquestion(screenname,'Do you have to change your eye prescription regularly? Y/N');
: : askquestion(screenname,'Do you have double vision? Y/N');
: : cataractinference;
: : end;
: :
: :
: : so as you can see, it is very difficult in this lay out to be able to go back to a prv question...any suggestions?
: :
: :
: Use a repeat-until loop around the askquestion() calls. Then using a case-of statement you can create the index method easily. This is not a very neat way to do, but it works. Example:
: [code]
: index := 0;
: screenname := 'Cataract Testing';
: repeat
: case index of
: 0: askquestion(screenname,'Are you diabetic? Y/N');
: 1: askquestion(screenname,'Do colours appear to be faded or dull? Y/N');
: 2: askquestion(screenname,'Have you been overexposed to the sun in the past? Y/N');
: { Etc. }
: 5: askquestion(screenname,'Do you have double vision? Y/N');
: else Exit; { Jump back to main menu }
: end;
: until index = 6 {number of questions };
: cataractinference;
: [/code]
:
:
Thanks again for your help.
however, I am getting unknown identifier at the beginign at index, whichi suppose means the word index needs to be declared some where before....
what do i do.
2.) i see you removed the count function....i think i would need this function, becase remember, if you looked at my code, if a certain number of Y are met, it calls a procedure, else another output happens.
: : : : :
: : : : : i need some help here desperately before new years day 2007.
: : : : : The program was written in Turbo Pascal 7.0
: : : : :
: : : : : The program asks the user a series of questions (each on a different screen) where the user either has to input Y or N (for yes or no).
: : : : : However i am trying to figure out a way for the user to go back to the previous question at anytime and also a seperate function to exit to the main menu at any time...any ideas?
: : : : :
: : : : : this is for a school project which has to be submitted before new years day.
: : : : : thanks
: : : : :
: : : : Depending on the rest of the code, you could keep track of the index of the current question. Then returning to the previous question will be as simple as decreasing the index and showing the current question.
: : : : Exiting from the current question, can be accomplished by presenting a 3rd choice to each question. This choice jumps back to the main menu.
: : : :
: : :
: : :
: : : thanks .....but the program sructure is pretty simple and does not have indexing as such...pls see a sample...of one of the procedures..
: : :
: : : what happens is depending on the number of Y or N answers inputed by the user, the prgram would call the next appropriate procedure....the results are not stored in anyway...it is jus done via a counter...take a look:
: : :
: : : procedure cataractinference;
: : : begin
: : :
: : : clrscr; pageheader('Cataract Testing - Inference');
: : : if count >=4 then
: : : begin
: : : gotoxy(20,10);writeln('suspect cataract');
: : : gotoxy(20,12);writeln('assign patient to cataract specialist');
: : : readln;
: : : end
: : : else
: : : uveitistest; {another procedure}
: : : end;
: : :
: : :
: : : procedure cataracttest;
: : : begin
: : : count := 0;
: : : screenname := 'Cataract Testing';
: : : askquestion(screenname,'Are you diabetic? Y/N');
: : : askquestion(screenname,'Do colours appear to be faded or dull? Y/N');
: : : askquestion(screenname,'Have you been overexposed to the sun in the past? Y/N');
: : : askquestion(screenname,'Do lights appear to be too bright, or is there a halo around light? Y/N');
: : : askquestion(screenname,'Do you have to change your eye prescription regularly? Y/N');
: : : askquestion(screenname,'Do you have double vision? Y/N');
: : : cataractinference;
: : : end;
: : :
: : :
: : : so as you can see, it is very difficult in this lay out to be able to go back to a prv question...any suggestions?
: : :
: : :
: : Use a repeat-until loop around the askquestion() calls. Then using a case-of statement you can create the index method easily. This is not a very neat way to do, but it works. Example:
: : [code]
: : index := 0;
: : screenname := 'Cataract Testing';
: : repeat
: : case index of
: : 0: askquestion(screenname,'Are you diabetic? Y/N');
: : 1: askquestion(screenname,'Do colours appear to be faded or dull? Y/N');
: : 2: askquestion(screenname,'Have you been overexposed to the sun in the past? Y/N');
: : { Etc. }
: : 5: askquestion(screenname,'Do you have double vision? Y/N');
: : else Exit; { Jump back to main menu }
: : end;
: : until index = 6 {number of questions };
: : cataractinference;
: : [/code]
: :
: :
:
:
:
: Thanks again for your help.
: however, I am getting unknown identifier at the beginign at index, whichi suppose means the word index needs to be declared some where before....
:
: what do i do.
:
: 2.) i see you removed the count function....i think i would need this function, becase remember, if you looked at my code, if a certain number of Y are met, it calls a procedure, else another output happens.
:
Yeah, he just swapped names. Change the Index to Count and it should work.
The other way you could do it is like so:
[code]
CONST
CataractCount = 5;
CataractQuestions : Array[0..CataractCount] Of String =
('Are you diabetic?',
'Do colours appear to be faded or dull?',
'Have you been overexposed to the sun in the past?',
'Do lights appear to be too bright, or is there a halo around light?',
'Do you have to change your eye prescription regularly?',
'Do you have double vision?');
{...}
Begin
Count := 0;
screenname := 'Cataract Testing';
repeat
askquestion(screenname,CataractQuestions[Count]+' Y/N');
inc(Count)
until index = 6 {number of questions };
cataractinference;
End.
[/code]
You may want to look at changing your AskQuestion Procedure to a Function and have it return the Answer:
[code]
repeat
Case askquestion(screenname,CataractQuestions[Count]+' Y/N') Of
0,1 : inc(Count); { 0 = No, 1 = Yes }
2 : Dec(Count); { 2 = Back a Question }
3 : Break; { 3 = Quit Section }
End;
until index = 6 {number of questions };
[/code]
Phat Nat
: : : : : :
: : : : : : i need some help here desperately before new years day 2007.
: : : : : : The program was written in Turbo Pascal 7.0
: : : : : :
: : : : : : The program asks the user a series of questions (each on a different screen) where the user either has to input Y or N (for yes or no).
: : : : : : However i am trying to figure out a way for the user to go back to the previous question at anytime and also a seperate function to exit to the main menu at any time...any ideas?
: : : : : :
: : : : : : this is for a school project which has to be submitted before new years day.
: : : : : : thanks
: : : : : :
: : : : : Depending on the rest of the code, you could keep track of the index of the current question. Then returning to the previous question will be as simple as decreasing the index and showing the current question.
: : : : : Exiting from the current question, can be accomplished by presenting a 3rd choice to each question. This choice jumps back to the main menu.
: : : : :
: : : :
: : : :
: : : : thanks .....but the program sructure is pretty simple and does not have indexing as such...pls see a sample...of one of the procedures..
: : : :
: : : : what happens is depending on the number of Y or N answers inputed by the user, the prgram would call the next appropriate procedure....the results are not stored in anyway...it is jus done via a counter...take a look:
: : : :
: : : : procedure cataractinference;
: : : : begin
: : : :
: : : : clrscr; pageheader('Cataract Testing - Inference');
: : : : if count >=4 then
: : : : begin
: : : : gotoxy(20,10);writeln('suspect cataract');
: : : : gotoxy(20,12);writeln('assign patient to cataract specialist');
: : : : readln;
: : : : end
: : : : else
: : : : uveitistest; {another procedure}
: : : : end;
: : : :
: : : :
: : : : procedure cataracttest;
: : : : begin
: : : : count := 0;
: : : : screenname := 'Cataract Testing';
: : : : askquestion(screenname,'Are you diabetic? Y/N');
: : : : askquestion(screenname,'Do colours appear to be faded or dull? Y/N');
: : : : askquestion(screenname,'Have you been overexposed to the sun in the past? Y/N');
: : : : askquestion(screenname,'Do lights appear to be too bright, or is there a halo around light? Y/N');
: : : : askquestion(screenname,'Do you have to change your eye prescription regularly? Y/N');
: : : : askquestion(screenname,'Do you have double vision? Y/N');
: : : : cataractinference;
: : : : end;
: : : :
: : : :
: : : : so as you can see, it is very difficult in this lay out to be able to go back to a prv question...any suggestions?
: : : :
: : : :
: : : Use a repeat-until loop around the askquestion() calls. Then using a case-of statement you can create the index method easily. This is not a very neat way to do, but it works. Example:
: : : [code]
: : : index := 0;
: : : screenname := 'Cataract Testing';
: : : repeat
: : : case index of
: : : 0: askquestion(screenname,'Are you diabetic? Y/N');
: : : 1: askquestion(screenname,'Do colours appear to be faded or dull? Y/N');
: : : 2: askquestion(screenname,'Have you been overexposed to the sun in the past? Y/N');
: : : { Etc. }
: : : 5: askquestion(screenname,'Do you have double vision? Y/N');
: : : else Exit; { Jump back to main menu }
: : : end;
: : : until index = 6 {number of questions };
: : : cataractinference;
: : : [/code]
: : :
: : :
: :
: :
: :
: : Thanks again for your help.
: : however, I am getting unknown identifier at the beginign at index, whichi suppose means the word index needs to be declared some where before....
: :
: : what do i do.
: :
: : 2.) i see you removed the count function....i think i would need this function, becase remember, if you looked at my code, if a certain number of Y are met, it calls a procedure, else another output happens.
: :
: Yeah, he just swapped names. Change the Index to Count and it should work.
:
: The other way you could do it is like so:
: [code]
: CONST
: CataractCount = 5;
: CataractQuestions : Array[0..CataractCount] Of String =
: ('Are you diabetic?',
: 'Do colours appear to be faded or dull?',
: 'Have you been overexposed to the sun in the past?',
: 'Do lights appear to be too bright, or is there a halo around light?',
: 'Do you have to change your eye prescription regularly?',
: 'Do you have double vision?');
:
: {...}
:
: Begin
: Count := 0;
: screenname := 'Cataract Testing';
: repeat
: askquestion(screenname,CataractQuestions[Count]+' Y/N');
: inc(Count)
: until index = 6 {number of questions };
: cataractinference;
: End.
: [/code]
:
: You may want to look at changing your AskQuestion Procedure to a Function and have it return the Answer:
: [code]
: repeat
: Case askquestion(screenname,CataractQuestions[Count]+' Y/N') Of
: 0,1 : inc(Count); { 0 = No, 1 = Yes }
: 2 : Dec(Count); { 2 = Back a Question }
: 3 : Break; { 3 = Quit Section }
: End;
: until index = 6 {number of questions };
: [/code]
:
: Phat Nat
:
:
I didn't swap Count and Index, because Count determines if someone is suspected of cataract. I forgot Count, since it wasn't an important part of my example. Just add count to the example as shown with screenname.
: : : : : : :
: : : : : : : i need some help here desperately before new years day 2007.
: : : : : : : The program was written in Turbo Pascal 7.0
: : : : : : :
: : : : : : : The program asks the user a series of questions (each on a different screen) where the user either has to input Y or N (for yes or no).
: : : : : : : However i am trying to figure out a way for the user to go back to the previous question at anytime and also a seperate function to exit to the main menu at any time...any ideas?
: : : : : : :
: : : : : : : this is for a school project which has to be submitted before new years day.
: : : : : : : thanks
: : : : : : :
: : : : : : Depending on the rest of the code, you could keep track of the index of the current question. Then returning to the previous question will be as simple as decreasing the index and showing the current question.
: : : : : : Exiting from the current question, can be accomplished by presenting a 3rd choice to each question. This choice jumps back to the main menu.
: : : : : :
: : : : :
: : : : :
: : : : : thanks .....but the program sructure is pretty simple and does not have indexing as such...pls see a sample...of one of the procedures..
: : : : :
: : : : : what happens is depending on the number of Y or N answers inputed by the user, the prgram would call the next appropriate procedure....the results are not stored in anyway...it is jus done via a counter...take a look:
: : : : :
: : : : : procedure cataractinference;
: : : : : begin
: : : : :
: : : : : clrscr; pageheader('Cataract Testing - Inference');
: : : : : if count >=4 then
: : : : : begin
: : : : : gotoxy(20,10);writeln('suspect cataract');
: : : : : gotoxy(20,12);writeln('assign patient to cataract specialist');
: : : : : readln;
: : : : : end
: : : : : else
: : : : : uveitistest; {another procedure}
: : : : : end;
: : : : :
: : : : :
: : : : : procedure cataracttest;
: : : : : begin
: : : : : count := 0;
: : : : : screenname := 'Cataract Testing';
: : : : : askquestion(screenname,'Are you diabetic? Y/N');
: : : : : askquestion(screenname,'Do colours appear to be faded or dull? Y/N');
: : : : : askquestion(screenname,'Have you been overexposed to the sun in the past? Y/N');
: : : : : askquestion(screenname,'Do lights appear to be too bright, or is there a halo around light? Y/N');
: : : : : askquestion(screenname,'Do you have to change your eye prescription regularly? Y/N');
: : : : : askquestion(screenname,'Do you have double vision? Y/N');
: : : : : cataractinference;
: : : : : end;
: : : : :
: : : : :
: : : : : so as you can see, it is very difficult in this lay out to be able to go back to a prv question...any suggestions?
: : : : :
: : : : :
: : : : Use a repeat-until loop around the askquestion() calls. Then using a case-of statement you can create the index method easily. This is not a very neat way to do, but it works. Example:
: : : : [code]
: : : : index := 0;
: : : : screenname := 'Cataract Testing';
: : : : repeat
: : : : case index of
: : : : 0: askquestion(screenname,'Are you diabetic? Y/N');
: : : : 1: askquestion(screenname,'Do colours appear to be faded or dull? Y/N');
: : : : 2: askquestion(screenname,'Have you been overexposed to the sun in the past? Y/N');
: : : : { Etc. }
: : : : 5: askquestion(screenname,'Do you have double vision? Y/N');
: : : : else Exit; { Jump back to main menu }
: : : : end;
: : : : until index = 6 {number of questions };
: : : : cataractinference;
: : : : [/code]
: : : :
: : : :
: : :
: : :
: : :
: : : Thanks again for your help.
: : : however, I am getting unknown identifier at the beginign at index, whichi suppose means the word index needs to be declared some where before....
: : :
: : : what do i do.
: : :
: : : 2.) i see you removed the count function....i think i would need this function, becase remember, if you looked at my code, if a certain number of Y are met, it calls a procedure, else another output happens.
: : :
: : Yeah, he just swapped names. Change the Index to Count and it should work.
: :
: : The other way you could do it is like so:
: : [code]
: : CONST
: : CataractCount = 5;
: : CataractQuestions : Array[0..CataractCount] Of String =
: : ('Are you diabetic?',
: : 'Do colours appear to be faded or dull?',
: : 'Have you been overexposed to the sun in the past?',
: : 'Do lights appear to be too bright, or is there a halo around light?',
: : 'Do you have to change your eye prescription regularly?',
: : 'Do you have double vision?');
: :
: : {...}
: :
: : Begin
: : Count := 0;
: : screenname := 'Cataract Testing';
: : repeat
: : askquestion(screenname,CataractQuestions[Count]+' Y/N');
: : inc(Count)
: : until index = 6 {number of questions };
: : cataractinference;
: : End.
: : [/code]
: :
: : You may want to look at changing your AskQuestion Procedure to a Function and have it return the Answer:
: : [code]
: : repeat
: : Case askquestion(screenname,CataractQuestions[Count]+' Y/N') Of
: : 0,1 : inc(Count); { 0 = No, 1 = Yes }
: : 2 : Dec(Count); { 2 = Back a Question }
: : 3 : Break; { 3 = Quit Section }
: : End;
: : until index = 6 {number of questions };
: : [/code]
: :
: : Phat Nat
: :
: :
: I didn't swap Count and Index, because Count determines if someone is suspected of cataract. I forgot Count, since it wasn't an important part of my example. Just add count to the example as shown with screenname.
:
........uhhh...i'm lost
: : : : : : : :
: : : : : : : : i need some help here desperately before new years day 2007.
: : : : : : : : The program was written in Turbo Pascal 7.0
: : : : : : : :
: : : : : : : : The program asks the user a series of questions (each on a different screen) where the user either has to input Y or N (for yes or no).
: : : : : : : : However i am trying to figure out a way for the user to go back to the previous question at anytime and also a seperate function to exit to the main menu at any time...any ideas?
: : : : : : : :
: : : : : : : : this is for a school project which has to be submitted before new years day.
: : : : : : : : thanks
: : : : : : : :
: : : : : : : Depending on the rest of the code, you could keep track of the index of the current question. Then returning to the previous question will be as simple as decreasing the index and showing the current question.
: : : : : : : Exiting from the current question, can be accomplished by presenting a 3rd choice to each question. This choice jumps back to the main menu.
: : : : : : :
: : : : : :
: : : : : :
: : : : : : thanks .....but the program sructure is pretty simple and does not have indexing as such...pls see a sample...of one of the procedures..
: : : : : :
: : : : : : what happens is depending on the number of Y or N answers inputed by the user, the prgram would call the next appropriate procedure....the results are not stored in anyway...it is jus done via a counter...take a look:
: : : : : :
: : : : : : procedure cataractinference;
: : : : : : begin
: : : : : :
: : : : : : clrscr; pageheader('Cataract Testing - Inference');
: : : : : : if count >=4 then
: : : : : : begin
: : : : : : gotoxy(20,10);writeln('suspect cataract');
: : : : : : gotoxy(20,12);writeln('assign patient to cataract specialist');
: : : : : : readln;
: : : : : : end
: : : : : : else
: : : : : : uveitistest; {another procedure}
: : : : : : end;
: : : : : :
: : : : : :
: : : : : : procedure cataracttest;
: : : : : : begin
: : : : : : count := 0;
: : : : : : screenname := 'Cataract Testing';
: : : : : : askquestion(screenname,'Are you diabetic? Y/N');
: : : : : : askquestion(screenname,'Do colours appear to be faded or dull? Y/N');
: : : : : : askquestion(screenname,'Have you been overexposed to the sun in the past? Y/N');
: : : : : : askquestion(screenname,'Do lights appear to be too bright, or is there a halo around light? Y/N');
: : : : : : askquestion(screenname,'Do you have to change your eye prescription regularly? Y/N');
: : : : : : askquestion(screenname,'Do you have double vision? Y/N');
: : : : : : cataractinference;
: : : : : : end;
: : : : : :
: : : : : :
: : : : : : so as you can see, it is very difficult in this lay out to be able to go back to a prv question...any suggestions?
: : : : : :
: : : : : :
: : : : : Use a repeat-until loop around the askquestion() calls. Then using a case-of statement you can create the index method easily. This is not a very neat way to do, but it works. Example:
: : : : : [code]
: : : : : index := 0;
: : : : : screenname := 'Cataract Testing';
: : : : : repeat
: : : : : case index of
: : : : : 0: askquestion(screenname,'Are you diabetic? Y/N');
: : : : : 1: askquestion(screenname,'Do colours appear to be faded or dull? Y/N');
: : : : : 2: askquestion(screenname,'Have you been overexposed to the sun in the past? Y/N');
: : : : : { Etc. }
: : : : : 5: askquestion(screenname,'Do you have double vision? Y/N');
: : : : : else Exit; { Jump back to main menu }
: : : : : end;
: : : : : until index = 6 {number of questions };
: : : : : cataractinference;
: : : : : [/code]
: : : : :
: : : : :
: : : :
: : : :
: : : :
: : : : Thanks again for your help.
: : : : however, I am getting unknown identifier at the beginign at index, whichi suppose means the word index needs to be declared some where before....
: : : :
: : : : what do i do.
: : : :
: : : : 2.) i see you removed the count function....i think i would need this function, becase remember, if you looked at my code, if a certain number of Y are met, it calls a procedure, else another output happens.
: : : :
: : : Yeah, he just swapped names. Change the Index to Count and it should work.
: : :
: : : The other way you could do it is like so:
: : : [code]
: : : CONST
: : : CataractCount = 5;
: : : CataractQuestions : Array[0..CataractCount] Of String =
: : : ('Are you diabetic?',
: : : 'Do colours appear to be faded or dull?',
: : : 'Have you been overexposed to the sun in the past?',
: : : 'Do lights appear to be too bright, or is there a halo around light?',
: : : 'Do you have to change your eye prescription regularly?',
: : : 'Do you have double vision?');
: : :
: : : {...}
: : :
: : : Begin
: : : Count := 0;
: : : screenname := 'Cataract Testing';
: : : repeat
: : : askquestion(screenname,CataractQuestions[Count]+' Y/N');
: : : inc(Count)
: : : until index = 6 {number of questions };
: : : cataractinference;
: : : End.
: : : [/code]
: : :
: : : You may want to look at changing your AskQuestion Procedure to a Function and have it return the Answer:
: : : [code]
: : : repeat
: : : Case askquestion(screenname,CataractQuestions[Count]+' Y/N') Of
: : : 0,1 : inc(Count); { 0 = No, 1 = Yes }
: : : 2 : Dec(Count); { 2 = Back a Question }
: : : 3 : Break; { 3 = Quit Section }
: : : End;
: : : until index = 6 {number of questions };
: : : [/code]
: : :
: : : Phat Nat
: : :
: : :
: : I didn't swap Count and Index, because Count determines if someone is suspected of cataract. I forgot Count, since it wasn't an important part of my example. Just add count to the example as shown with screenname.
: :
: ........uhhh...i'm lost
:
Index holds the index of the current question, which is shown to the user. Count is still the same as in your original program. Based on your original code it is the number of times the user answered yes. The only addition to your program I made, was an repeat-until loop, case-of statement and the Index variable to control which question is shown. All other code is exactly the same.
: : : : :
: : : : : i need some help here desperately before new years day 2007.
: : : : : The program was written in Turbo Pascal 7.0
: : : : :
: : : : : The program asks the user a series of questions (each on a different screen) where the user either has to input Y or N (for yes or no).
: : : : : However i am trying to figure out a way for the user to go back to the previous question at anytime and also a seperate function to exit to the main menu at any time...any ideas?
: : : : :
: : : : : this is for a school project which has to be submitted before new years day.
: : : : : thanks
: : : : :
: : : : Depending on the rest of the code, you could keep track of the index of the current question. Then returning to the previous question will be as simple as decreasing the index and showing the current question.
: : : : Exiting from the current question, can be accomplished by presenting a 3rd choice to each question. This choice jumps back to the main menu.
: : : :
: : :
: : :
: : : thanks .....but the program sructure is pretty simple and does not have indexing as such...pls see a sample...of one of the procedures..
: : :
: : : what happens is depending on the number of Y or N answers inputed by the user, the prgram would call the next appropriate procedure....the results are not stored in anyway...it is jus done via a counter...take a look:
: : :
: : : procedure cataractinference;
: : : begin
: : :
: : : clrscr; pageheader('Cataract Testing - Inference');
: : : if count >=4 then
: : : begin
: : : gotoxy(20,10);writeln('suspect cataract');
: : : gotoxy(20,12);writeln('assign patient to cataract specialist');
: : : readln;
: : : end
: : : else
: : : uveitistest; {another procedure}
: : : end;
: : :
: : :
: : : procedure cataracttest;
: : : begin
: : : count := 0;
: : : screenname := 'Cataract Testing';
: : : askquestion(screenname,'Are you diabetic? Y/N');
: : : askquestion(screenname,'Do colours appear to be faded or dull? Y/N');
: : : askquestion(screenname,'Have you been overexposed to the sun in the past? Y/N');
: : : askquestion(screenname,'Do lights appear to be too bright, or is there a halo around light? Y/N');
: : : askquestion(screenname,'Do you have to change your eye prescription regularly? Y/N');
: : : askquestion(screenname,'Do you have double vision? Y/N');
: : : cataractinference;
: : : end;
: : :
: : :
: : : so as you can see, it is very difficult in this lay out to be able to go back to a prv question...any suggestions?
: : :
: : :
: : Use a repeat-until loop around the askquestion() calls. Then using a case-of statement you can create the index method easily. This is not a very neat way to do, but it works. Example:
: : [code]
: : index := 0;
: : screenname := 'Cataract Testing';
: : repeat
: : case index of
: : 0: askquestion(screenname,'Are you diabetic? Y/N');
: : 1: askquestion(screenname,'Do colours appear to be faded or dull? Y/N');
: : 2: askquestion(screenname,'Have you been overexposed to the sun in the past? Y/N');
: : { Etc. }
: : 5: askquestion(screenname,'Do you have double vision? Y/N');
: : else Exit; { Jump back to main menu }
: : end;
: : until index = 6 {number of questions };
: : cataractinference;
: : [/code]
: :
: :
:
:
:
: Thanks again for your help.
: however, I am getting unknown identifier at the beginign at index, whichi suppose means the word index needs to be declared some where before....
:
: what do i do.
:
: 2.) i see you removed the count function....i think i would need this function, becase remember, if you looked at my code, if a certain number of Y are met, it calls a procedure, else another output happens.
:
:
:
ok i got it....i implemented the code, so it now looks like:
[code]
procedure cataractinference;
begin
clrscr; pageheader('Cataract Testing - Inference');
if count >=4 then
begin
gotoxy(20,10);writeln('suspect cataract');
gotoxy(20,12);writeln('assign patient to cataract specialist');
readln;
end
else
uveitistest;
end;
procedure cataracttest;
begin
count := 0;
index:=0;
repeat
screenname := 'Cataract Testing';
case index of
0: askquestion(screenname,'Are you diabetic? Y/N');
1: askquestion(screenname,'Do colours appear to be faded or dull? Y/N');
2: askquestion(screenname,'Have you been overexposed to the sun in the past? Y/N');
3: askquestion(screenname,'Do lights appear to be too bright, or is there a halo around light? Y/N');
4: askquestion(screenname,'Do you have to change your eye prescription regularly? Y/N');
5: askquestion(screenname,'Do you have double vision? Y/N');
else Exit;
end;
until index=6;
cataractinference;
readln;
end;
[/code]
the program runs now...but when it comes to the first question which is
"are you diabetic Y/N"? and i enter any value..whether it be Y /or N or anything, the program just stays there and i have to use the ctrl break function to exit...but it used to work before.... *confused*
: : : : : :
: : : : : : i need some help here desperately before new years day 2007.
: : : : : : The program was written in Turbo Pascal 7.0
: : : : : :
: : : : : : The program asks the user a series of questions (each on a different screen) where the user either has to input Y or N (for yes or no).
: : : : : : However i am trying to figure out a way for the user to go back to the previous question at anytime and also a seperate function to exit to the main menu at any time...any ideas?
: : : : : :
: : : : : : this is for a school project which has to be submitted before new years day.
: : : : : : thanks
: : : : : :
: : : : : Depending on the rest of the code, you could keep track of the index of the current question. Then returning to the previous question will be as simple as decreasing the index and showing the current question.
: : : : : Exiting from the current question, can be accomplished by presenting a 3rd choice to each question. This choice jumps back to the main menu.
: : : : :
: : : :
: : : :
: : : : thanks .....but the program sructure is pretty simple and does not have indexing as such...pls see a sample...of one of the procedures..
: : : :
: : : : what happens is depending on the number of Y or N answers inputed by the user, the prgram would call the next appropriate procedure....the results are not stored in anyway...it is jus done via a counter...take a look:
: : : :
: : : : procedure cataractinference;
: : : : begin
: : : :
: : : : clrscr; pageheader('Cataract Testing - Inference');
: : : : if count >=4 then
: : : : begin
: : : : gotoxy(20,10);writeln('suspect cataract');
: : : : gotoxy(20,12);writeln('assign patient to cataract specialist');
: : : : readln;
: : : : end
: : : : else
: : : : uveitistest; {another procedure}
: : : : end;
: : : :
: : : :
: : : : procedure cataracttest;
: : : : begin
: : : : count := 0;
: : : : screenname := 'Cataract Testing';
: : : : askquestion(screenname,'Are you diabetic? Y/N');
: : : : askquestion(screenname,'Do colours appear to be faded or dull? Y/N');
: : : : askquestion(screenname,'Have you been overexposed to the sun in the past? Y/N');
: : : : askquestion(screenname,'Do lights appear to be too bright, or is there a halo around light? Y/N');
: : : : askquestion(screenname,'Do you have to change your eye prescription regularly? Y/N');
: : : : askquestion(screenname,'Do you have double vision? Y/N');
: : : : cataractinference;
: : : : end;
: : : :
: : : :
: : : : so as you can see, it is very difficult in this lay out to be able to go back to a prv question...any suggestions?
: : : :
: : : :
: : : Use a repeat-until loop around the askquestion() calls. Then using a case-of statement you can create the index method easily. This is not a very neat way to do, but it works. Example:
: : : [code]
: : : index := 0;
: : : screenname := 'Cataract Testing';
: : : repeat
: : : case index of
: : : 0: askquestion(screenname,'Are you diabetic? Y/N');
: : : 1: askquestion(screenname,'Do colours appear to be faded or dull? Y/N');
: : : 2: askquestion(screenname,'Have you been overexposed to the sun in the past? Y/N');
: : : { Etc. }
: : : 5: askquestion(screenname,'Do you have double vision? Y/N');
: : : else Exit; { Jump back to main menu }
: : : end;
: : : until index = 6 {number of questions };
: : : cataractinference;
: : : [/code]
: : :
: : :
: :
: :
: :
: : Thanks again for your help.
: : however, I am getting unknown identifier at the beginign at index, whichi suppose means the word index needs to be declared some where before....
: :
: : what do i do.
: :
: : 2.) i see you removed the count function....i think i would need this function, becase remember, if you looked at my code, if a certain number of Y are met, it calls a procedure, else another output happens.
: :
: :
: :
:
: ok i got it....i implemented the code, so it now looks like:
:
: [code]
: procedure cataractinference;
: begin
:
: clrscr; pageheader('Cataract Testing - Inference');
: if count >=4 then
: begin
: gotoxy(20,10);writeln('suspect cataract');
: gotoxy(20,12);writeln('assign patient to cataract specialist');
: readln;
: end
: else
: uveitistest;
: end;
:
:
: procedure cataracttest;
: begin
: count := 0;
: index:=0;
: repeat
: screenname := 'Cataract Testing';
: case index of
: 0: askquestion(screenname,'Are you diabetic? Y/N');
: 1: askquestion(screenname,'Do colours appear to be faded or dull? Y/N');
: 2: askquestion(screenname,'Have you been overexposed to the sun in the past? Y/N');
: 3: askquestion(screenname,'Do lights appear to be too bright, or is there a halo around light? Y/N');
: 4: askquestion(screenname,'Do you have to change your eye prescription regularly? Y/N');
: 5: askquestion(screenname,'Do you have double vision? Y/N');
: else Exit;
: end;
: until index=6;
: cataractinference;
:
: readln;
: end;
:
: [/code]
:
: the program runs now...but when it comes to the first question which is
: "are you diabetic Y/N"? and i enter any value..whether it be Y /or N or anything, the program just stays there and i have to use the ctrl break function to exit...but it used to work before.... *confused*
:
After each question, you should increase the index by 1 to go to the next question. Remember that the value stored in the Index variable determines which question the user gets to see, not the order in which the questions are coded.
: : : : : : :
: : : : : : : i need some help here desperately before new years day 2007.
: : : : : : : The program was written in Turbo Pascal 7.0
: : : : : : :
: : : : : : : The program asks the user a series of questions (each on a different screen) where the user either has to input Y or N (for yes or no).
: : : : : : : However i am trying to figure out a way for the user to go back to the previous question at anytime and also a seperate function to exit to the main menu at any time...any ideas?
: : : : : : :
: : : : : : : this is for a school project which has to be submitted before new years day.
: : : : : : : thanks
trying...but only getting errors......pls help...can u do the code....? thanks...
: : : : : : :
: : : : : : Depending on the rest of the code, you could keep track of the index of the current question. Then returning to the previous question will be as simple as decreasing the index and showing the current question.
: : : : : : Exiting from the current question, can be accomplished by presenting a 3rd choice to each question. This choice jumps back to the main menu.
: : : : : :
: : : : :
: : : : :
: : : : : thanks .....but the program sructure is pretty simple and does not have indexing as such...pls see a sample...of one of the procedures..
: : : : :
: : : : : what happens is depending on the number of Y or N answers inputed by the user, the prgram would call the next appropriate procedure....the results are not stored in anyway...it is jus done via a counter...take a look:
: : : : :
: : : : : procedure cataractinference;
: : : : : begin
: : : : :
: : : : : clrscr; pageheader('Cataract Testing - Inference');
: : : : : if count >=4 then
: : : : : begin
: : : : : gotoxy(20,10);writeln('suspect cataract');
: : : : : gotoxy(20,12);writeln('assign patient to cataract specialist');
: : : : : readln;
: : : : : end
: : : : : else
: : : : : uveitistest; {another procedure}
: : : : : end;
: : : : :
: : : : :
: : : : : procedure cataracttest;
: : : : : begin
: : : : : count := 0;
: : : : : screenname := 'Cataract Testing';
: : : : : askquestion(screenname,'Are you diabetic? Y/N');
: : : : : askquestion(screenname,'Do colours appear to be faded or dull? Y/N');
: : : : : askquestion(screenname,'Have you been overexposed to the sun in the past? Y/N');
: : : : : askquestion(screenname,'Do lights appear to be too bright, or is there a halo around light? Y/N');
: : : : : askquestion(screenname,'Do you have to change your eye prescription regularly? Y/N');
: : : : : askquestion(screenname,'Do you have double vision? Y/N');
: : : : : cataractinference;
: : : : : end;
: : : : :
: : : : :
: : : : : so as you can see, it is very difficult in this lay out to be able to go back to a prv question...any suggestions?
: : : : :
: : : : :
: : : : Use a repeat-until loop around the askquestion() calls. Then using a case-of statement you can create the index method easily. This is not a very neat way to do, but it works. Example:
: : : : [code]
: : : : index := 0;
: : : : screenname := 'Cataract Testing';
: : : : repeat
: : : : case index of
: : : : 0: askquestion(screenname,'Are you diabetic? Y/N');
: : : : 1: askquestion(screenname,'Do colours appear to be faded or dull? Y/N');
: : : : 2: askquestion(screenname,'Have you been overexposed to the sun in the past? Y/N');
: : : : { Etc. }
: : : : 5: askquestion(screenname,'Do you have double vision? Y/N');
: : : : else Exit; { Jump back to main menu }
: : : : end;
: : : : until index = 6 {number of questions };
: : : : cataractinference;
: : : : [/code]
: : : :
: : : :
: : :
: : :
: : :
: : : Thanks again for your help.
: : : however, I am getting unknown identifier at the beginign at index, whichi suppose means the word index needs to be declared some where before....
: : :
: : : what do i do.
: : :
: : : 2.) i see you removed the count function....i think i would need this function, becase remember, if you looked at my code, if a certain number of Y are met, it calls a procedure, else another output happens.
: : :
: : :
: : :
: :
: : ok i got it....i implemented the code, so it now looks like:
: :
: : [code]
: : procedure cataractinference;
: : begin
: :
: : clrscr; pageheader('Cataract Testing - Inference');
: : if count >=4 then
: : begin
: : gotoxy(20,10);writeln('suspect cataract');
: : gotoxy(20,12);writeln('assign patient to cataract specialist');
: : readln;
: : end
: : else
: : uveitistest;
: : end;
: :
: :
: : procedure cataracttest;
: : begin
: : count := 0;
: : index:=0;
: : repeat
: : screenname := 'Cataract Testing';
: : case index of
: : 0: askquestion(screenname,'Are you diabetic? Y/N');
: : 1: askquestion(screenname,'Do colours appear to be faded or dull? Y/N');
: : 2: askquestion(screenname,'Have you been overexposed to the sun in the past? Y/N');
: : 3: askquestion(screenname,'Do lights appear to be too bright, or is there a halo around light? Y/N');
: : 4: askquestion(screenname,'Do you have to change your eye prescription regularly? Y/N');
: : 5: askquestion(screenname,'Do you have double vision? Y/N');
: : else Exit;
: : end;
: : until index=6;
: : cataractinference;
: :
: : readln;
: : end;
: :
: : [/code]
: :
: : the program runs now...but when it comes to the first question which is
: : "are you diabetic Y/N"? and i enter any value..whether it be Y /or N or anything, the program just stays there and i have to use the ctrl break function to exit...but it used to work before.... *confused*
: :
: After each question, you should increase the index by 1 to go to the next question. Remember that the value stored in the Index variable determines which question the user gets to see, not the order in which the questions are coded.
: