Sign in to follow this  
Followers 0
systemhijack

variable

6 posts in this topic

Okay, Lets say that i have a variable ( $ie=_iecreate("www.google.com",0,1,0) ) in a function called Search.

And i got another function called Click, and i need the $ie variable there. how can i do this?

p.s This is an example! please dont provide information about google because its for something different.

Thanks <_<

Share this post


Link to post
Share on other sites

Global $ie

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

"Global" is what you are looking for

Func1()
Func2()
Global $GlobalVar = "green"
Func Func1()
Local $LocalVar = "red"
EndFunc

Func Func2()
Msgbox(0,"", "Global: "&$GlobalVar&@CRLF&"Local: "&$LocalVar)
EndFunc
Edited by Paulie

Share this post


Link to post
Share on other sites

Func Login($sAccount, $sPasswd, $sWorld)
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Display Inline Images", "REG_SZ", "No")
    Global $oIE = _IECreate("http://www.secret.com", 0, 1)
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Display Inline Images", "REG_SZ", "Yes")
    $oForm = _IEFormGetCollection($oIE, 0)
    $oSelect = _IEFormElementGetObjByName($oForm, "server")
    $oAccount = _IEFormElementGetObjByName($oForm, "user")
    $oPasswd = _IEFormElementGetObjByName($oForm, "password")
    
    _IEFormElementSetValue($oAccount, $sAccount)
    _IEFormElementSetValue($oPasswd, $sPasswd)
    
    If $sWorld > 0 And $sWorld < 6 Then
        _IEFormElementOptionselect($oSelect, "nl" & $sWorld, 1, "byValue")
    Else
        MsgBox(0 + 16, "ERROR", "Wereldt bestaat niet.")
        _IEQuit($oIE)
        Exit
    EndIf
    
    _IEFormSubmit($oForm, 0)
    _IELoadWait($oIE)
    
    If StringInStr(_IEBodyReadHTML($oIE), "Account niet beschikbaar") Then
        MsgBox(0 + 16, "ERROR", "Account bestaat niet.")
        _IEQuit($oIE)
        Exit
    ElseIf StringInStr(_IEBodyReadHTML($oIE), "Wachtwoord ongeldig") Or StringInStr(_IEBodyReadHTML($oIE), "" & _
            "Ongeldig wachtwoord") Then
        MsgBox(0 + 16, "ERROR", "Wachtwoordt is fout.")
        _IEQuit($oIE)
        Exit
    EndIf
EndFunc   ;==>Login

Like that?

And @ Paul, whats the differents between Local and Global then?

Thanks <_<

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

@ Paul, whats the differents between Local and Global then?

Thanks <_<

Well, a global variable is meant to be able to be accessed from anywhere in the script (hence globally)

where as "Local" is only supposed to be accessable in the function in which it is created.

Edited by Paulie

Share this post


Link to post
Share on other sites

I get it, Thanks alot! <_<

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
Sign in to follow this  
Followers 0