Dent

[SOLVED] Possibly used before declaration error in IE.au3

6 posts in this topic

#1 ·  Posted (edited)

Hi all,

So I have a script that interacts with IE but for some reason I can't identify I'm getting the 'possibly used before declaration' error even though I've declared and used those variables.

Local $oPlayer1FSPC = _IEGetObjByName($oIE, "fs")
$oPlayer1FSPC.Value = $sFirstServePc1
Local $oPlayer2FSPC = _IEGetObjByName($oIE, "ofs")
$oPlayer2FSPC.Value = $sFirstServePc2
Local $oPlayer1FSWPC = _IEGetObjByName($oIE, "fsw")
$oPlayer1FSWPC.Value = $sFirstServeWonPc1
Local $oPlayer2FSWPC = _IEGetObjByName($oIE, "ofsw")
$oPlayer2FSWPC.Value = $sFirstServeWonPc2
Local $oPlayer1SSWPC = _IEGetObjByName($oIE, "ssw")
$oPlayer1SSWPC.Value = $sSecondServeWonPc1
Local $oPlayer2SSWPC = _IEGetObjByName($oIE, "ossw")
$oPlayer2SSWPC.Value = $sSecondServeWonPc2
Local $oPlayer1BPS = _IEGetObjByName($oIE, "kps")
$oPlayer1BPS.Value = $sBPSavePc1
Local $oPlayer2BPS = _IEGetObjByName($oIE, "kpb")
$oPlayer2BPS.Value = $sBPSavePc2

The $s variables have had strings assigned earlier in the script and I've tested that with ConsoleWrite

Edited by Dent
Solved

Share this post


Link to post
Share on other sites



Post whole script

Share this post


Link to post
Share on other sites
Local $TIUsername = "AutoBert"
Local $TIPassword = "password"
Local $TOCUsername = "AutoBert"
Local $TOCPassword = "password"

Local $oIE = _IECreate("http://tennisinsight.com/wp-login.php")
If Not IsObj($oIE) Then Exit ConsoleWrite("Error creating instance of IE" & @CRLF)

Local $oIE = _IEAttach("Tennis Insight")

_IELoadWait($oIE)

Local $Page = _IEBodyReadHTML($oIE)

If StringInStr($Page, "Logout") Then
    _IELinkClickByText($oIE, "Logout")
Else
EndIf

Local $oLogin = _IEGetObjByName($oIE, "log")
_IEFormElementSetValue($oLogin, $TIUsername)
Local $oPassword = _IEGetObjByName($oIE, "pwd")
_IEFormElementSetValue($oPassword, $TIPassword)
Local $oButton = _IEGetObjByName($oIE, "wp-submit")
$oButton.Click()
_IELoadWait($oIE)
Local $sURL = InputBox("Match to scrape", "Please enter the full URL of the match including http://", "", "", 400)

If StringInStr($sURL, "http://") Then
    _IENavigate($oIE, $sURL)
Else
    MsgBox(0, "Error", "Invalid URL, exiting")
    _IEQuit($oIE)
    Exit
EndIf

_IELoadWait($oIE)
sleep(5000)
ReadStats()

Func ReadStats()
Local $Page = _IEBodyReadText($oIE)
Local $iFirstServePc1Start = StringInStr($Page, "1st")
If $iFirstServePc1Start = 0 Then
    Wait()
Else
EndIf
$iFirstServePc1Start = ($iFirstServePc1Start - 5)
Local $sFirstServePc1 = StringMid($Page, $iFirstServePc1Start, 4)

;ConsoleWrite($iFirstServePc1Start & @CRLF)
ConsoleWrite("Player 1 1st Serve % : " & $sFirstServePc1 & @CRLF)

Local $iFirstServePc2Start = StringInStr($Page, "Serve %")
$iFirstServePc2Start = ($iFirstServePc2Start + 7)
Local $sFirstServePc2 = StringMid($Page, $iFirstServePc2Start, 4)

;ConsoleWrite($iFirstServePc2Start & @CRLF)
ConsoleWrite("Player 2 1st Serve % : " & $sFirstServePc2 & @CRLF)

Local $iFirstServeWonPc1Start = StringInStr($Page, "1st Serve W")
$iFirstServeWonPc1Start = ($iFirstServeWonPc1Start - 5)
Local $sFirstServeWonPc1 = StringMid($Page, $iFirstServeWonPc1Start, 4)

;ConsoleWrite($iFirstServeWonPc1Start & @CRLF)
ConsoleWrite("Player 1 1st Serve Win % : " & $sFirstServeWonPc1 & @CRLF)

Local $iFirstServeWonPc2Start = StringInStr($Page, "1st Serve W%")
$iFirstServeWonPc2Start = ($iFirstServeWonPc2Start + 12)
Local $sFirstServeWonPc2 = StringMid($Page, $iFirstServeWonPc2Start, 4)

;ConsoleWrite($iFirstServeWonPc2Start & @CRLF)
ConsoleWrite("Player 2 1st Serve Win % : " & $sFirstServeWonPc2 & @CRLF)

Local $iSecondServeWonPc1Start = StringInStr($Page, "2nd Serve W")
$iSecondServeWonPc1Start = ($iSecondServeWonPc1Start - 5)
Local $sSecondServeWonPc1 = StringMid($Page, $iSecondServeWonPc1Start, 4)

;ConsoleWrite($iSecondServeWonPc1Start & @CRLF)
ConsoleWrite("Player 1 2nd Serve Win % : " & $sSecondServeWonPc1 & @CRLF)

Local $iSecondServeWonPc2Start = StringInStr($Page, "2nd Serve W%")
$iSecondServeWonPc2Start = ($iSecondServeWonPc2Start + 12)
Local $sSecondServeWonPc2 = StringMid($Page, $iSecondServeWonPc2Start, 4)

;ConsoleWrite($iSecondServeWonPc2Start & @CRLF)
ConsoleWrite("Player 2 2nd Serve Win % : " & $sSecondServeWonPc2 & @CRLF)

Local $iBPSavePc1Start = StringInStr($Page, "BP Save")
$iBPSavePc1Start = ($iBPSavePc1Start - 5)
Local $sBPSavePc1 = StringMid($Page, $iBPSavePc1Start, 4)

;ConsoleWrite($iBPSavePc1Start & @CRLF)
ConsoleWrite("Player 1 BP Save % : " & $sBPSavePc1 & @CRLF)

Local $iBPSavePc2Start = StringInStr($Page, "BP Save %")
$iBPSavePc2Start = ($iBPSavePc2Start + 9)
Local $sBPSavePc2 = StringMid($Page, $iBPSavePc2Start, 4)

;ConsoleWrite($iBPSavePc2Start & @CRLF)
ConsoleWrite("Player 2 BP Save % : " & $sBPSavePc2 & @CRLF)
EndFunc

Func Wait()
    Sleep(2000)
    ReadStats()
EndFunc

_IEQuit($oIE)

Local $oIE = _IECreate("http://www.tennisoddscalculator.com/")
If Not IsObj($oIE) Then Exit ConsoleWrite("Error creating instance of IE" & @CRLF)

Local $oIE = _IEAttach("TOC")

_IELoadWait($oIE)

_IENavigate($oIE, "http://www.tennisoddscalculator.com/account/calculator/")

_IELoadWait($oIE)

Local $Page = _IEBodyReadText($oIE)

If StringInStr($Page, "Username or Email") Then
    Local $oUsername = _IEGetObjByName($oIE, "username")
    _IEFormElementSetValue($oUsername, $TOCUsername)
    Local $oPassword = _IEGetObjByName($oIE, "password")
    _IEFormElementSetValue($oPassword, $TOCPassword)
    Local $oClassReturn = $oIE.document.getElementsByClassName("form-actions")
    If Not IsObj($oClassReturn) Then Exit ConsoleWrite("Error in $oClassReturn" & @CRLF)
    Local $oTagReturn = $oClassReturn.Item(0).getElementsByTagName("button")
    If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)
    $oTagReturn.Item(0).Click()
    _IELoadWait($oIE)
ElseIf StringInStr($Page, "Use the menu at the top") Then
    _IENavigate($oIE, "http://www.tennisoddscalculator.com/account/calculator/")
    _IELoadWait($oIE)
Else
    MsgBox(0, "Error", "Unknown error")
EndIf

Local $oPlayer1FSPC = _IEGetObjByName($oIE, "fs")
$oPlayer1FSPC.Value = $sFirstServePc1
Local $oPlayer2FSPC = _IEGetObjByName($oIE, "ofs")
$oPlayer2FSPC.Value = $sFirstServePc2
Local $oPlayer1FSWPC = _IEGetObjByName($oIE, "fsw")
$oPlayer1FSWPC.Value = $sFirstServeWonPc1
Local $oPlayer2FSWPC = _IEGetObjByName($oIE, "ofsw")
$oPlayer2FSWPC.Value = $sFirstServeWonPc2
Local $oPlayer1SSWPC = _IEGetObjByName($oIE, "ssw")
$oPlayer1SSWPC.Value = $sSecondServeWonPc1
Local $oPlayer2SSWPC = _IEGetObjByName($oIE, "ossw")
$oPlayer2SSWPC.Value = $sSecondServeWonPc2
Local $oPlayer1BPS = _IEGetObjByName($oIE, "kps")
$oPlayer1BPS.Value = $sBPSavePc1
Local $oPlayer2BPS = _IEGetObjByName($oIE, "kpb")
$oPlayer2BPS.Value = $sBPSavePc2

 

Share this post


Link to post
Share on other sites

Dent,

You declare those variables as Local within the ReadStats function - as such they do not exist in the main script. You need to declare them as Global at the top of your script. I suggest reading the Variables - using Global, Local, Static and ByRef tutorial in the Wiki to learn about variable scoping.

M23

 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

very strict Au3check says:

>Running AU3Check (3.3.14.2)  params:-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6  from:C:\Program Files\AutoIt3  input:C:\Users\Bert\AutoIt3.My\Temp\test.au3
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(1,7) : warning: 'Local' specifier in global scope.
Local $TIUsername
~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(2,7) : warning: 'Local' specifier in global scope.
Local $TIPassword
~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(3,7) : warning: 'Local' specifier in global scope.
Local $TOCUsername
~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(4,7) : warning: 'Local' specifier in global scope.
Local $TOCPassword
~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(7,7) : warning: 'Local' specifier in global scope.
Local $oIE
~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(10,7) : warning: 'Local' specifier in global scope.
Local $oIE
~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(10,41) : warning: $oIE already declared/assigned
Local $oIE = _IEAttach("Tennis Insight")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(14,7) : warning: 'Local' specifier in global scope.
Local $Page
~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(21,7) : warning: 'Local' specifier in global scope.
Local $oLogin
~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(23,7) : warning: 'Local' specifier in global scope.
Local $oPassword
~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(25,7) : warning: 'Local' specifier in global scope.
Local $oButton
~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(28,7) : warning: 'Local' specifier in global scope.
Local $sURL
~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(112,7) : warning: 'Local' specifier in global scope.
Local $oIE
~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(112,63) : warning: $oIE already declared/assigned
Local $oIE = _IECreate("http://www.tennisoddscalculator.com/")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(115,7) : warning: 'Local' specifier in global scope.
Local $oIE
~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(115,30) : warning: $oIE already declared/assigned
Local $oIE = _IEAttach("TOC")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(123,7) : warning: 'Local' specifier in global scope.
Local $Page
~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(123,36) : warning: $Page already declared/assigned
Local $Page = _IEBodyReadText($oIE)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(126,8) : warning: 'Local' specifier in global scope.
    Local $oUsername
    ~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(128,8) : warning: 'Local' specifier in global scope.
    Local $oPassword
    ~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(128,54) : warning: $oPassword already declared/assigned
    Local $oPassword = _IEGetObjByName($oIE, "password")
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(130,8) : warning: 'Local' specifier in global scope.
    Local $oClassReturn
    ~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(132,8) : warning: 'Local' specifier in global scope.
    Local $oTagReturn
    ~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(143,7) : warning: 'Local' specifier in global scope.
Local $oPlayer1FSPC
~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(144,38) : warning: $sFirstServePc1: possibly used before declaration.
$oPlayer1FSPC.Value = $sFirstServePc1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(145,7) : warning: 'Local' specifier in global scope.
Local $oPlayer2FSPC
~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(146,38) : warning: $sFirstServePc2: possibly used before declaration.
$oPlayer2FSPC.Value = $sFirstServePc2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(147,7) : warning: 'Local' specifier in global scope.
Local $oPlayer1FSWPC
~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(148,42) : warning: $sFirstServeWonPc1: possibly used before declaration.
$oPlayer1FSWPC.Value = $sFirstServeWonPc1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(149,7) : warning: 'Local' specifier in global scope.
Local $oPlayer2FSWPC
~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(150,42) : warning: $sFirstServeWonPc2: possibly used before declaration.
$oPlayer2FSWPC.Value = $sFirstServeWonPc2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(151,7) : warning: 'Local' specifier in global scope.
Local $oPlayer1SSWPC
~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(152,43) : warning: $sSecondServeWonPc1: possibly used before declaration.
$oPlayer1SSWPC.Value = $sSecondServeWonPc1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(153,7) : warning: 'Local' specifier in global scope.
Local $oPlayer2SSWPC
~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(154,43) : warning: $sSecondServeWonPc2: possibly used before declaration.
$oPlayer2SSWPC.Value = $sSecondServeWonPc2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(155,7) : warning: 'Local' specifier in global scope.
Local $oPlayer1BPS
~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(156,33) : warning: $sBPSavePc1: possibly used before declaration.
$oPlayer1BPS.Value = $sBPSavePc1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(157,7) : warning: 'Local' specifier in global scope.
Local $oPlayer2BPS
~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(158,22) : warning: $sBPSavePc2: possibly used before declaration.
$oPlayer2BPS.Value = $sBPSavePc2
~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(144,38) : error: $sFirstServePc1: undeclared global variable.
$oPlayer1FSPC.Value = $sFirstServePc1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(146,38) : error: $sFirstServePc2: undeclared global variable.
$oPlayer2FSPC.Value = $sFirstServePc2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(148,42) : error: $sFirstServeWonPc1: undeclared global variable.
$oPlayer1FSWPC.Value = $sFirstServeWonPc1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(150,42) : error: $sFirstServeWonPc2: undeclared global variable.
$oPlayer2FSWPC.Value = $sFirstServeWonPc2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(152,43) : error: $sSecondServeWonPc1: undeclared global variable.
$oPlayer1SSWPC.Value = $sSecondServeWonPc1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(154,43) : error: $sSecondServeWonPc2: undeclared global variable.
$oPlayer2SSWPC.Value = $sSecondServeWonPc2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(156,33) : error: $sBPSavePc1: undeclared global variable.
$oPlayer1BPS.Value = $sBPSavePc1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(158,22) : error: $sBPSavePc2: undeclared global variable.
$oPlayer2BPS.Value = $sBPSavePc2
~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(7,63) : error: _IECreate(): undefined function.
Local $oIE = _IECreate("http://tennisinsight.com/wp-login.php")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(10,40) : error: _IEAttach(): undefined function.
Local $oIE = _IEAttach("Tennis Insight")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(12,17) : error: _IELoadWait(): undefined function.
_IELoadWait($oIE)
~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(14,35) : error: _IEBodyReadHTML(): undefined function.
Local $Page = _IEBodyReadHTML($oIE)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(17,35) : error: _IELinkClickByText(): undefined function.
    _IELinkClickByText($oIE, "Logout")
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(21,44) : error: _IEGetObjByName(): undefined function.
Local $oLogin = _IEGetObjByName($oIE, "log")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(22,44) : error: _IEFormElementSetValue(): undefined function.
_IEFormElementSetValue($oLogin, $TIUsername)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(31,25) : error: _IENavigate(): undefined function.
    _IENavigate($oIE, $sURL)
    ~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(34,14) : error: _IEQuit(): undefined function.
    _IEQuit($oIE)
    ~~~~~~~~~~~~^
"C:\Users\Bert\AutoIt3.My\Temp\test.au3"(43,35) : error: _IEBodyReadText(): undefined function.
Local $Page = _IEBodyReadText($oIE)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Bert\AutoIt3.My\Temp\test.au3 - 18 error(s), 39 warning(s)
!>11:40:11 AU3Check ended. Press F4 to jump to next error.rc:2
+>11:40:11 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 1.491

at least one include file is missin, so it's not whole script.

Share this post


Link to post
Share on other sites

 

1 hour ago, Melba23 said:

Dent,

You declare those variables as Local within the ReadStats function - as such they do not exist in the main script. You need to declare them as Global at the top of your script. I suggest reading the Variables - using Global, Local, Static and ByRef tutorial in the Wiki to learn about variable scoping.

M23

 

Thank-you very much. Sometimes I can't see the forest for the trees!

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

  • Similar Content

    • nassausky
      By nassausky
      Hi all,
       
      Anyone have any idea how to close all open tabs except a specific one I manually open.  Assuming I don't know what is open in all the tabs except just the one I want to keep open.
       
      I didn't want to use sendkeys and I was trying to use the following code to list the title (or url) of the 3 open tabs and  after I got that part working I would just close the other 2. This sample only displays the title of the first open tab
      #include <IE.au3> Const $ie_new_in_tab = 0x0800 $oIE = _IECreate("https://www.autoitscript.com") __IENavigate($oIE, "https://www.autoitscript.com/forum/", 1, $ie_new_in_tab) ;(obj,url,wait,param) __IENavigate($oIE, "https://www.google.com/", 1, $ie_new_in_tab) ;(obj,url,wait,param) Local $aIE[1] $aIE[0] = 0 Local $i = 1, $oIE While 1     $oIE = _IEAttach("", "instance", $i)     If @error = $_IEStatus_NoMatch Then ExitLoop     ConsoleWrite(_IEPropertyGet($oIE, "title") & @CRLF)     ReDim $aIE[$i + 1]     $aIE[$i] = $oIE ;each item holds object     $aIE[0] = $i ;first item holds count     $i += 1 WEnd MsgBox($MB_SYSTEMMODAL, "Browsers Found", "Number of browser instances in the array: " & $aIE[0]) ; This doesn't return the list of tabs in the console just the first tab  
      Thanks for any and all help
    • toto22
      By toto22
      I'm trying to click on Java Dropbox using IE. However, I'm running into problems. There is a Dropbox "Please Select" with two options "Buy" and "Sell".
      I'm able to click on a drop box (please see code below) but i'm unable to select "Buy" or "Sell"".
      Local $sMyString = "Please Select" ;############ ENTER ############# Local $oLinks = _IELinkGetCollection($oIE) For $oLink In $oLinks Local $sLinkText = _IEPropertyGet($oLink, "innerText") If StringInStr($sLinkText, $sMyString) Then _IEAction($oLink, "click") ExitLoop EndIf Next  
      Please help
       
         
    • Gowrisankar
      By Gowrisankar
      Hello everyone,
      I'm working on a task where, a PDF file is opened (in IE browser) when I click a link in a website.
      I have to read the first page of the PDF to find particular strings. Can you please share some ideas?
    • Seminko
      By Seminko
      Hey,
      i would like to set a value into an INPUT field.
      Checked the _IEFormElementSetValue function but that does require _IEFormGetObjByName and this is where the problem comes in. The input field I want to write to is not a part of a form tag. It is part of a table.
      <input type="text" class="w2" id="nabidka_vozidel_formular_tach_od" name="nabidka_vozidel_formular_tach_od" onchange="GLOBAL.pocetInzerceNZ(&quot;nabidka_vozidel_formular&quot;,&quot;tach_od&quot;,&quot;&quot;);" autocomplete="off"> I tried this but that didn't work:
      $oDownloadSamples = _IEGetObjById($oIE, "nabidka_vozidel_formular_tach_od") _IEFormElementSetValue($oDownloadSamples, "123") If you want to try the site I'm working with is https://www.tipcars.cz/. There is a menu on the top left hand side and if you click the "vyhledat" button the input fields will show up.
      Thanks
    • Seminko
      By Seminko
      I am now able to populate the dropdown menus at https://www.tipcars.com/.
      The dropdowns are dynamic and do not have a Text value, only ids.
      Is there a way to get all the available options from a dropdown?
      $url = "https://www.tipcars.com/" $oIE = _IECreate($url) _IELoadWait($oIE) $oDownloadSamples = _IEGetObjById($oIE, "homepage_vyhl_frm_vozidlo") _IEFormElementOptionSelect($oDownloadSamples, "C") Above code, populates ID 'C' into the 'druh' dropdown, which results in selecting 'užitkové'. 
      Is there a way so I can grab all of the options from the dropdown menu? I could easily grab all the IDs but I am afraid they will change in the future so I would much rather match the text titles and assign the option IDs grabbed from site.
      This is what the options are according to Chrome:
      <select class="w1"id="homepage_vyhl_frm_vozidlo"name="homepage_vyhl_frm_vozidlo"onchange="try{NABIDKA_VOZIDEL_FORMULAR.naplnSelectZnacka('homepage_vyhl_frm');GLOBAL.pocetInzerceHZ('homepage_vyhl_frm','vozidlo');}catch(ex){odeslatJsChybu('formHOMEPAGE onChange 1: ' + ex.message, 'formHomePage onChange 1', -1);}"> <option value="A" style="color: black;">osobní a terénní (56 334)</option> <option value="C" style="color: black;">užitkové (4 333)</option> <option value="D" style="color: black;">nákladní (3 742)</option> <option value="E" style="color: black;">autobusy (56)</option> <option value="F" style="color: black;">obytné (373)</option> <option value="G" style="color: black;">přívěsy (1 179)</option> <option value="J" style="color: black;">motorky (780)</option> <option value="S" style="color: black;">pracovní stroje (605)</option> <option value="L" style="color: black;">ostatní (235)</option></select> Also, this cannot be grabbed by _INetGetSource.
      Thanks