Jump to content

If none = true then


Go to solution Solved by UEZ,

Recommended Posts

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

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

:blink:

Link to comment
Share on other sites

  • Solution

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 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

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

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:

947297_10200962802132074_659609379_n.jpg

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:

Skjermbilde.png

Edited by EpicKnarvik97
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...