Page 1 of 1

Test for Equality does not work - why?

Posted: Sun Nov 15, 2009 9:21 am
by Simon Knight
Hi,
I think that I have missed something obvious but I am having problems with what should be a simple equality test:

The line " If LineCount is 5" does not work, neither does "If LineCount = 5", but the line "If LineCount > 5" does work.

I have confirmed that LineCount is being incremented.

Any ideas?


Code: Select all

Put 0 into Blockcount
   Put 0 into LineCount
   set the itemDelimiter to space
   Put Blockcount & return after CleanData
   repeat for each line tLine in tFileData           --compound statement that sets the new var tLine to the value of present line
      Put LineCount+1 into LineCount
      If the length of tline >10 then                 -- only process lines containing data
         repeat with tItemNo = 1 to 8
            put "<" & item tItemNo of tLine & ">" after CleanData
         end repeat
         If (LineCount is 5) then                             -- DataFile stores each block on 5 lines
            put Blockcount+1 into Blockcount
            Put return & "Block -" & Blockcount & return after CleanData
            put 0 into LineCount
         Else
            put return after CleanData
         End if
      end if
   end repeat
   put CleanData after field debug

Posted: Sun Nov 15, 2009 9:31 am
by mwieder
My guess is that line 5 of tFileData has fewer than 10 chars. Try moving line

Code: Select all

Put LineCount+1 into LineCount
after

Code: Select all

If the length of tline >10 then
so you only increment the line count on lines you process.

Code: Select all

      If the length of tline >10 then                 -- only process lines containing data
          Put LineCount+1 into LineCount
          repeat with tItemNo = 1 to 8

Posted: Sun Nov 15, 2009 10:37 am
by Simon Knight
Doh!

Thanks for pointing out my "schoolboy" error. I was so sure that I had the syntax wrong.

Simon :-)

write out 100 times - I must get the logic right...

Posted: Sun Nov 15, 2009 6:31 pm
by mwieder
Well, it's hard to get that syntax *too* wrong. <g>

The first law of quality assurance is that you can't find the bugs in your own code - it takes a set of eyes that aren't intimately familiar with the way things *should* work.

Posted: Sun Nov 15, 2009 6:36 pm
by Simon Knight
You are so right. Its also true for important letters: have them reviewed by someone else or leave them to cool for 24 hours.

Thanks