Recent

Author Topic: if within repeat not working  (Read 2610 times)

thenarrator

  • New Member
  • *
  • Posts: 14
if within repeat not working
« on: August 28, 2015, 08:17:57 am »
Am trying to nest an if within a repeat, is this something that is possible?

The main code block is below and currently ignores the if statement and completes DoSort as part of the repeat loop...

Code: [Select]
procedure Main();
var
data: IntArray;
begin
    OpenGraphicsWindow('Sort Visualiser', 800, 600);
    LoadResourceBundle( 'NumberBundle.txt' );
 
    GUISetForegroundColor( ColorBlack );
    GUISetBackgroundColor( ColorWhite );
 
    ShowPanel( 'NumberPanel' );
 
    ClearScreen(ColorWhite);
 
    repeat
    ProcessEvents();
    UpdateInterface();

    DrawInterface();
    RefreshScreen(60);
 
  if ButtonClicked( 'Sort Button' ) then
  begin
  DoSort();
  end;

    until WindowCloseRequested();
end;

begin
Main();
end.
« Last Edit: August 28, 2015, 08:30:46 am by thenarrator »

derek.john.evans

  • Guest
Re: if within repeat not working
« Reply #1 on: August 28, 2015, 08:30:22 am »
DoSort & if statement?

Am I blind?

thenarrator

  • New Member
  • *
  • Posts: 14
Re: if within repeat not working
« Reply #2 on: August 28, 2015, 08:31:17 am »
my bad, copied wrong file, changed it to the right code now

derek.john.evans

  • Guest
Re: if within repeat not working
« Reply #3 on: August 28, 2015, 08:36:25 am »
"currently ignores the if statement and completes DoSort"

I'm guessing that means ButtonClicked( 'Sort Button' ) is always returning True.


thenarrator

  • New Member
  • *
  • Posts: 14
Re: if within repeat not working
« Reply #4 on: August 28, 2015, 08:55:28 am »
hmm ok will have to investigate the template my uni gave me there must be an issue with ButtonClicked or the name...

But other than that the way the if is nested is fine?

thenarrator

  • New Member
  • *
  • Posts: 14
Re: if within repeat not working
« Reply #5 on: August 28, 2015, 09:05:55 am »
edit: wasn't meant to be a space between sort and button... sorry for the waste of time
« Last Edit: August 28, 2015, 09:08:14 am by thenarrator »

 

TinyPortal © 2005-2018