faustf

strange error array o_O

10 posts in this topic

hi  guy  i  hav e  a  strange problem with a  script  and  array

i  have  created  this  script

#cs ----------------------------------------------------------------------------

    AutoIt Version: 3.3.12.0
    Author:         myName

    Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <IE.au3>
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <InetConstants.au3>
#include <WinAPI.au3>
#include <WinAPIsysinfoConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <Misc.au3>
#include <INet.au3>
#include <Excel.au3>
#include <File.au3>
#include <Array.au3>

If ProcessExists("iexplore.exe") Then ; Check if the internet esplorer process is running.
    ProcessClose("iexplore.exe")
EndIf

_entra_dentro()

Func _entra_dentro()

    Local $page_num = 0
    Global $oIE

    Do

        If ProcessExists("iexplore.exe") Then ; Check if the internet esplorer process is running.
            ProcessClose("iexplore.exe")
        EndIf

        $oIE = _IECreate("https://incloak.com/proxy-list/?start=" & $page_num & "#list", 0, 1, 1, 1)

        _IELoadWait($oIE)
        Local $sText = _IEBodyReadHTML($oIE)
        Local $sText2 = _IEBodyReadText($oIE)

        ;ConsoleWrite($sText)
        Local $aArray_link_altrePAG1_2 = StringRegExp($sText, '(?is)="tdl">(.*?)</td><td>(.*?)</td>', 3)
        ;_ArrayDisplay($aArray_link_altrePAG1_2)
        Local $sFilePath = @ScriptDir & "\Examples.txt"
        Local $i = 0
        Local $h = 1
        Local $total = UBound($aArray_link_altrePAG1_2, $UBOUND_ROWS)
        ;MsgBox (0,'',$total)
        ;_ArrayDisplay($aArray_link_altrePAG1_2)
        ;For $i = 0  To  UBound ($aArray_link_altrePAG1_2) -1
        Do
            FileWrite($sFilePath, "Http://" & $aArray_link_altrePAG1_2[$i] & ":" & $aArray_link_altrePAG1_2[$h] & @CRLF)
            ;MsgBox (0,'',$i)
            ;MsgBox (0,'127',$h)

            $i += 2
            $h += 2
        Until $h = ($total - 1)

        $page_num += 64
    Until $page_num = 640

    MsgBox(0, '', 'fine')
EndFunc   ;==>_entra_dentro

 this  script  some  time  work  "good" after 3 page   go in error  with this  code

FileWrite($sFilePath, "Http://" & $aArray_link_altrePAG1_2[$i] & ":" & $aArray_link_altrePAG1_2[$h] & @CRLF)
FileWrite($sFilePath, "Http://" & $aArray_link_altrePAG1_2^ ERROR
->11:40:34 AutoIt3.exe ended.rc:1
+>11:40:34 AutoIt3Wrapper Finished.

and  some time  give me this  error  at  first page  ,  but  if  i insert  a msgbox  for debugging  like  Msgbox (0,'',$i) down filewrite ,  the  script  work good and  arrive at 3° page  and  go in error

where  is  the problem ???

thsankz  at all

Share this post


Link to post
Share on other sites



sorry the same error

 

FileWrite($sFilePath, "Http://" & $aArray_link_altrePAG1_2[$i] & ":" & $aArray_link_altrePAG1_2[$h] & @CRLF)
FileWrite($sFilePath, "Http://" & $aArray_link_altrePAG1_2^ ERROR
->11:40:34 AutoIt3.exe ended.rc:1
+>11:40:34 AutoIt3Wrapper Finished.

Share this post


Link to post
Share on other sites

What do you think will happen when this statement:

Local $total = UBound($aArray_link_altrePAG1_2, $UBOUND_ROWS)

Fails and returns an Error when the variables isn't an array?

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

ubound  return a number  of  total array 

Share this post


Link to post
Share on other sites

On top of that: You are adding 2 in each loop which also could cause an error:

Do
            FileWrite($sFilePath, "Http://" & $aArray_link_altrePAG1_2[$i] & ":" & $aArray_link_altrePAG1_2[$h] & @CRLF)
            ;MsgBox (0,'',$i)
            ;MsgBox (0,'127',$h)

            $i += 2
            $h += 2
Until $h = ($total - 1)

So it's time you add some consolewrite debugging statements in you code to figure out why you are getting this error!

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

This demonstrates my first point with an empty array:

$a = ""
ConsoleWrite("! Start For loop" & @CRLF)
For $x = 0 to UBound($a)-1
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $a = ' & $a[$x] & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
Next

ConsoleWrite("! Start Do loop" & @CRLF)
$x=0
Do
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $a = ' & $a[$x] & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
    $x+=1
until UBound($a)

Over to you.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

o understund  some  time  velocity  of page  is not  good  for  thake  a  total  by  ubound

Share this post


Link to post
Share on other sites

thankzz so much  :)

 

Share this post


Link to post
Share on other sites

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