Recent

Author Topic: Error in a nested if condition  (Read 2942 times)

py2pa

  • New Member
  • *
  • Posts: 11
Error in a nested if condition
« on: August 16, 2014, 04:07:54 pm »
For the following piece of code:

Code: [Select]
if join_first_prop then
   if syllables.Count > 1 and length(syllables[0]) = 1 then
      bla...bla...bla

where:
* join_first_prop is a boolean and
* syllables is a TStringList

the compiler highlights Count and throws the error: Incompatible types: got "Boolean" expected "LongInt". Please help.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Error in a nested if condition
« Reply #1 on: August 16, 2014, 04:12:56 pm »
Code: [Select]
  if (syllables.Count > 1) and (length(syllables[0]) = 1) then

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Error in a nested if condition
« Reply #2 on: August 16, 2014, 04:14:25 pm »
you forgot your parenthesis the error message says it clearly "if" requires boolean expressions can't handle other types. ee
Code: [Select]
if join_first_prop then
   if (syllables.Count > 1) and (length(syllables[0]) = 1) then
      bla...bla...bla
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

py2pa

  • New Member
  • *
  • Posts: 11
Re: Error in a nested if condition
« Reply #3 on: August 16, 2014, 04:17:56 pm »
Thank you so much.

 

TinyPortal © 2005-2018