Jump to content

Trouble with nested If Else..


Go to solution Solved by Damein,

Recommended Posts

So I have a function that does multiple checks to an INI file but I am having trouble getting the If's to close properly. I think I've just been staring at it too long and can't see what I'm doing wrong. I know its something simple I'm just over looking. If someone could give it a fresh pair of eyes that would be great..

#include <EditConstants.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <Excel.au3>

Global $RundownHoursGui

Opt("GUIOnEventMode", 1)

Dim $Volts[4000]

$CurrentBattery = @ScriptDir & "\Test.ini"

_Edit1HourReading()

Func _Edit1HourReading()
    $CheckStatus = IniReadSection($CurrentBattery, "10MinuteComplete")
    If $CheckStatus[1][1] = 1 Then
        $CheckStatus2 = IniReadSection($CurrentBattery, "1HourComplete")
        If $CheckStatus2[1][1] = 1 Then
            $CheckCancel = MsgBox(4, "Check", "1 Hour Reading is complete.. do you wish to edit this?")
        If $CheckCancel = 6 Then
            $CurrentGui = "1Hour"
            GUIDelete($RundownHoursGui)
            $1HourGui = GUICreate("1 Hour Readings", 330, 700)
;~          GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseGui")
            GUISetBkColor(0xFFFFFF)
            GUISetFont(12)
            $OkButton = GUICtrlCreateButton("Save", 200, 280, 110, 40)
;~          GUICtrlSetOnEvent(-1, "_Save1HourInfo")
            $CancelButton = GUICtrlCreateButton("Close", 200, 370, 110, 40)
;~          GUICtrlSetOnEvent(-1, "_Cancel1HourInfo")
            GUICtrlCreateLabel("Volts", 120, 20)
            For $i = 1 To 24
                If $i = 1 Then
                    $Y = 50
                    GUICtrlCreateLabel("Cell #" & $i, 10, 50)
                    GUICtrlSetFont(-1, 10)
                Else
                    $Y += 27
                    GUICtrlCreateLabel("Cell #" & $i, 10, $Y)
                    GUICtrlSetFont(-1, 10)
                EndIf
            Next
            For $i = 1 To 24
                If $i = 1 Then
                    $Y = 50
                    $Volts[$i] = GUICtrlCreateInput("", 100, 50, 80, 20, $ES_CENTER)
                    GUICtrlSetFont(-1, 10)
                Else
                    $Y += 27
                    $Volts[$i] = GUICtrlCreateInput("", 100, $Y, 80, 20, $ES_CENTER)
                    GUICtrlSetFont(-1, 10)
                EndIf
            Next
            $VoltsToEncode = IniReadSection($CurrentBattery, "1HourReading")
            For $i = 1 To 24
                GUICtrlSetData($Volts[$i], $VoltsToEncode[$i][1])
            Next

    GUICtrlCreateLabel("Read Time", 215, 20)
    $ReadTime = GUICtrlCreateInput("", 215, 50, 80, 20, $ES_Center)
    GUICtrlSetFont(-1, 10)

    $ReadTimeToEncode = IniReadSection($CurrentBattery, "1HourReadTime")
    GUICtrlSetData($ReadTime, $ReadTimeToEncode[1][1])
            GUISetState()
    Else
        MsgBox(48, "Error", "Error, you must complete the 10 minute readings section of the battery first!")
    EndIf
Else
    MsgBox(0, "test", "No")
Endif
EndIf
EndFunc   ;==>_Edit1HourReading

Create an INI file with this 

[10MinuteReading]
1=200
2=200
3=200
4=200
5=200
6=200
7=200
8=200
9=200
10=200
11=200
12=200
13=200
14=200
15=200
16=200
17=200
18=200
19=200
20=200
21=200
22=200
23=200
24=200
[10MinuteReadTime]
1=9:10
[10MinuteComplete]
Status=1
[1HourReading]
1=197
2=197
3=197
4=197
5=197
6=197
7=197
8=197
9=197
10=197
11=197
12=197
13=197
14=197
15=197
16=197
17=197
18=197
19=197
20=197
21=197
22=197
23=197
24=197
[1HourReadTime]
1=
[1HourComplete]
Status=1

Labeled Test.ini in the same location.

When you run it, it will say "No" due to the MsgBox on line 72.

Now, if you look at the INI file for the section [10MinuteComplete] you'll see the Status does = 1.

Now, what its suppose to do if that status does = 1 it goes to the next check on line 20, and if thats complete (By [1HourComplete] in the INI file) it goes to the MsgBox, but it doesn't.

So here are the steps its suppose to take.

If [10MinuteComplete] = 1

Check [1HourComplete]

If [1HourComplete] = 1

Check and see if user wants to edit 1HourGui

If user wants to, initiate the GUI creation.

If any of the checks = 0 I want it to just go to the bottom of the function and do a Sleep(10).

Let me know if further explanation needs done.

Thanks! Getting tired looking at it.. :(

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

  • Solution

Ah.. I found my problem. I wasn't attaching the correct INI after a previous check. All good ^^;

Thanks!

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

Haha, thanks :)

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

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