Recent

Author Topic: [SOLVED] Not sure what is going on ...  (Read 1519 times)

SteveSS

  • New Member
  • *
  • Posts: 43
[SOLVED] Not sure what is going on ...
« on: August 08, 2018, 01:47:24 pm »
Hi Folks.  Attached is a button click routine.  It does a complicated, mainly random number calculation in the function calcgames.  If this fails, it returns a blank result.  After several attempts, it asks the user if they want to carry on and if they reply 'no', calls exit.  This doesn't seem to work - if I step through with F8, it goes to the end of the procedure, then continues the procedure at the line : if g = 1 and carries on doing the calculations.  I don't understand why the procedure doesn't stop.  There is probably an obvious reason but I just can't see it.  Any thoughts?
« Last Edit: August 08, 2018, 03:25:42 pm by SteveSS »

Handoko

  • Hero Member
  • *****
  • Posts: 5130
  • My goal: build my own game engine using Lazarus
Re: Not sure what is going on ...
« Reply #1 on: August 08, 2018, 02:15:30 pm »
Please provide the complete source code, which is compilable. To do it:
Create a new folder, copy and paste all the needed files to it except: *.bak, the binary (*.exe) and the lib folder. Then compress the the folder and send the zip file to the forum.

Please help us to help you. By providing the compilable source code will make us easier to help you.

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: Not sure what is going on ...
« Reply #2 on: August 08, 2018, 02:20:54 pm »
Without a fully compilable example this is my guess:

You basically do:
Code: Pascal  [Select][+][-]
  1. while true do
  2. begin
  3.   ...
  4.   if failure then
  5.     continue
  6.   else
  7.     other code
  8. end;

The continu statement will get you back to the start of the while loop, which I guess is not what you want.

Bart

SteveSS

  • New Member
  • *
  • Posts: 43
[SOLVED] Re: Not sure what is going on ...
« Reply #3 on: August 08, 2018, 03:24:36 pm »
Hi All.  Thanks for the responses.  I discovered that the problem was caused by calling the button click routine with the parameter (nil) effectively changes where an exit call goes.  I am now using a different method to re-start the calculations (if the user wants to) and all is well.

 

TinyPortal © 2005-2018