Urgent Help Needed For Program

Hi there.

I need urgent help with a program that needs to be in on tuesday. I am doing a lotto program that stores ones numbers in a data base and then one can type in the weeks numbers each week and it compares the weeks numbers to the numbers in the data base.

I have already error trapped it so one can only type in numbers between 1 and 49. My problem is that i dont know how to error trap it so that one can only enter a number once per row. At the moment one can enter (for example 1,1,1,1,1,2) which doesnt help. I need it that if one enters 1,2,3,1(print error message and allows user to re-enter a differnt number that he hasnt already used).

Anyone's help will be greatly appreciated...If anyone has a trapped lotto program that might help me plz send it to [email protected]

My code is as follows :

PROCEDURE Enter_Nums;
VAR
F_S : Integer;
Num : Array [1..6] Of Boolean;
BEGIN
Clearviewport;
Window(1,1,80,25);
Assign(LottoFile,'Lottos.dat');
Reset(LottoFile);
Write('Press [y/Y] To Enter a New Row Of Numbers Or Press Any Other Key To Return : ');
Ans := Readkey;
F_S := 0;
F_S := Filesize(LottoFile);
Seek(LottoFile,F_S);


IF Upcase(Ans) = 'Y' THEN
begin
REPEAT
WITH Lotto DO
begin
Window(1,1,80,25);
Clearviewport;
Writeln('Enter Your Lotto Numbers Between 1 And 49 : ');
FOR A := 1 TO 6 DO
begin
Readln(Actual[A]);
Val(Actual[A],Your_nums[A],Code);
IF CODE <> 0 THEN
REPEAT
Clearviewport;
Window(1,1,80,25);
Writeln('Invaild Entry, Please Enter a Number Between 1 And 49 : ');
Readln(Actual[A]);
Val(Actual[A],Your_nums[A],Code);
UNTIL Code = 0;

Lottotrue := (Your_Nums[A] >= 1) AND (Your_nums[A] <= 49);
IF Lottotrue THEN
Your_Nums[A] := Your_nums[A]
ELSE
REPEAT
Clearviewport;
Window(1,1,80,25);
Writeln('Invaild Entry, Please Enter a Number Between 1 And 49 : ');
Readln(Actual[A]);
VAL(Actual[A],Your_nums[A],CODE);
IF CODE <> 0 THEN
REPEAT
Clearviewport;
Window(1,1,80,25);
Writeln('Invaild Entry, Please Enter a Number Between 1 And 49 : ');
Readln(Actual[A]);
VAL(Actual[A],Your_nums[A],CODE);
UNTIL CODE = 0;
Lottotrue := (Your_Nums[A] >= 1) AND (Your_nums[A] <= 49);
UNTIL lottotrue;

end;

end;
Write(LottoFile, Lotto);
Clearviewport;
Window(1,1,80,25);
Write('Enter More Nums [Y/N] : ');
Ans := Readkey;
UNTIL upcase(ans) = 'N'
end;
Close(LottoFile);
END;

If anyone reqires my program plz mail me and i'll send it.
Thanks again
Soul-Fusion

Comments

  • : Hi there.
    :
    : I need urgent help with a program that needs to be in on tuesday. I am doing a lotto program that stores ones numbers in a data base and then one can type in the weeks numbers each week and it compares the weeks numbers to the numbers in the data base.
    :
    : I have already error trapped it so one can only type in numbers between 1 and 49. My problem is that i dont know how to error trap it so that one can only enter a number once per row. At the moment one can enter (for example 1,1,1,1,1,2) which doesnt help. I need it that if one enters 1,2,3,1(print error message and allows user to re-enter a differnt number that he hasnt already used).
    :
    : Anyone's help will be greatly appreciated...If anyone has a trapped lotto program that might help me plz send it to [email protected]
    :
    : My code is as follows :
    :
    : PROCEDURE Enter_Nums;
    : VAR
    : F_S : Integer;
    : Num : Array [1..6] Of Boolean;
    : BEGIN
    : Clearviewport;
    : Window(1,1,80,25);
    : Assign(LottoFile,'Lottos.dat');
    : Reset(LottoFile);
    : Write('Press [y/Y] To Enter a New Row Of Numbers Or Press Any Other Key To Return : ');
    : Ans := Readkey;
    : F_S := 0;
    : F_S := Filesize(LottoFile);
    : Seek(LottoFile,F_S);
    :
    :
    : IF Upcase(Ans) = 'Y' THEN
    : begin
    : REPEAT
    : WITH Lotto DO
    : begin
    : Window(1,1,80,25);
    : Clearviewport;
    : Writeln('Enter Your Lotto Numbers Between 1 And 49 : ');
    : FOR A := 1 TO 6 DO
    : begin
    : Readln(Actual[A]);
    : Val(Actual[A],Your_nums[A],Code);
    : IF CODE <> 0 THEN
    : REPEAT
    : Clearviewport;
    : Window(1,1,80,25);
    : Writeln('Invaild Entry, Please Enter a Number Between 1 And 49 : ');
    : Readln(Actual[A]);
    : Val(Actual[A],Your_nums[A],Code);
    : UNTIL Code = 0;
    :
    : Lottotrue := (Your_Nums[A] >= 1) AND (Your_nums[A] <= 49);
    : IF Lottotrue THEN
    : Your_Nums[A] := Your_nums[A]
    : ELSE
    : REPEAT
    : Clearviewport;
    : Window(1,1,80,25);
    : Writeln('Invaild Entry, Please Enter a Number Between 1 And 49 : ');
    : Readln(Actual[A]);
    : VAL(Actual[A],Your_nums[A],CODE);
    : IF CODE <> 0 THEN
    : REPEAT
    : Clearviewport;
    : Window(1,1,80,25);
    : Writeln('Invaild Entry, Please Enter a Number Between 1 And 49 : ');
    : Readln(Actual[A]);
    : VAL(Actual[A],Your_nums[A],CODE);
    : UNTIL CODE = 0;
    : Lottotrue := (Your_Nums[A] >= 1) AND (Your_nums[A] <= 49);
    : UNTIL lottotrue;
    :
    : end;
    :
    : end;
    : Write(LottoFile, Lotto);
    : Clearviewport;
    : Window(1,1,80,25);
    : Write('Enter More Nums [Y/N] : ');
    : Ans := Readkey;
    : UNTIL upcase(ans) = 'N'
    : end;
    : Close(LottoFile);
    : END;
    :
    : If anyone reqires my program plz mail me and i'll send it.
    : Thanks again
    : Soul-Fusion
    :
    :
    You need to compare the new entry with each previous entry. Here is a small code, which does just that.
    [code]
    FoundMatch := false;
    if A > 1 then { don't check first entry }
    for i := 1 to A - 1 do { run through all entries except last }
    if Your_Nums[i] = Your_Nums[A] then
    FoundMatch := true; { New entry matches one of the previous }
    if FoundMatch then begin
    { Perform some error message here and ask again }
    end;
    [/code]
    I think you will be able to insert this code in your entry-procedure.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion