Help please! 
Author Message
 Help please!

I am new at Pascal programming, and was wondering if any of you could help
me with a lone of code.

I am trying to get the following line to work -

if (e1 + e2) > 21 and x1 = 1 then e1 := 1;

Why won't this work?  Is there another solution to this?

Thanks,
JoeSmith



Wed, 18 Jun 1902 08:00:00 GMT  
 Help please!

Quote:

> I am new at pascal programming, and was wondering if any of you could help
> me with a lone of code.
> I am trying to get the following line to work -
> if (e1 + e2) > 21 and x1 = 1 then e1 := 1;
> Why won't this work?  Is there another solution to this?

You're missing some parentheses; you want

if (e1 + e2 > 21) and (x1 = 1) then e1 := 1;

The "and" operator has higher precedence than "relational operators" such as
<, >, = etc. So the compiler tries to evaluate "21 and x1" as a Boolean
expression and, of course, fails.

--
______________________________________________________________________
     The Scarlet Manuka,      |        Nitpickers' Party motto:
  Pratchett Quoter At Large,  |  "He who guards his lips guards his
 First Prophet of Bonni, is:  |  soul, but he who speaks rashly will

______________________________|_______________________________________



Wed, 18 Jun 1902 08:00:00 GMT  
 Help please!
Some more parenthesis would help a lot...;)

                TXAS, Comando Lagarto.

Quote:

> I am new at pascal programming, and was wondering if any of you could help
> me with a lone of code.

> I am trying to get the following line to work -

> if (e1 + e2) > 21 and x1 = 1 then e1 := 1;

> Why won't this work?  Is there another solution to this?

> Thanks,
> JoeSmith




Wed, 18 Jun 1902 08:00:00 GMT  
 Help please!

Write like this: If ((e1+e2)>21) And (x1=1) Then e1: =1
Note If you assign a value to a variable.Like e1:=1 then it is : =
if you make a conditional statement.Like (e1+e2)>21 then it is only =
You can make as many conditions as you like.Just do Like (...) And (...) Or
(....)...

Quote:

> I am new at pascal programming, and was wondering if any of you could help
> me with a lone of code.

> I am trying to get the following line to work -

> if (e1 + e2) > 21 and x1 = 1 then e1 := 1;

> Why won't this work?  Is there another solution to this?

> Thanks,
> JoeSmith




Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. programming help **please help me** its not hard

2. HELP, Please help. Delphi and TAPI

3. HELP ! HELP PLEASE IN COMPILE TO EXE FILE

4. HELP PLEASE HELP

5. algorithm...help please

6. Help please: non-BDE, non-ODBC database files

7. Help please!

8. Help, please : QBE syntax error (?!)

9. Unknown Database? yet it exists - help please

10. HELP PLEASE!!: TQuery question

11. ADO help please

 

 
Powered by phpBB® Forum Software