Jump to content

IE udf problem


Recommended Posts

So I started using IE.au3 in my program, and I have made a web crawler for various websites.

I made this function to help with some stuff. It's supposed to get the id of a page. But when my internet explorer times out or doesn't load, I get

Func GetID($url)
    Local $x, $y
    $x = StringSplit($url, "?showpage=", 1)
    $y = StringSplit($x[2], "&f=", 1)
    Return $y[1]
EndFunc ;==>Get

C:\Documents and Settings\Drew\Desktop\d2jsp SV3\d2jsp SV.au3 (302) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$y = StringSplit($x[2], "&f=", 1)
$y = StringSplit(^ ERROR

Is there a way to fix this?

-------------------

Second problem, I know it's completely unrelated, however I was told to just edit the post instead of spamming the forums.

Func GetIdText()
    Local $i, $line, $file, $id[1000]
    Local Const $FilePath = @ScriptDir & "\ID.txt"
    
    $i = 1
    
    If FileExists($FilePath) Then
        $file = FileOpen("ID.txt", 0)
        While 1
            $line = FileReadLine($file)
            $id[$i] = FileReadLine($file)
            If @error = -1 Then ExitLoop
            $i = $i + 1
        Wend
$id[0] = $i
        For $i = 0 to $id[0]
            Msgbox(0, 0, $id[$i])
        Next
    Else
        ;L("No 'ID.txt' file found. Not loading any past ID files.")
    EndIf
    

EndFunc

GetIdtext()

Here is id.txt

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

It still counts the Chr(10) or Chr(13) left by filewriteline, is there a way to get rid of it?

Edited by igotandrew
Link to comment
Share on other sites

well if you wont give us a sord of working sample code I can be more specific. more likely. But so far I can only guess:

Problem 1: dimension range exceeded.: means there is nothing in your array & you are trying to get non existing value. for example if your array lenght is $y[0] & you are trying to get a value from $y[1] it will error. use _ArrayDisplay after $y = StringSplit($x[2], "&f=", 1) this will show you the array contents:

#include <Array.au3>
$y = StringSplit($x[2], "&f=", 1) 
_ArrayDisplay($y, "")

cant help you further hire, need an example that I can execute.

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
Share on other sites

@igotandrew

For have two strings so $x[2], your url have to contain "?showpage=" , so if your url contain 0 time "?showpage=" you will have an error so you cant fix function just change your url...

Func GetID($url)
     Local $x, $y
     $x = StringSplit($url, "?showpage=", 1)
     $y = StringSplit($x[2], "&f=", 1)
     Return $y[1]
 EndFunc;==>Get

Cheers, FireFox.

Edited by FireFox
Link to comment
Share on other sites

Return Value

Returns an array, the first element ($array[0]) contains the number of strings returned, the remaining elements ($array[1], $array[2], etc.) contain the delimited strings.

Meaning 2 would appear in $x[0]

Unless you're thinking of a different function or were not on the same page here.

Edited by igotandrew
Link to comment
Share on other sites

Return Value

Returns an array, the first element ($array[0]) contains the number of strings returned, the remaining elements ($array[1], $array[2], etc.) contain the delimited strings.

Meaning 2 would appear in $x[0]

Unless you're thinking of a different function or were not on the same page here.

If the input string doesn't contain the expected delimiter, you may not get the array you want, or as many elements as you expect. It needs some error handling. This example uses StringRegExp(), but you could put similar error handling on your own version:
$sURL = "http://www.site.com/index.php?showpage=12387&f=20"
$RET = GetID($sURL)
$iErrRET = @error
MsgBox(64, "Results", "$RET = " & $RET & @CRLF & "@error = " & $iErrRET)

Func GetID($url)
    Local $y = StringRegExp($url, "(?:\?showpage=)(\d+)(?:&f=20)", 3)
    Local $iErrSav = @error
    If IsArray($y) Then
        Return SetError($iErrSav, 0, $y[0])
    Else
        Return SetError($iErrSav, 0, "")
    EndIf
EndFunc;==>Get

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
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
 Share

  • Recently Browsing   0 members

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