use Win32::GUI;

$REPEAT_COUNT = 4;
my @Wins;

for($i=0; $i<$REPEAT_COUNT ;$i++) {
 set_hold_interval($i);
}

$Wins[0]->Show();
Win32::GUI::BringWindowToTop($Wins[i]);
$Wins[i]->hold_interval->SetFocus();

Win32::GUI::Dialog();

sub set_hold_interval()
{
 my $i=shift;        # instance of dialog box to create
 
 my $code=" 
 \$Wins[$i]= new Win32::GUI::DialogBox(
     -name   => \"hold_interval_dialog_box$i\",
     -text   => \"Set Hold Interval $i\",
     -left   => 150,
     -top    => 160,
     -width  => 250,
     -height => 100,
     -style  => WS_MAXIMIZEBOX,
 );

 \$Wins[$i]->AddTextfield(
     -name      => \"hold_interval\",
     -left      => 25,
     -top       => 10,
     -width     => 100,
     -height    => 22,
     -text      => 1,
     -prompt    => [ \"Hold Interval:\", 90 ],
     -tabstop   => 1,
 );

 \$Wins[$i]->AddButton(
     -name     => \"HoldIntervalOK$i\",
     -left     => 58,
     -top      => \$Wins[$i]->Height-55,
     -width    => 60,
     -text     => \"&OK\",
     -ok       => 1,
     -default  => 1,
     -tabstop  => 1,
 );
 
 \$Wins[$i]->AddButton(
     -name     => \"HoldIntervalClose$i\",
     -left     => 128,
     -top      => \$Wins[$i]->Height-55,
     -width    => 60,
     -text     => \"&Cancel\",
     -cancel   => $HOLD_INTERVAL,
     -tabstop  => 1,
 );

sub HoldIntervalOK$i\_Click {
 my \$i=$i;
 OK_Click($i);
}

sub HoldIntervalClose$i\_Click {
  return -1;
}";

#print "$code\n";
#<>;
eval $code;

}

sub OK_Click {
 my $i=shift;                       # Current Window
 my $n= ($i+ 1) % $REPEAT_COUNT;    # Next Window
# print "In $i\n";
 $Wins[$n]->Show();
 $HOLD_INTERVAL = $Wins[$i]->hold_interval->Text;
 $Wins[$i]->Hide();
 Win32::GUI::BringWindowToTop($Wins[$n]);
 $Wins[$n]->hold_interval->SetFocus();
}

