EpicKnarvik97 Posted October 28, 2013 Share Posted October 28, 2013 I have a list of information that changes at different weeks (it's a sort of school calendar). I will have a lot of these: If _WeekNumberISO() = 45 And $i = 0 Then One() If _WeekNumberISO() = 44 And $i = 0 Then Two() But what if none is true? #AutoIt3Wrapper_Res_File_Add="C:\Users\Kristian\SkyDrive\Autoit\Bilder\Timeplan skisse.bmp", rt_rcdata, Timeplan #include <GUIConstantsEx.au3> #include <Date.au3> #include "resources.au3" Global $i = 0, $1 = 34, $2 = 64, $3 = 95, $4 = 124, $6 = 186, $7 = 219, $8 = 248, $ENG = 40, $NORSK = 57, $DIST = 325, $EDIST = 335 While 1 $msg = GUIGetMsg() If _WeekNumberISO() = 45 And $i = 0 Then One() If _WeekNumberISO() = 44 And $i = 0 Then One() Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func One() Global $hGuiWin = GUICreate("Timeplan", 388, 271) & GUISetState(@SW_SHOW), $i = 1, $pic1 = GUICtrlCreatePic("C:\Users\Kristian\SkyDrive\Autoit\Bilder\Timeplan skisse.bmp", 0, 0, 395, 274), $image = _ResourceSetImageToCtrl($pic1, "Timeplan") & GUICtrlCreateLabel("NORSK", $DIST, $1, $NORSK) & GUICtrlSetFont(-1, 12, "", "", "Arial") & GUICtrlCreateLabel("NORSK", $DIST, $2, $NORSK) & GUICtrlSetFont(-1, 12, "", "", "Arial") & GUICtrlCreateLabel("ENG", $EDIST, $3, $ENG) & GUICtrlSetFont(-1, 12, "", "", "Arial") & GUICtrlCreateLabel("ENG", $EDIST, $4, $ENG) & GUICtrlSetFont(-1, 12, "", "", "Arial") & GUICtrlCreateLabel("ENG", $EDIST, $6, $ENG) & GUICtrlSetFont(-1, 12, "", "", "Arial") & GUICtrlCreateLabel("ENG", $EDIST, $7, $ENG) & GUICtrlSetFont(-1, 12, "", "", "Arial") & GUICtrlCreateLabel("ENG", $EDIST, $8, $ENG) & GUICtrlSetFont(-1, 12, "", "", "Arial") EndFunc ;==>Two If none is true, it just loops. Can I add something to do if none is true without adding Else after each If? I want it to just show the picture instead of showing nothing. Link to comment Share on other sites More sharing options...
FireFox Posted October 28, 2013 Share Posted October 28, 2013 Func One() Global $hGuiWin = GUICreate("Timeplan", 388, 271) & GUISetState(@SW_SHOW), $i = 1, $pic1 = GUICtrlCreatePic("C:\Users\Kristian\SkyDrive\Autoit\Bilder\Timeplan skisse.bmp", 0, 0, 395, 274), $image = _ResourceSetImageToCtrl($pic1, "Timeplan") & GUICtrlCreateLabel("NORSK", $DIST, $1, $NORSK) & GUICtrlSetFont(-1, 12, "", "", "Arial") & GUICtrlCreateLabel("NORSK", $DIST, $2, $NORSK) & GUICtrlSetFont(-1, 12, "", "", "Arial") & GUICtrlCreateLabel("ENG", $EDIST, $3, $ENG) & GUICtrlSetFont(-1, 12, "", "", "Arial") & GUICtrlCreateLabel("ENG", $EDIST, $4, $ENG) & GUICtrlSetFont(-1, 12, "", "", "Arial") & GUICtrlCreateLabel("ENG", $EDIST, $6, $ENG) & GUICtrlSetFont(-1, 12, "", "", "Arial") & GUICtrlCreateLabel("ENG", $EDIST, $7, $ENG) & GUICtrlSetFont(-1, 12, "", "", "Arial") & GUICtrlCreateLabel("ENG", $EDIST, $8, $ENG) & GUICtrlSetFont(-1, 12, "", "", "Arial") EndFunc ;==>Two Link to comment Share on other sites More sharing options...
Solution UEZ Posted October 28, 2013 Solution Share Posted October 28, 2013 (edited) You can try something like this here (according to your code): If _WeekNumberISO() = 45 And $i = 0 Then One() ElseIf _WeekNumberISO() = 44 And $i = 0 Then One() Else AnotherFunction() EndIf Or shorter: $iWeek = _WeekNumberISO() If ($iWeek = 45 Or $iWeek = 44) And $i = 0 Then One() Else AnotherFunction() EndIf But at the top you wrote something different! Br, UEZ Edited October 28, 2013 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Valuater Posted October 28, 2013 Share Posted October 28, 2013 Without adding else after each if... If _WeekNumberISO() = 45 And $i = 0 Then One() If _WeekNumberISO() = 44 And $i = 0 Then One() Sleep(2000) While WinExists("Timeplan") $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
kylomas Posted October 28, 2013 Share Posted October 28, 2013 You can use a construct like this #AutoIt3Wrapper_Res_File_Add="C:\Users\Kristian\SkyDrive\Autoit\Bilder\Timeplan skisse.bmp", rt_rcdata, Timeplan #include <GUIConstantsEx.au3> #include <Date.au3> #include "resources.au3" Global $i = 0, $1 = 34, $2 = 64, $3 = 95, $4 = 124, $6 = 186, $7 = 219, $8 = 248, $ENG = 40, $NORSK = 57, $DIST = 325, $EDIST = 335 While 1 $msg = GUIGetMsg() switch _WeekNumberISO() case 44,45 And $i = 0 One() case else somethingelse() Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd and add as many weeks as you like kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
EpicKnarvik97 Posted October 28, 2013 Author Share Posted October 28, 2013 (edited) You can try something like this here (according to your code): If _WeekNumberISO() = 45 And $i = 0 Then One() ElseIf _WeekNumberISO() = 44 And $i = 0 Then One() Else AnotherFunction() EndIf Or shorter: $iWeek = _WeekNumberISO() If ($iWeek = 45 Or $iWeek = 44) And $i = 0 Then One() Else AnotherFunction() EndIf But at the top you wrote something different! Br, UEZ Thanks. It was exactly what I was looking for. I know that my question was complicated. It's supposed to run three or four functions which will output names of different "school classes". It's going to be one if for each so I needed something like this. An example of the program in action: The Friday one where it says NORSK was just a test. We have different classes on Fridays so I want it to show what is this current week. What One() outputs: Edited October 28, 2013 by EpicKnarvik97 Link to comment Share on other sites More sharing options...
FireFox Posted October 28, 2013 Share Posted October 28, 2013 I know what it outputs, I was just wondering why you wrote everything on the same line... 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