Sign in to follow this  
Followers 0
EpicKnarvik97

If none = true then

7 posts in this topic

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



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:


 

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_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My 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

#3 ·  Posted (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 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

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

#6 ·  Posted (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:

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

Share this post


Link to post
Share on other sites

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_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My 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

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
Sign in to follow this  
Followers 0