EpicKnarvik97 0 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. Share this post Link to post Share on other sites
FireFox 260 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 OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDFMy Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme makerMy Examples : Capture tool | IP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewerMy Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control Share this post Link to post Share on other sites
UEZ 1,265 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Share this post Link to post Share on other sites
Valuater 129 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 Share this post Link to post Share on other sites
kylomas 415 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 Share this post Link to post Share on other sites
EpicKnarvik97 0 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 Share this post Link to post Share on other sites
FireFox 260 Posted October 28, 2013 I know what it outputs, I was just wondering why you wrote everything on the same line... OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDFMy Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme makerMy Examples : Capture tool | IP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewerMy Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control Share this post Link to post Share on other sites