Orangey Posted November 14, 2005 Share Posted November 14, 2005 (edited) Basically, I want to call a function inside my script. All I seem to get from the helpfile is that you use a number to call your function? What if I want to call a function by name? Also, is there such thing as calling a function without returning a value? My real problem is, I have a script with a GUI inside of it- towards the end of the script. When the script and it gets to the GUI part, the GUI closes almost as soon as it is opened. Now, when I run that part of the script alone, it works fine.. buttons close it, etc... So I was thinking that it would be better to call the GUI as a function instead of just letting it stand there at the end of the script? Any advice? Below is the GUI part: expandcollapse popup;Test Script #include <GUIConstants.au3> #include <File.au3> #include <GuiListView.au3> $mydl = FileOpen ( "C:\ACTIVESCPS\TEMP\_SongList.txt", 0 ) GuiCreate("MyGUI", 430,282,(@DesktopWidth-430)/2, (@DesktopHeight-282)/2 , 0x04CF0000) $button_1 = GuiCtrlCreateButton("Add Selected to Queue", 240, 140, 180, 30) ;$label_1 = GuiCtrlCreateLabel("Welcome: " &$bb_rep2, 240, 30, 170, 30) $label_2 = GuiCtrlCreateLabel("Account Balance:", 240, 70, 170, 20) $label_3 = GuiCtrlCreateLabel("Test Label", 240, 100, 170, 30 ) $button_2 = GuiCtrlCreateButton("Exit", 340, 220, 80, 30) $button_3 = GuiCtrlCreateButton("Go!", 240, 220, 80, 30) $button_4 = GuiCtrlCreateButton("Add All to Queue", 240, 180, 180, 30) $listView = GuiCtrlCreateListView("Artist |Album/Song ", 10, 20, 220, 230) $cnt = 0 While 1 $linenum = FileReadLine( $mydl ) $cnt = $cnt + 1 If @error = -1 Then ExitLoop Wend $i=1 $j=2 Do $artist = FileReadLine ( $mydl , $i ) $album = FileReadLine ( $mydl, $j) $r = GuiCtrlCreateListViewItem($artist &"|" &$album, $listView) $j = $j + 2 $i = $i + 2 Until $j >= $cnt _FileCreate ( "C:\ACTIVESCPS\TEMP\_itemselect.txt" ) $itmselect = FileOpen ( "C:\ACTIVESCPS\TEMP\_itemselect.txt", 2 ) $addalltoq = 0 $addseltoq = 0 GUISetState() $ExitLoop = 0 Do $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $button_2 $ExitLoop = 1 Case $msg = $button_1 $ret = _GUICtrlListViewGetItemText ($listview) Local $s_indices = _GUICtrlListViewGetSelectedIndices($listview) If ($ret <> $LV_ERR) Then $addseltoq = 1 $ret_art = _GUICtrlListViewGetItemText ($listview, -1, 0) $ret_alb = _GUICtrlListViewGetItemText ($listview, -1, 1) FileWriteLine ( $itmselect, $ret_art ) FileWriteLine ( $itmselect, $ret_alb ) _GUICtrlListViewDeleteItem($listview, $s_indices) Else MsgBox(0, "", "Nothing Selected") EndIf Case $msg = $button_4 $itmcnt = _GUICtrlListViewGetItemCount($listview) Do _GUICtrlListViewDeleteItem($listview, $itmcnt) $itmcnt = $itmcnt - 1 Until $itmcnt = -1 $addalltoq = 1 Case $msg = $button_3 If $addalltoq = 1 Then $ExitLoop = 1 ElseIf $addseltoq = 1 Then $ExitLoop = 1 Else MsgBox(0, "", "Please make a selection to continue.") EndIf EndSelect Until $ExitLoop = 1 FileClose($itmselect) EDIT: Well, I went ahead and just made the GUI part into an exe which seemed to work okay. Edited November 14, 2005 by Orangey Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now