Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4095
Number of posts: 14004

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Invalid Variable Reference? Posted by FyreAndIce83 on 11 Oct 2003 at 5:47 PM
First...I don't know what the error means but...could someone please offer me a hand as to why the error is there and how I can get rid of it to finish this program. Remember, this is just a fragment so far...

PROGRAM Charges;
USES CRT;

VAR

UserAccount : String[5];
PriorityCode, NumberCustomer : Integer;
UseHours, HourCharge, AveCharge, PriorityCharge, TotalCharge : Real;

Procedure Headings;

Begin

Writeln(' Apex Computer Service');
Writeln;
Writeln(' Account Charge');
Writeln(' --------- --------');

End;

Procedure GetInfo;

Begin

Writeln(' Please Input Your User Account Number: ');
Readln(UserAccount);
Writeln(' Please Input Your Priority Code: ');
Readln(PriorityCode);
Writeln(' Please Input Your Hours of Usage: ');
Readln(UseHours);

End;

Procedure LoopingIt;

Begin

WHILE UserAccount <> 'xxxxx' DO

Begin

IF (UseHours > 15.00) THEN
HourCharge := (225.00 + (15.00 * UseHours))

ELSE (UseHours > 5.00) AND (UseHours <= 15.00)
HourCharge := (100.00 + (25.00 * UseHours))

ELSE
HourCharge := 100.00;

End;
End;
End;

BEGIN

CLRSCR;
Headings;
GetInfo;
LoopingIt;
CalcCharge;

END.

Report
Re: Invalid Variable Reference? Posted by zibadian on 11 Oct 2003 at 10:45 PM
: First...I don't know what the error means but...could someone please offer me a hand as to why the error is there and how I can get rid of it to finish this program. Remember, this is just a fragment so far...
:
: PROGRAM Charges;
: USES CRT;
:
: VAR
:
: UserAccount : String[5];
: PriorityCode, NumberCustomer : Integer;
: UseHours, HourCharge, AveCharge, PriorityCharge, TotalCharge : Real;
:
: Procedure Headings;
:
: Begin
:
: Writeln(' Apex Computer Service');
: Writeln;
: Writeln(' Account Charge');
: Writeln(' --------- --------');
:
: End;
:
: Procedure GetInfo;
:
: Begin
:
: Writeln(' Please Input Your User Account Number: ');
: Readln(UserAccount);
: Writeln(' Please Input Your Priority Code: ');
: Readln(PriorityCode);
: Writeln(' Please Input Your Hours of Usage: ');
: Readln(UseHours);
:
: End;
:
: Procedure LoopingIt;
:
: Begin
:
: WHILE UserAccount <> 'xxxxx' DO
:
: Begin
:
: IF (UseHours > 15.00) THEN
: HourCharge := (225.00 + (15.00 * UseHours))
:
: ELSE (UseHours > 5.00) AND (UseHours <= 15.00)
: HourCharge := (100.00 + (25.00 * UseHours))
:
: ELSE
: HourCharge := 100.00;
:
: End;
: End;
: End;
:
: BEGIN
:
: CLRSCR;
: Headings;
: GetInfo;
: LoopingIt;
: CalcCharge;
:
: END.
:
:
The "Invalid Variable Reference" means that the compiler cannot a certain statement, unless the variables it uses are of identical formats.
Given the fact that you want us to guess where the error occurred, my guess is that it occurred in the while-do. You could try to solve it by changing the type of the UserAccount into a normal string.
Also you have created an infinite loop, because the user cannot change the UserAccount from within the while-do.
Report
Re: Invalid Variable Reference? Posted by Perran on 12 Oct 2003 at 4:14 AM
: First...I don't know what the error means but...could someone please offer me a hand as to why the error is there and how I can get rid of it to finish this program. Remember, this is just a fragment so far...
:
: PROGRAM Charges;
: USES CRT;
:
: VAR
:
: UserAccount : String[5];
: PriorityCode, NumberCustomer : Integer;
: UseHours, HourCharge, AveCharge, PriorityCharge, TotalCharge : Real;
:
: Procedure Headings;
:
: Begin
:
: Writeln(' Apex Computer Service');
: Writeln;
: Writeln(' Account Charge');
: Writeln(' --------- --------');
:
: End;
:
: Procedure GetInfo;
:
: Begin
:
: Writeln(' Please Input Your User Account Number: ');
: Readln(UserAccount);
: Writeln(' Please Input Your Priority Code: ');
: Readln(PriorityCode);
: Writeln(' Please Input Your Hours of Usage: ');
: Readln(UseHours);
:
: End;
:
: Procedure LoopingIt;
:
: Begin
:
: WHILE UserAccount <> 'xxxxx' DO
:
: Begin
:
: IF (UseHours > 15.00) THEN
: HourCharge := (225.00 + (15.00 * UseHours))
:
: ELSE (UseHours > 5.00) AND (UseHours <= 15.00)
: HourCharge := (100.00 + (25.00 * UseHours))
:
: ELSE
: HourCharge := 100.00;
:
: End;
: End;
: End;
:
: BEGIN
:
: CLRSCR;
: Headings;
: GetInfo;
: LoopingIt;
: CalcCharge;
:
: END.
:
:
In addition to Zibadian's comments, I would like to point out that there is a call to "CalcCharge" which doesn't appear to exist.
Report
Re: Invalid Variable Reference? Posted by FyreAndIce83 on 13 Oct 2003 at 4:16 AM
(Initial Code Was Here)
: In addition to Zibadian's comments, I would like to point out that there is a call to "CalcCharge" which doesn't appear to exist.
:

Alright, I changed some things, but am getting an error compiling using a procedure in the loop. I believe it is the CalcCharge procedure that contains the error. Please let me know how to fix it?

PROGRAM Charges;
USES CRT;

VAR

UserAccount : String;
PriorityCode, NumberCustomer : Integer;
UseHours, HourCharge, AveCharge, PriorityCharge, TotalCharge : Real;

Procedure Headings;

Begin

Writeln(' Apex Computer Service');
Writeln;
Writeln(' Account Charge');
Writeln(' --------- --------');

End;

Procedure GetInfo;

Begin

Writeln(' Please Input Your User Account Number: ');
Readln(UserAccount);
Writeln(' Please Input Your Priority Code: ');
Readln(PriorityCode);
Writeln(' Please Input Your Hours of Usage: ');
Readln(UseHours);

End;

Procedure LoopingIt;

Begin

WHILE UserAccount <> 'xxxxx' DO

Begin

Procedure CalcCharge;

Begin

IF (UseHours > 15.00) THEN
HourCharge := (225.00 + (15.00 * UseHours));

ELSE (UseHours > 5.00) AND (UseHours <= 15.00)
HourCharge := (100.00 + (25.00 * UseHours));

ELSE
HourCharge := 100.00;

IF PriorityCode = 0 THEN
TotalCharge := HourCharge

ELSE
PriorityCode = 1 THEN
TotalCharge := (HourCharge + 50);

ELSE
PriorityCode = 2 THEN
TotalCharge := (HourCharge + 100);

End;


Procedure ShowData;

Begin

Writeln(Headings);
Writeln(TotalCharge);

End;

GetInfo;
End;

BEGIN

CLRSCR;
Headings;
GetInfo;
LoopingIt;
CalcCharge;
ShowData;

END.

Report
Re: Invalid Variable Reference? Posted by zibadian on 13 Oct 2003 at 11:05 AM
: (Initial Code Was Here)
: : In addition to Zibadian's comments, I would like to point out that there is a call to "CalcCharge" which doesn't appear to exist.
: :
:
: Alright, I changed some things, but am getting an error compiling using a procedure in the loop. I believe it is the CalcCharge procedure that contains the error. Please let me know how to fix it?
:
: PROGRAM Charges;
: USES CRT;
:
: VAR
:
: UserAccount : String;
: PriorityCode, NumberCustomer : Integer;
: UseHours, HourCharge, AveCharge, PriorityCharge, TotalCharge : Real;
:
: Procedure Headings;
:
: Begin
:
: Writeln(' Apex Computer Service');
: Writeln;
: Writeln(' Account Charge');
: Writeln(' --------- --------');
:
: End;
:
: Procedure GetInfo;
:
: Begin
:
: Writeln(' Please Input Your User Account Number: ');
: Readln(UserAccount);
: Writeln(' Please Input Your Priority Code: ');
: Readln(PriorityCode);
: Writeln(' Please Input Your Hours of Usage: ');
: Readln(UseHours);
:
: End;
:
: Procedure LoopingIt;
:
: Begin
:
: WHILE UserAccount <> 'xxxxx' DO
:
: Begin
:
: Procedure CalcCharge;
:
: Begin
:
: IF (UseHours > 15.00) THEN
: HourCharge := (225.00 + (15.00 * UseHours));
:
: ELSE (UseHours > 5.00) AND (UseHours <= 15.00)
: HourCharge := (100.00 + (25.00 * UseHours));
:
: ELSE
: HourCharge := 100.00;
:
: IF PriorityCode = 0 THEN
: TotalCharge := HourCharge
:
: ELSE
: PriorityCode = 1 THEN
: TotalCharge := (HourCharge + 50);
:
: ELSE
: PriorityCode = 2 THEN
: TotalCharge := (HourCharge + 100);
:
: End;
:
:
: Procedure ShowData;
:
: Begin
:
: Writeln(Headings);
: Writeln(TotalCharge);
:
: End;
:
: GetInfo;
: End;
:
: BEGIN
:
: CLRSCR;
: Headings;
: GetInfo;
: LoopingIt;
: CalcCharge;
: ShowData;
:
: END.
:
:
The main problem with this code is, that you try to declare a procedure within the execution of another procedure. I know of absolutely no language, which allows that.
You need to move the CalcCharge() and ShowData() procedure declarations out of the procedure LoopingIt(). Secondly in Pascal you never place a semicolon before an else, because the if-then-else statement is compiled as being a single Pascal statement.
Report
Re: Invalid Variable Reference? Posted by FyreAndIce83 on 14 Oct 2003 at 9:30 AM
First off, I want to thank you all for all your help, I am certainly grateful to you all. Anyway, the good news, I got rid of the nasty errors. Now all I need to do is get the infinite loop to stop and get the results I'd like. How is that achieved in this situation? Code follows:

VAR

UserAccount : String[5];
PriorityCode, NumberCustomer : Integer;
UseHours, HourCharge, AveCharge, PriorityCharge, TotalCharge : Real;

Procedure Headings;

Begin

Writeln(' Apex Computer Service');
Writeln;
Writeln(' Account Charge');
Writeln(' --------- --------');

End;

Procedure GetInfo;

Begin

Writeln(' Please Input Your User Account Number: ');
Readln(UserAccount);
Writeln(' Please Input Your Priority Code: ');
Readln(PriorityCode);
Writeln(' Please Input Your Hours of Usage: ');
Readln(UseHours);

End;

Procedure LoopingIt;

Begin

WHILE UserAccount <> 'xxxxx' DO

Begin


{Calculating of Charges Begins Here}

IF (UseHours > 15.00) THEN
HourCharge := (225.00 + (15.00 * UseHours));

IF (UseHours > 5.00) AND (UseHours <= 15.00) THEN
HourCharge := (100.00 + (25.00 * UseHours));

IF (UseHours <= 5.00) THEN
HourCharge := 100.00;

IF PriorityCode = 0 THEN
TotalCharge := HourCharge;

IF
PriorityCode = 1 THEN
TotalCharge := (HourCharge + 50);

IF
PriorityCode = 2 THEN
TotalCharge := (HourCharge + 100);

End;


{ Data Output Begins Here}

Begin

Writeln(TotalCharge);

End;

GetInfo;
End;

BEGIN

CLRSCR;
GetInfo;
LoopingIt;
Headings;

END.

Report
Re: Invalid Variable Reference? Posted by zibadian on 14 Oct 2003 at 12:37 PM
: First off, I want to thank you all for all your help, I am certainly grateful to you all. Anyway, the good news, I got rid of the nasty errors. Now all I need to do is get the infinite loop to stop and get the results I'd like. How is that achieved in this situation? Code follows:
:
: VAR
:
: UserAccount : String[5];
: PriorityCode, NumberCustomer : Integer;
: UseHours, HourCharge, AveCharge, PriorityCharge, TotalCharge : Real;
:
: Procedure Headings;
:
: Begin
:
: Writeln(' Apex Computer Service');
: Writeln;
: Writeln(' Account Charge');
: Writeln(' --------- --------');
:
: End;
:
: Procedure GetInfo;
:
: Begin
:
: Writeln(' Please Input Your User Account Number: ');
: Readln(UserAccount);
: Writeln(' Please Input Your Priority Code: ');
: Readln(PriorityCode);
: Writeln(' Please Input Your Hours of Usage: ');
: Readln(UseHours);
:
: End;
:
: Procedure LoopingIt;
:
: Begin
:
: WHILE UserAccount <> 'xxxxx' DO
:
: Begin
:
:
: {Calculating of Charges Begins Here}
:
: IF (UseHours > 15.00) THEN
: HourCharge := (225.00 + (15.00 * UseHours));
:
: IF (UseHours > 5.00) AND (UseHours <= 15.00) THEN
: HourCharge := (100.00 + (25.00 * UseHours));
:
: IF (UseHours <= 5.00) THEN
: HourCharge := 100.00;
:
: IF PriorityCode = 0 THEN
: TotalCharge := HourCharge;
:
: IF
: PriorityCode = 1 THEN
: TotalCharge := (HourCharge + 50);
:
: IF
: PriorityCode = 2 THEN
: TotalCharge := (HourCharge + 100);
:
: End;
:
:
: { Data Output Begins Here}
:
: Begin
:
: Writeln(TotalCharge);
:
: End;
:
: GetInfo;
: End;
:
: BEGIN
:
: CLRSCR;
: GetInfo;
: LoopingIt;
: Headings;
:
: END.
:
:
You are very close with the solution. You just need to move the call to GetInfo (marked in red) up one line, right after the writeln() line.
Report
Re: Invalid Variable Reference? Posted by FyreAndIce83 on 14 Oct 2003 at 3:56 PM
: : First off, I want to thank you all for all your help, I am certainly grateful to you all. Anyway, the good news, I got rid of the nasty errors. Now all I need to do is get the infinite loop to stop and get the results I'd like. How is that achieved in this situation? Code follows:
: :
: : VAR
: :
: : UserAccount : String[5];
: : PriorityCode, NumberCustomer : Integer;
: : UseHours, HourCharge, AveCharge, PriorityCharge, TotalCharge : Real;
: :
: : Procedure Headings;
: :
: : Begin
: :
: : Writeln(' Apex Computer Service');
: : Writeln;
: : Writeln(' Account Charge');
: : Writeln(' --------- --------');
: :
: : End;
: :
: : Procedure GetInfo;
: :
: : Begin
: :
: : Writeln(' Please Input Your User Account Number: ');
: : Readln(UserAccount);
: : Writeln(' Please Input Your Priority Code: ');
: : Readln(PriorityCode);
: : Writeln(' Please Input Your Hours of Usage: ');
: : Readln(UseHours);
: :
: : End;
: :
: : Procedure LoopingIt;
: :
: : Begin
: :
: : WHILE UserAccount <> 'xxxxx' DO
: :
: : Begin
: :
: :
: : {Calculating of Charges Begins Here}
: :
: : IF (UseHours > 15.00) THEN
: : HourCharge := (225.00 + (15.00 * UseHours));
: :
: : IF (UseHours > 5.00) AND (UseHours <= 15.00) THEN
: : HourCharge := (100.00 + (25.00 * UseHours));
: :
: : IF (UseHours <= 5.00) THEN
: : HourCharge := 100.00;
: :
: : IF PriorityCode = 0 THEN
: : TotalCharge := HourCharge;
: :
: : IF
: : PriorityCode = 1 THEN
: : TotalCharge := (HourCharge + 50);
: :
: : IF
: : PriorityCode = 2 THEN
: : TotalCharge := (HourCharge + 100);
: :
: : End;
: :
: :
: : { Data Output Begins Here}
: :
: : Begin
: :
: : Writeln(TotalCharge);
: :
: : End;
: :
: : GetInfo;
: : End;
: :
: : BEGIN
: :
: : CLRSCR;
: : GetInfo;
: : LoopingIt;
: : Headings;
: :
: : END.
: :
: :
: You are very close with the solution. You just need to move the call to GetInfo (marked in red) up one line, right after the writeln() line.
:

Okay, recommended changes were made. How do I get out of the infinite loop though?
Report
Re: Invalid Variable Reference? Posted by zibadian on 14 Oct 2003 at 9:14 PM
: : : First off, I want to thank you all for all your help, I am certainly grateful to you all. Anyway, the good news, I got rid of the nasty errors. Now all I need to do is get the infinite loop to stop and get the results I'd like. How is that achieved in this situation? Code follows:
: : :
: : : VAR
: : :
: : : UserAccount : String[5];
: : : PriorityCode, NumberCustomer : Integer;
: : : UseHours, HourCharge, AveCharge, PriorityCharge, TotalCharge : Real;
: : :
: : : Procedure Headings;
: : :
: : : Begin
: : :
: : : Writeln(' Apex Computer Service');
: : : Writeln;
: : : Writeln(' Account Charge');
: : : Writeln(' --------- --------');
: : :
: : : End;
: : :
: : : Procedure GetInfo;
: : :
: : : Begin
: : :
: : : Writeln(' Please Input Your User Account Number: ');
: : : Readln(UserAccount);
: : : Writeln(' Please Input Your Priority Code: ');
: : : Readln(PriorityCode);
: : : Writeln(' Please Input Your Hours of Usage: ');
: : : Readln(UseHours);
: : :
: : : End;
: : :
: : : Procedure LoopingIt;
: : :
: : : Begin
: : :
: : : WHILE UserAccount <> 'xxxxx' DO
: : :
: : : Begin
: : :
: : :
: : : {Calculating of Charges Begins Here}
: : :
: : : IF (UseHours > 15.00) THEN
: : : HourCharge := (225.00 + (15.00 * UseHours));
: : :
: : : IF (UseHours > 5.00) AND (UseHours <= 15.00) THEN
: : : HourCharge := (100.00 + (25.00 * UseHours));
: : :
: : : IF (UseHours <= 5.00) THEN
: : : HourCharge := 100.00;
: : :
: : : IF PriorityCode = 0 THEN
: : : TotalCharge := HourCharge;
: : :
: : : IF
: : : PriorityCode = 1 THEN
: : : TotalCharge := (HourCharge + 50);
: : :
: : : IF
: : : PriorityCode = 2 THEN
: : : TotalCharge := (HourCharge + 100);
: : :
: : : End;
: : :
: : :
: : : { Data Output Begins Here}
: : :
: : : Begin
: : :
: : : Writeln(TotalCharge);
: : :
: : : End;
: : :
: : : GetInfo;
: : : End;
: : :
: : : BEGIN
: : :
: : : CLRSCR;
: : : GetInfo;
: : : LoopingIt;
: : : Headings;
: : :
: : : END.
: : :
: : :
: : You are very close with the solution. You just need to move the call to GetInfo (marked in red) up one line, right after the writeln() line.
: :
:
: Okay, recommended changes were made. How do I get out of the infinite loop though?
:
If the changes are correct, you should be asked to enter the account info everytime the loop runs. If you then enter the correct value for UserAccount (='xxxxx') you will terminate the loop.
Report
Re: Invalid Variable Reference? Posted by FyreAndIce83 on 15 Oct 2003 at 3:08 AM
:
: VAR
:
: UserAccount : String[5];
: PriorityCode, NumberCustomer : Integer;
: UseHours, HourCharge, AveCharge, PriorityCharge, TotalCharge : Real;
:
: Procedure Headings;
:
: Begin
:
: Writeln(' Apex Computer Service');
: Writeln;
: Writeln(' Account Charge');
: Writeln(' --------- --------');
:
: End;
:
: Procedure GetInfo;
:
: Begin
:
: Writeln(' Please Input Your User Account Number: ');
: Readln(UserAccount);
: Writeln(' Please Input Your Priority Code: ');
: Readln(PriorityCode);
: Writeln(' Please Input Your Hours of Usage: ');
: Readln(UseHours);
:
: End;
:
: Procedure LoopingIt;
:
: Begin
:
: WHILE UserAccount <> 'xxxxx' DO
:
: Begin
:
:
: {Calculating of Charges Begins Here}
:
: IF (UseHours > 15.00) THEN
: HourCharge := (225.00 + (15.00 * UseHours));
:
: IF (UseHours > 5.00) AND (UseHours <= 15.00) THEN
: HourCharge := (100.00 + (25.00 * UseHours));
:
: IF (UseHours <= 5.00) THEN
: HourCharge := 100.00;
:
: IF PriorityCode = 0 THEN
: TotalCharge := HourCharge;
:
: IF
: PriorityCode = 1 THEN
: TotalCharge := (HourCharge + 50);
:
: IF
: PriorityCode = 2 THEN
: TotalCharge := (HourCharge + 100);
:
: End;
:
:
: { Data Output Begins Here}
:
: Begin
:
: Writeln(TotalCharge);
:
: End;
:
: GetInfo;
: End;
:
: BEGIN
:
: CLRSCR;
: GetInfo;
: LoopingIt;
: Headings;
:
: END.
:
:
: You are very close with the solution. You just need to move the call to GetInfo (marked in red) up one line, right after the writeln() line.
: : :
: :
: : Okay, recommended changes were made. How do I get out of the infinite loop though?
: :
: If the changes are correct, you should be asked to enter the account info everytime the loop runs. If you then enter the correct value for UserAccount (='xxxxx') you will terminate the loop.
:
Yeah, that part I understand. But when the program is run, I get stuck in the if statements? Would calculating the charges right there after the IF statements help break the cycling?
Report
Re: Invalid Variable Reference? Posted by zibadian on 15 Oct 2003 at 3:43 AM
: : 
: : VAR
: : 
: :    UserAccount : String[5];
: :    PriorityCode, NumberCustomer : Integer;
: :    UseHours, HourCharge, AveCharge, PriorityCharge, TotalCharge : Real;
: : 
: :   Procedure Headings;
: : 
: :      Begin
: : 
: :         Writeln('        Apex Computer Service');
: :         Writeln;
: :         Writeln('    Account                Charge');
: :         Writeln('   ---------              --------');
: : 
: :      End;
: : 
: :   Procedure GetInfo;
: : 
: :      Begin
: : 
: :         Writeln('     Please Input Your User Account Number: ');
: :         Readln(UserAccount);
: :         Writeln('     Please Input Your Priority Code: ');
: :         Readln(PriorityCode);
: :         Writeln('     Please Input Your Hours of Usage: ');
: :         Readln(UseHours);
: : 
: :      End;
: : 
: :   Procedure LoopingIt;
: : 
: :      Begin
: : 
: :         WHILE UserAccount <> 'xxxxx' DO
: : 
: :            Begin
: : 
: : 
: :            {Calculating of Charges Begins Here}
: : 
: :               IF (UseHours > 15.00) THEN
: :                 HourCharge := (225.00 + (15.00 * UseHours));
: : 
: :               IF (UseHours > 5.00) AND (UseHours <= 15.00) THEN
: :                 HourCharge := (100.00 + (25.00 * UseHours));
: : 
: :               IF (UseHours <= 5.00) THEN
: :                 HourCharge := 100.00;
: : 
: :                     IF PriorityCode = 0 THEN
: :                        TotalCharge := HourCharge;
: : 
: :                     IF
: :                        PriorityCode = 1 THEN
: :                        TotalCharge := (HourCharge + 50);
: : 
: :                     IF
: :                       PriorityCode = 2 THEN
: :                       TotalCharge := (HourCharge + 100);
: : 
: :             GetInfo;
: :                     End; { end of the while }
: : 
: : 
: :               { Data Output Begins Here}
: : 
: :               Begin
: : 
: :                Writeln(TotalCharge);
: : 
: :              End;
: : 
: :      End;
: : 
: : BEGIN
: : 
: :   CLRSCR;
: :   GetInfo;
: :   LoopingIt;
: :   Headings;
: : 
: : END.
: : 

: :
: : You are very close with the solution. You just need to move the call to GetInfo (marked in red) up one line, right after the writeln() line.
: : : :
: : :
: : : Okay, recommended changes were made. How do I get out of the infinite loop though?
: : :
: : If the changes are correct, you should be asked to enter the account info everytime the loop runs. If you then enter the correct value for UserAccount (='xxxxx') you will terminate the loop.
: :
: Yeah, that part I understand. But when the program is run, I get stuck in the if statements? Would calculating the charges right there after the IF statements help break the cycling?
:
Above are the changes you need to make. Also in this case it's very important to check your indentation, because according to "standard" Pascal indentation rules, the word "end" is always indented to the same level as its accompanying "begin".

Report
Re: Invalid Variable Reference? Posted by FyreAndIce83 on 15 Oct 2003 at 5:42 AM
Hey Zib...thank you so very much for your help! I got everything working finally, with one small problem in finding the average of the Total Charges at the end of the program. I think I can handle it from here but, TY AGAIN!

~*Fyre And Ice*~

P.S. Thank you to everyone else who aided!
Report
Re: Invalid Variable Reference? Posted by delljohnb on 13 Oct 2003 at 6:39 AM
: First...I don't know what the error means but...could someone please offer me a hand as to why the error is there and how I can get rid of it to finish this program. Remember, this is just a fragment so far...
:
: PROGRAM Charges;
: USES CRT;
:
: VAR
:
: UserAccount : String[5];
: PriorityCode, NumberCustomer : Integer;
: UseHours, HourCharge, AveCharge, PriorityCharge, TotalCharge : Real;
:
: Procedure Headings;
:
: Begin
:
: Writeln(' Apex Computer Service');
: Writeln;
: Writeln(' Account Charge');
: Writeln(' --------- --------');
:
: End;
:
: Procedure GetInfo;
:
: Begin
:
: Writeln(' Please Input Your User Account Number: ');
: Readln(UserAccount);
: Writeln(' Please Input Your Priority Code: ');
: Readln(PriorityCode);
: Writeln(' Please Input Your Hours of Usage: ');
: Readln(UseHours);
:
: End;
:
: Procedure LoopingIt;
:
: Begin
:
: WHILE UserAccount <> 'xxxxx' DO
:
: Begin
:
: IF (UseHours > 15.00) THEN
: HourCharge := (225.00 + (15.00 * UseHours))
:
: ELSE (UseHours > 5.00) AND (UseHours <= 15.00)
: HourCharge := (100.00 + (25.00 * UseHours))
:
: ELSE
: HourCharge := 100.00;
:
: End;
: End;
: End;
:
: BEGIN
:
: CLRSCR;
: Headings;
: GetInfo;
: LoopingIt;
: CalcCharge;
:
: END.
:
:

Try making UserAccount a text variable. I had this same problem last week, and I converted to a text variable, and everything worked great.

I didn't even look into the while loop, the error could still be there. Zibadian is a pretty good programmer, go with his suggestion first, and if that doesn't work, try mine. Good Luck.

Delljohnb


Report
Re: Invalid Variable Reference? Posted by FyreAndIce83 on 13 Oct 2003 at 7:17 AM
: : First...I don't know what the error means but...could someone please offer me a hand as to why the error is there and how I can get rid of it to finish this program. Remember, this is just a fragment so far...
: :
: : PROGRAM Charges;
: : USES CRT;
: :
: : VAR
: :
: : UserAccount : String[5];
: : PriorityCode, NumberCustomer : Integer;
: : UseHours, HourCharge, AveCharge, PriorityCharge, TotalCharge : Real;
: :
: : Procedure Headings;
: :
: : Begin
: :
: : Writeln(' Apex Computer Service');
: : Writeln;
: : Writeln(' Account Charge');
: : Writeln(' --------- --------');
: :
: : End;
: :
: : Procedure GetInfo;
: :
: : Begin
: :
: : Writeln(' Please Input Your User Account Number: ');
: : Readln(UserAccount);
: : Writeln(' Please Input Your Priority Code: ');
: : Readln(PriorityCode);
: : Writeln(' Please Input Your Hours of Usage: ');
: : Readln(UseHours);
: :
: : End;
: :
: : Procedure LoopingIt;
: :
: : Begin
: :
: : WHILE UserAccount <> 'xxxxx' DO
: :
: : Begin
: :
: : IF (UseHours > 15.00) THEN
: : HourCharge := (225.00 + (15.00 * UseHours))
: :
: : ELSE (UseHours > 5.00) AND (UseHours <= 15.00)
: : HourCharge := (100.00 + (25.00 * UseHours))
: :
: : ELSE
: : HourCharge := 100.00;
: :
: : End;
: : End;
: : End;
: :
: : BEGIN
: :
: : CLRSCR;
: : Headings;
: : GetInfo;
: : LoopingIt;
: : CalcCharge;
: :
: : END.
: :
: :
:
: Try making UserAccount a text variable. I had this same problem last week, and I converted to a text variable, and everything worked great.
:
: I didn't even look into the while loop, the error could still be there. Zibadian is a pretty good programmer, go with his suggestion first, and if that doesn't work, try mine. Good Luck.
:
: Delljohnb
:
:
:
Ty for the help, but changing the UserAccount into a text variable, it causes a type mismatch in the While Loop. Any clue why?

Report
Re: Invalid Variable Reference? Posted by Manning on 13 Oct 2003 at 8:09 AM
: : : First...I don't know what the error means but...could someone please offer me a hand as to why the error is there and how I can get rid of it to finish this program. Remember, this is just a fragment so far...
: : :
: : : PROGRAM Charges;
: : : USES CRT;
: : :
: : : VAR
: : :
: : : UserAccount : String[5];
: : : PriorityCode, NumberCustomer : Integer;
: : : UseHours, HourCharge, AveCharge, PriorityCharge, TotalCharge : Real;
: : :
: : : Procedure Headings;
: : :
: : : Begin
: : :
: : : Writeln(' Apex Computer Service');
: : : Writeln;
: : : Writeln(' Account Charge');
: : : Writeln(' --------- --------');
: : :
: : : End;
: : :
: : : Procedure GetInfo;
: : :
: : : Begin
: : :
: : : Writeln(' Please Input Your User Account Number: ');
: : : Readln(UserAccount);
: : : Writeln(' Please Input Your Priority Code: ');
: : : Readln(PriorityCode);
: : : Writeln(' Please Input Your Hours of Usage: ');
: : : Readln(UseHours);
: : :
: : : End;
: : :
: : : Procedure LoopingIt;
: : :
: : : Begin
: : :
: : : WHILE UserAccount <> 'xxxxx' DO
: : :
: : : Begin
: : :
: : : IF (UseHours > 15.00) THEN
: : : HourCharge := (225.00 + (15.00 * UseHours))
: : :
: : : ELSE (UseHours > 5.00) AND (UseHours <= 15.00)
: : : HourCharge := (100.00 + (25.00 * UseHours))
: : :
: : : ELSE
: : : HourCharge := 100.00;
: : :
: : : End;
: : : End;
: : : End;
: : :
: : : BEGIN
: : :
: : : CLRSCR;
: : : Headings;
: : : GetInfo;
: : : LoopingIt;
: : : CalcCharge;
: : :
: : : END.
: : :
: : :
: :
: : Try making UserAccount a text variable. I had this same problem last week, and I converted to a text variable, and everything worked great.
: :
: : I didn't even look into the while loop, the error could still be there. Zibadian is a pretty good programmer, go with his suggestion first, and if that doesn't work, try mine. Good Luck.
: :
: : Delljohnb
: :
: :
: :
: Ty for the help, but changing the UserAccount into a text variable, it causes a type mismatch in the While Loop. Any clue why?


A text variable is used to read/write to text files, he probably meant to use a string variable instead.

And to answer your question in the other thread about what is wrong with your new CalcCharge function, you should definitely brush up on your IF-THEN-ELSE syntax, because that is definitely one problem with the code. I didn't look over it enough to see if there are others.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.