I a script that performs different actions on a list of computers. I want to use an "Emergency Stop" button to stop whatever action on the computers. When I click on the button, it is ignored until the list is finished.
How can you break out of a Function/Loop using a button on a form?
here is an example of pinging.
code:
FUNCTION Ping_Click()
$ButtonStop.OnClick = "GOTO 'Ping_ClickEnd'"
ResetList_Click()
FormBeginUpdate()
$RC = $List.Columns.Add('Ping Status')
$RC = $List.Columns.Add('Ping IP')
$RC = $List.Columns.Add('Ping Name')
$RC = $List.Columns.Add('Ping Error')
FormEndUpdate()
FOR EACH $Item IN $List.Items
$LabelCountValue.Text = '' + $List.Items.Count + ' \ ' + Val ($Item.Index + 1)
$ProgressBarStatus.Value = $Item.Index + 1
$List.EnsureVisible($Item.Index)
$Item.Selected = 1
$RC = IsPing($Item.SubItems(0).Text)
$PingError = @error
SELECT
CASE $PingError = 0
$PingStatus = 'On'
CASE $PingError = 1
$PingStatus = 'RAS'
CASE $PingError = 2
$PingStatus = 'Off'
CASE $PingError = 3
$PingStatus = 'Gone'
CASE 1
$PingStatus = 'PROBLEM'
ENDSELECT
$Item.SubItems(1).Text = $PingStatus
$Item.SubItems(2).Text = $AddressIP
$Item.SubItems(3).Text = $AddressName
$Item.SubItems(4).Text = $IPError
$Item.Selected = 0
NEXT
:Ping_ClickEnd
FormBeginUpdate()
FormEndUpdate()
BEEP
ENDFUNCTION
I forgot. Here is some of the form function that are called.
code:
FUNCTION ResetList_Click()
IF $List.Columns.Count > 1
FOR $ColumnIndex = $List.Columns.Count - 1 TO 1 STEP -1
$List.Columns($ColumnIndex).Remove
NEXT
ENDIF
ENDFUNCTION
FUNCTION FormBeginUpdate()
$Form.MousePointer = 11
$Form.Enabled = 0
$Form.BeginUpdate
ENDFUNCTION
FUNCTION FormEndUpdate()
FOR EACH $Column IN $List.Columns
$Column.Width = -1
$Column.Width = -2
NEXT
$Form.EndUpdate
$Form.MousePointer = 0
$Form.Enabled = 1
$List.SetFocus
ENDFUNCTION
Thanks
[ 22. November 2002, 18:19: Message edited by: krabourn ]
_________________________
Kelly