Bert Posted December 9, 2005 Share Posted December 9, 2005 I wrote a example script to do the following: If the example.ini has the following key- tabnumber = 2, then the GUI would have 2 tabs. any other number, it would have one tab. The problem I'm having is I'm getting a error on my Func. It says it is badly formatted. ?????? It works fine if I just use the line 7 where I got it remarked out, and remark out anything with the ini. #include <GuiConstants.au3> #include <File.au3> $main_gui = GUICreate("example", 600, 115) $tab = GUICtrlCreateTab(-1, -1, 600) $tab1 = GuiCtrlCreateTabItem("tab1") ;$tab2 = GuiCtrlCreateTabItem("tab2") $ini = iniread("example.ini", "tab number", "tab") if $ini == 2 then _tab_2 GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop endselect wend Func _tab_2 $tab2 = GuiCtrlCreateTabItem("tab2") EndFunc The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
w0uter Posted December 9, 2005 Share Posted December 9, 2005 Func _tab_2() $tab2 = GuiCtrlCreateTabItem("tab2") EndFunc My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Bert Posted December 9, 2005 Author Share Posted December 9, 2005 OK, that fix that problem, but now I got a new issue. I get a error on line 16 saying the variable not being declared. #include <GuiConstants.au3> #include <File.au3> $main_gui = GUICreate("example", 600, 115) $tab = GUICtrlCreateTab(-1, -1, 600) $tab1 = GuiCtrlCreateTabItem("tab1") $ini = iniread("unplus.ini", "tab number", "tab", "2") if $ini == 2 then _tab_2() ; GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button1 msgbox(0, "ok", "it worked") endselect wend Func _tab_2() $tab2 = GuiCtrlCreateTabItem("tab2") $button1 = GUICtrlCreateButton("OK", 530, 35, 60, 20) EndFunc The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
GaryFrost Posted December 9, 2005 Share Posted December 9, 2005 OK, that fix that problem, but now I got a new issue. I get a error on line 16 saying the variable not being declared. #include <GuiConstants.au3> #include <File.au3> $main_gui = GUICreate("example", 600, 115) $tab = GUICtrlCreateTab(-1, -1, 600) $tab1 = GuiCtrlCreateTabItem("tab1") $ini = iniread("unplus.ini", "tab number", "tab", "2") if $ini == 2 then _tab_2() ; GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button1 msgbox(0, "ok", "it worked") endselect wend Func _tab_2() $tab2 = GuiCtrlCreateTabItem("tab2") $button1 = GUICtrlCreateButton("OK", 530, 35, 60, 20) EndFunc that's becaues you haven't assigned a anything to $button1 SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Guest s_mack Posted December 9, 2005 Share Posted December 9, 2005 (edited) Get in the habit of declaring (see global, local, dim) your variables before you use them and you'll be set. - Steven Edited December 9, 2005 by s_mack Link to comment Share on other sites More sharing options...
Bert Posted December 9, 2005 Author Share Posted December 9, 2005 I had it assigned in the function, so when the 2nd tab was shown, it would have a working button. How then do I have it so when the second tab is shown, the tab can have working stuff? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Guest s_mack Posted December 9, 2005 Share Posted December 9, 2005 Oh, I see now... and that's why you probably got a compilation "warning" and not an "error", right? If I'm following right, you should be able to ignore the "warning" and it should work... but its still not kosher practice. Just declare the variable first... leave it the way you have it but add: Dim $button1 somewhere near the top - Steven Link to comment Share on other sites More sharing options...
Guest s_mack Posted December 9, 2005 Share Posted December 9, 2005 I take it back... it probably was an error. This is because of your "if"... with the code as you have it, if $ini doesn't == 2 then you continue on without calling the function that declares the $button1 variable... then you end up with a variable being used that your script has no idea what it is. Again, adding the code I wrote will fix this. (other solutions and practices exist) - Steven Link to comment Share on other sites More sharing options...
Bert Posted December 9, 2005 Author Share Posted December 9, 2005 (edited) I just figured it out. expandcollapse popup#include <GuiConstants.au3> #include <File.au3> $main_gui = GUICreate("example", 600, 115) $tab = GUICtrlCreateTab(-1, -1, 600) $tab1 = GuiCtrlCreateTabItem("tab1") $button = GUICtrlCreateButton("OK", 530, 35, 60, 20) $ini = iniread("unplus.ini", "tab number", "tab", "2") if $ini == 2 then _tab_2() GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button msgbox(0, "ok", "it worked") exit endselect wend Func _tab_2() GUISetState() $tab2 = GuiCtrlCreateTabItem("tab2") $button1 = GUICtrlCreateButton("OK", 530, 35, 60, 20) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button1 msgbox(0, "ok", "it worked") exit endselect wend EndFunc Edited December 9, 2005 by vollyman The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Bert Posted December 11, 2005 Author Share Posted December 11, 2005 I didn't have a chance to test the script much until now. It will display correctly, but I notice the ok button won't work unless I click back and forth between the tabs a couple of times. ?????? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
MHz Posted December 11, 2005 Share Posted December 11, 2005 Couple of changes as commented. Try it. expandcollapse popup#include <GuiConstants.au3> #include <File.au3> $main_gui = GUICreate("example", 600, 115) $tab = GUICtrlCreateTab(-1, -1, 600) $tab1 = GUICtrlCreateTabItem("tab1") $button = GUICtrlCreateButton("OK", 530, 35, 60, 20) $ini = IniRead("unplus.ini", "tab number", "tab", "2") If $ini == 2 Then _tab_2() GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button MsgBox(0, "ok", "it worked") Exit EndSelect WEnd Func _tab_2() $tab2 = GUICtrlCreateTabItem("tab2") $button1 = GUICtrlCreateButton("OK", 530, 35, 60, 20) GUISetState(); Moved this down While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button; Added this MsgBox(0, "ok", "it worked"); Added this Exit; Added this Case $msg = $button1 MsgBox(0, "ok", "it worked") Exit EndSelect WEnd EndFunc Link to comment Share on other sites More sharing options...
Bert Posted December 11, 2005 Author Share Posted December 11, 2005 I see what you did, but I plan to have 5 tabs. Do I need to have all the controls for each tab in each function to fix the problem? I hope I'm asking this right. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
MHz Posted December 11, 2005 Share Posted December 11, 2005 Well, 1 message loop would be easier if possible. I'm guessing this may suit your cause ? #include <GuiConstants.au3> #include <File.au3> $main_gui = GUICreate("example", 600, 115) $tab = GUICtrlCreateTab(-1, -1, 600) $tab1 = GUICtrlCreateTabItem("tab1") $button = GUICtrlCreateButton("OK", 530, 35, 60, 20) $ini = IniRead("unplus.ini", "tab number", "tab", "2") If $ini == 2 Then $tab2 = GUICtrlCreateTabItem("tab2") $button1 = GUICtrlCreateButton("OK", 530, 35, 60, 20) Else Global $button1 = -1, $tab2 = -1 EndIf GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button MsgBox(0, "ok", "it worked") Exit Case $msg = $button1 MsgBox(0, "ok2", "it worked") Exit EndSelect WEnd Link to comment Share on other sites More sharing options...
Bert Posted December 11, 2005 Author Share Posted December 11, 2005 I think what I'm saying is if the user switches back and forth between tabs, would it affect how the buttons work. I also plan to have different child windows work off each tab. Would it help if I posted the current script so you can see what I plan to do? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Bert Posted December 14, 2005 Author Share Posted December 14, 2005 I got it working. Here is the example code. If you wish to test it, you only need to change the iniread from 5 to whatever number between 1 - 5: expandcollapse popup#include <GuiConstants.au3> #include <File.au3> $main_gui = GUICreate("example", 600, 115) $tab = GUICtrlCreateTab(-1, -1, 600) $tab1 = GUICtrlCreateTabItem("TAB 1") $button1 = GUICtrlCreateButton("TAB 1", 530, 35, 60, 20) $ini = IniRead("test.ini", "tab number", "tab", "5") If $ini == 2 Then _tab_2() If $ini == 3 Then _tab_3() If $ini == 4 Then _tab_4() If $ini == 5 Then _tab_5() GUISetState() ;tab 1 While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $button1 MsgBox(0, "TAB 1", "it worked") Exit EndSelect WEnd ;tab 2 Func _tab_2() $tab2 = GUICtrlCreateTabItem("TAB 2") $button2 = GUICtrlCreateButton("TAB 2", 530, 35, 60, 20) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $button; Added this MsgBox(0, "ok", "it worked") Exit Case $msg = $button2 MsgBox(0, "ok", "it worked") Exit EndSelect WEnd EndFunc ;tab3 Func _tab_3() $tab2 = GUICtrlCreateTabItem("TAB 2") $button2 = GUICtrlCreateButton("TAB 2", 530, 35, 60, 20) $tab3 = GUICtrlCreateTabItem("TAB 3") $button3 = GUICtrlCreateButton("TAB 3", 530, 35, 60, 20) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $button1; Added this MsgBox(0, "ok", "it worked") Exit Case $msg = $button2 MsgBox(0, "ok", "it worked") Case $msg = $button3 MsgBox(0, "ok", "it worked") Exit EndSelect WEnd EndFunc Func _tab_4() $tab2 = GUICtrlCreateTabItem("TAB 2") $button2 = GUICtrlCreateButton("TAB 2", 530, 35, 60, 20) $tab3 = GUICtrlCreateTabItem("TAB 3") $button3 = GUICtrlCreateButton("TAB 3", 530, 35, 60, 20) $tab4 = GUICtrlCreateTabItem("TAB 4") $button4 = GUICtrlCreateButton("TAB 4", 530, 35, 60, 20) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $button1; Added this MsgBox(0, "ok", "it worked") Exit Case $msg = $button2 MsgBox(0, "ok", "it worked") exit Case $msg = $button3 MsgBox(0, "ok", "it worked") Exit Case $msg = $button4 MsgBox(0, "ok", "it worked") Exit EndSelect WEnd EndFunc Func _tab_5() $tab2 = GUICtrlCreateTabItem("TAB 2") $button2 = GUICtrlCreateButton("TAB 2", 530, 35, 60, 20) $tab3 = GUICtrlCreateTabItem("TAB 3") $button3 = GUICtrlCreateButton("TAB 3", 530, 35, 60, 20) $tab4 = GUICtrlCreateTabItem("TAB 4") $button4 = GUICtrlCreateButton("TAB 4", 530, 35, 60, 20) $tab5 = GUICtrlCreateTabItem("TAB 5") $button5 = GUICtrlCreateButton("TAB 5", 530, 35, 60, 20) GUISetState(); Moved this down While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $button1; Added this MsgBox(0, "ok", "it worked") Exit Case $msg = $button2 MsgBox(0, "ok", "it worked") exit Case $msg = $button3 MsgBox(0, "ok", "it worked") Exit Case $msg = $button4 MsgBox(0, "ok", "it worked") Exit Case $msg = $button5 MsgBox(0, "ok", "it worked") Exit EndSelect WEnd EndFunc The Vollatran project My blog: http://www.vollysinterestingshit.com/ 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