Jump to content

If not @error then Failure


Go to solution Solved by dersiniar,

Recommended Posts

Posted

i started new script today, and something wierd happend. If Not @Error Then not working

For $b = 1 to $aFile[0]
    $sTemp = _StringBetween($aFile[$b], $PriceStart, $PriceEnd)
    If $sTemp <> 0 Then _ArrayAdd($aFinal, $sTemp[0])
    Next
Local $Price = $aFinal[1]
If Not @error Then
   Sleep(100)
Else
Local $Price = "0"
EndIf

If i remove error test, i get results as neede, but as soon i but this error test in, i get only "Else" outbut from error

  • Developers
Posted (edited)

What is the If @Error supposed the check? @Error contains the Error code of the last performed function!

Also format your code to make it better readable (with Tidy):

For $b = 1 To $aFile[0]
    $sTemp = _StringBetween($aFile[$b], $PriceStart, $PriceEnd)
    If $sTemp <> 0 Then _ArrayAdd($aFinal, $sTemp[0])
Next
Local $Price = $aFinal[1]
If Not @error Then
    Sleep(100)
Else
    Local $Price = "0"
EndIf

 

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted
11 hours ago, Jos said:

Local $Price = $aFinal[1]

it have to error check this one. Or rather if it fails for some reason, then just skip. Cos sometimes $aFinal[1] can be 0 value. I have tried different ways, but result is same. i always get output for  Local $Price = "0", but if i delete this part
If Not @error Then
    Sleep(100)
Else
    Local $Price = "0"
EndIf

Then all works good until 0 value appears

  • Solution
Posted (edited)
12 hours ago, Jos said:

What is the If @Error supposed the check? @Error contains the Error code of the last performed function!

Also format your code to make it better readable (with Tidy):

For $b = 1 To $aFile[0]
    $sTemp = _StringBetween($aFile[$b], $PriceStart, $PriceEnd)
    If $sTemp <> 0 Then _ArrayAdd($aFinal, $sTemp[0])
Next
Local $Price = $aFinal[1]
If Not @error Then
    Sleep(100)
Else
    Local $Price = "0"
EndIf

 

What i need, figured out

If this    Global $Price = $aFinal[1] fails then i need to  use  Global $Price = $aFinal[0]

Edited by dersiniar

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...