Okay here is some code.
When I click the button while inside the Ping function it outputs "ButtonStop_Click()" to the command line. The button works fine when called directly from the form.
At the beginning of the script.
code:
$SwitchStopProgress = 0
Here is the Button
code:
$ButtonStop = $Form.Button
$ButtonStop.Text = 'STOP'
$ButtonStop.Top = $LabelCount.Top
$ButtonStop.Left = $LabelCountValue.Right + 5
$ButtonStop.Size = 90,25
$ButtonStop.OnClick = 'ButtonStop_Click()'
$ButtonStop.ToolTip = 'Stop the current tasks progress'
The function for the button.
code:
FUNCTION ButtonStop_Click()
$SwitchStopProgress = 1
ENDFUNCTION
Here is the functinon
code:
FUNCTION Ping_Click()
$SwitchStopProgress = 0
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
$Form.DoEvents(1)
? $SwitchStopProgress
IF $SwitchStopProgress = 1
GOTO 'Ping_ClickEnd'
ENDIF
NEXT
:Ping_ClickEnd
FormBeginUpdate()
FormEndUpdate()
BEEP
ENDFUNCTION
_________________________
Kelly