What is wrong with this Script logic?

Kay C Lan lan.kc.macmail at gmail.com
Thu Jan 10 22:04:18 EST 2013


What is wrong with this Script logic?

I've been staring at this too long and can't figure out what's wrong.

1) New Main Stack
2) Add 1 plain field
3) Set the flds Script to:

on closeField
 hCheckEntry me
end closeField

on hCheckEntry pData
 if (pData is not an integer) then
  ask warning "Please enter only whole numbers!" with pData titled
"Enter A Number"
  put it into tAnswer
  if (tAnswer = empty ) then
   exit to top
  else
   if (tAnswer is not an Integer) then
    --breakpoint --Pos 1
    hCheckEntry tAnswer
    --breakpoint --Pos 2
   else
    put tAnswer into me
   end if
  end if
 end if
end hCheckEntry

If I make the Pos 1 breakpoint active and Pos 2 inactive, then enter A
into the field the ask Dialog comes up with A. If I enter B into the
Dialog then the Dialog reappears with B; this continues for all the
bad data I enter. If I then enter a number or click "Cancel" it all
completes as it should. OK.

If I comment out Pos 1 breakpoint and make Pos 2 breakpoint active,
then when I enter A my ask Dialog comes up with A, BUT if I then enter
B I get an IDE window:

The handler: hCheckEntry has reached the recursion limit of: 400000

If I click the "OK" button on this window to make it go away I am then
presented with my ask Dialog with the B as the default.

If I press "Cancel" my ask Dialog Box comes back with "OK" as the
default answer.

If I press "Cancel" again it finally cancels.

At no time does the debug window come up at my breakpoint.

If I turn Debug Mode OFF, and repeat the above, after I enter B in my
ask Dialog I get the IDE Errors widow come up with:

Type: Handler: can't find handler
Object: fldTest
Line: hCheckEntry tAnswer
Hint: hCheckEntry

My Ask Dialog Box is also presented with B as the default. If I press
"Cancel" my ask Dialog comes back with "ask warning" as the default
answer. If I press 'Cancel' again, it finally cancels.

So why is my script having a recursion problem or not finding the handler?

I'm sure I've written many many similar data checking scripts over the
years and not had this happen.

LC 5.5.3 OS X 10.8.2




More information about the use-livecode mailing list