Board index » delphi » Logical Operator Problem

Logical Operator Problem

Quote
Lim Poh San wrote:

> I can't get the logical operator to work logically.
> Can anyone help?

> write('Serviceman_Age      : ');
> Readln (result[counter].Serviceman_Age);

  with result[counter] do

Quote
>   if (serviceman_age >=16) and (serviceman_age <25) then
> begin

You fill the age in one variable, but then ask another variable.
--
Franz Glaser, Glasau 3, A-4191 Vorderweissenbach Austria ++43-7219-7035
Muehlviertler Elektronik Glaser. Industrial control and instrumentation
-----------------------------------------------------------------------
http://members.eunet.at/meg-glaser           mailto:meg-gla...@eunet.at
http://www.geocities.com/~franzglaser  http://members.xoom.com/f_glaser
 

Re:Logical Operator Problem


Quoting a message by "Lim Poh San" <ps7577...@pacific.net.sg> in
comp.lang.pascal.borland:

Quote
>Readln (result[counter].Serviceman_Age);
>if (serviceman_age >=16) and (serviceman_age <25) then
>If I use the statement in line 3,
>any age that I enter will still be under cat X

Firstly, when you step through this program in the IDE, put the
variables;

serviceman_age and result[counter]serviceman_age

into the watch window.

(Hint: Look at the variable you're inputting, and the variable you're
trying to reference).

Quote
>but if i replace line 3 with readln(serviceman_age);
>it works just fine.

Does the line;

serviceman_age := result[counter].serviceman_age

ring any bells? When you input to one variable, you *CAN* then store
the inputted value to a second (third, fourth, etc..) variable.

As a side note - it's good coding practises to read input with strings,
so that you may parse it to make sure there are no typo's (foreign
characters) contained within. For instance, if I were to enter 18, then
hit the apostrophe (') key on my way to the enter key, the input would
be invalid and return 0.

--

= Stewart Honsberger (AKA Blackdeath)
= Web: http://sprk.com/blackdeath ICQ UIN: 3484915
= Remove 'thir{*word*249}' to reply privately

... I hit my CRTL key but i'm STILL not in control....
-!- GOPGP/2 v1.21

Re:Logical Operator Problem


In article <36E8327E.A6B30...@eunet.at>,
Ing. Franz Glaser <meg-gla...@eunet.at> wrote:

Quote
>Lim Poh San wrote:

>> I can't get the logical operator to work logically.
>> Can anyone help?

>> write('Serviceman_Age      : ');
>> Readln (result[counter].Serviceman_Age);
>  with result[counter] do
>>   if (serviceman_age >=16) and (serviceman_age <25) then
>> begin

>You fill the age in one variable, but then ask another variable.

I just wonder how he managed to have a variable and a field with same
name. Doing so is asking disaster. Maybe he had a compile time error and
"fixed" it by adding the variable definition.

Osmo

Other Threads