Sign in to follow this  
Followers 0
masonje

passing variables to functions

4 posts in this topic

I'm not able to get this to run correctly. It will compile, and run the GUI, but errors out on the _srvConnect() function The error is attached and below is the code...

#include <GuiConstants.au3>

$ipParce = StringLeft(@IPAddress1, 6)

$homeIPparce = "10.70." ;parced to 6 digits, including decimals

$url = "domain.com"

$vncPath = "C:\Program Files\RealVNC\VNC4\vncviewer.exe"

;set var to make compiler stop complaining....

$port = ""

$server = ""

;Setup GUI

GUICreate("VNC Connect", 152, 90, (@DesktopWidth - 152) / 2, (@DesktopHeight - 110) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$Button_Tower = GUICtrlCreateButton("Tower", 10, 10, 130, 30)

$Button_Linux = GUICtrlCreateButton("Server2", 10, 50, 130, 30)

Func _srvConnect()

;Determin home or outside network

If $ipParce = $homeIPparce Then

$run = $vncPath & " " & $server

Run($run)

Exit

Else

$run = $vncPath & " " & $url & ':' & $port

Run($run)

Exit

EndIf

Exit

EndFunc ;==>_srvConnect

;Start GUI

GUISetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $Button_Tower

;set port and server infor for Button_1

$port = "4444"

$server = "10.70.1.11"

;Connect to server

_srvConnect($port & $server)

Case $msg = $Button_Linux

;set port and server infor for Button_2

$port = "5555"

$server = "10.70.1.12"

;Connect to server

_srvConnect($port & $server)

EndSelect

WEnd

Exit

PS, the personal stuff has all been changed, so don't bother! :P Also I attached my real source file so it can be read w/ the tabs.

guiconnect_posted.au3

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Does this help?

#include <GuiConstants.au3>
Dim $ipParce = StringLeft(@IPAddress1, 6)
Dim $homeIPparce = "10.70.";parced to 6 digits, including decimals
Dim $url = "domain.com"
Dim $vncPath = "C:\Program Files\RealVNC\VNC4\vncviewer.exe"
;set var to make compiler stop complaining....
Dim $port = ""
Dim $server = ""

;Setup GUI
GUICreate("VNC Connect", 152, 90, (@DesktopWidth - 152) / 2, (@DesktopHeight - 110) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$Button_Tower = GUICtrlCreateButton("Tower", 10, 10, 130, 30)
$Button_Linux = GUICtrlCreateButton("Server2", 10, 50, 130, 30)

Func _srvConnect(ByRef $vncPath, ByRef $port, ByRef $server, ByRef $url, ByRef $homeIPparce, ByRef $ipParce)
;Determin home or outside network
    If $ipParce = $homeIPparce Then
        $run = $vncPath & " " & $server
        Run($run)
        Exit
    Else
        $run = $vncPath & " " & $url & ':' & $port
        Run($run)
        Exit
    EndIf
    Exit
EndFunc  ;==>_srvConnect

;Start GUI
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button_Tower
        ;set port and server infor for Button_1
            $port = "4444"
            $server = "10.70.1.11"
        ;Connect to server
            _srvConnect($vncPath, $port, $server, $url, $homeIPparce, $ipParce)
        Case $msg = $Button_Linux
        ;set port and server infor for Button_2
            $port = "5555"
            $server = "10.70.1.12"
        ;Connect to server
            _srvConnect($vncPath, $port, $server, $url, $homeIPparce, $ipParce)
    EndSelect
WEnd
Exit

Edit:

Forgot some stuff...

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I'm not able to get this to run correctly. It will compile, and run the GUI, but errors out on the _srvConnect() function The error is attached and below is the code...

PS, the personal stuff has all been changed, so don't bother! :P Also I attached my real source file so it can be read w/ the tabs.

you haven't setup your _srvconnect() to accept any arguments. if you want to send it a value, you have to assign a name to the value being received, like

Func _SrvConnect($argument)
then use $argument within the function to refer to the referenced. Another option if you're using global variables and it's just working with those, take out the arguments being passed in the function call, and call it with just:

_SrvConnect()

***edit** fixed typo. also, please use [ code ] and [ /code ] (without the spaces) to seperate your code and make it stand out... PS. welcome to the forum

Edited by cameronsdad

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

Does this help?

Yes! Thanks a tun. I also tried taking out the passing of vars and that works too b/c I guess they are global variables (I didn't think of that).

Thanks again guys.

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