Jump to content

Need your help on find what goes wrong


friends
 Share

Recommended Posts

Please help me to take a look at my coding.

It only works well for the first run (Current Date EJournal).

Afterwards, I clears up all the things and return back for

user to choose.

Now, 2nd run, whenever you select Current Date EJournal,

nothing shows up. It stop at LINE 126 $msg = GUIGetMsg()

Please help me to correct my lousy coding. Thank you.

#include <GUIconstants.au3>

;;;;;Opt("GUINotifyMode",1)
Opt ("ExpandEnvStrings", 1)
Opt ("WinTitleMatchMode", 4)
Opt ("TrayIconDebug", 1)

$RepeatFlag = 1

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Checking for application, only one be executed
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

$VERSION = "::PandaTools::MIS Utilities v1.0"
If WinExists($VERSION) Then
  MsgBox(48, "::PandaTools::MIS Utilities v1.0", "Application is already running.....", 3)
  Exit
EndIf

AutoItWinSetTitle($VERSION)



$HANDLE = GUICreate(":: PandaTools :: MIS Utilities v1.0", 380, 450)

# - - - - - - - - - - - - 
#  Drop - down Calendar
# - - - - - - - - - - - - 

GUICtrlCreateGroup ("Date / Time", 20, 10, 340, 55)
GUICtrlCreateDate ("Date", 34, 31, 200, 22)


GUICtrlCreatetab (20, 80, 340, 350)

   # - - - - - - - - 
   #  E-Journal Tab
   # - - - - - - - - 
   GUICtrlCreateTabItem ("E-Journal")
   GUISetFont (12, 800, -1, "Arial")
   GUICtrlCreateLabel (":: E-Journal Viewer v1.0 ::", 74, 125, 228, 25, $SS_CENTER + $SS_SUNKEN )

   GUISetFont (10, 800, -1, "Arial")
   GUICtrlCreateLabel ("Select one of the options below :", 80, 175, 210, 15)
   
  ; E-Journal Options
   GUICtrlCreateGroup ("Options", 70, 200, 240, 120)
   GUIStartGroup()
      $CurrentRadio = GUICtrlCreateRadio ("&Current Date EJournal", 90, 225, 165, 20)
      $PreviousRadio = GUICtrlCreateRadio ("&Previous Date EJournal", 90, 255, 170, 20)
      $PreviousMonthRadio = GUICtrlCreateRadio ("Previous &Month EJournal", 90, 285, 180, 20)
      
  ; POS Input Fields
   $POSLabel = GUICtrlCreateLabel ("POS Counter", 70, 338, 85, 16)
   GUICtrlSetState ($POSLabel, $GUI_HIDE)
   
   $POSInput = GUICtrlCreateInput ("", 160, 335, 70, 25, $ES_CENTER + $ES_NUMBER)
   GUICtrlSetLimit ($POSInput, 4)
   GUICtrlSetState ($POSInput, $GUI_HIDE)
      
  ; Day To View Input Fields
   $DayLabel = GUICtrlCreateLabel ("Day To View", 70, 375, 85, 16)
   GUICtrlSetState ($DayLabel, $GUI_HIDE)
   
   $DayInput = GUICtrlCreateInput ("", 160, 370, 70, 25, $ES_CENTER + $ES_NUMBER)
   GUICtrlSetLimit ($DayInput, 2)
   GUICtrlSetState ($DayInput, $GUI_HIDE)   
   
  ; View Now Button
   $ViewNow = GUICtrlCreateButton ("&View Now", 250, 335, 80, 60)
   GUICtrlSetState ($ViewNow, $GUI_HIDE)
   

   # - - - - - - - - - 
   #  Downloadlog Tab
   # - - - - - - - - -
   GUICtrlCreateTabItem ("Downloadlog")
   GUISetFont (30, 800, -1, "Arial")
   GUICtrlCreateLabel ("Coming Soon !", 85, 200, 200, 150, $SS_CENTER, $WS_EX_TRANSPARENT)



# - - - - - - - -
#  Main Process
# - - - - - - - -

GuiSetState (@SW_SHOW)

$TIME = @HOUR & ":" & @MIN & ":" & @SEC
$PREVTIME = $TIME
$TIME_CONTROL = GUICtrlCreateLabel ($TIME, 250, 31, 95, 25)
GuiCtrlSetFont (-1, 16, 600, -1, "Arial")

$X = 0


While 1 
   
  $MSG = GuiGetMsg ()    [COLOR=green]; <== 2nd run it stops here, any ideas ?[/COLOR]
  SysTime() 
  
  Select
     Case $MSG = $GUI_EVENT_CLOSE    ;dialog box being closed
          TrayTip(":: MIS Utilities ::", "Closing program...", 3, 1)
          Sleep(2500)
          Exit
        
     Case $MSG = $CURRENTRADIO
          CurrentEJournal()
          ProcessData()         
                  
     Case $MSG = $PREVIOUSRADIO
        ;PreviousEJournal()
        
     Case $MSG = $PREVIOUSMONTHRADIO
        ;PreviousMonthEJournal()
   EndSelect      
Wend
GUIDelete()
GuiSetState (@SW_SHOW)


# - - - - - - - - - - - -
#  Function Declaration
# - - - - - - - - - - - -

Func SysTime()
    ;Sleep(1000)
  
     $X = $X + 1
     $Time = @HOUR & ":" & @MIN & ":" & @SEC
     If $X = 10 Or $PrevTime <> $Time Then
        GuiCtrlSetData ($TIME_CONTROL, $TIME)
        $PrevTime = $Time
        $X = 0        
     EndIf   
EndFunc
  

Func CurrentEJournal()
     GUICtrlSetState ($PreviousRadio, $GUI_DISABLE)
     GUICtrlSetState ($PreviousMonthRadio, $GUI_DISABLE)
   
     GUICtrlSetState ($POSLabel, $GUI_SHOW)
     GUICtrlSetState ($POSInput, $GUI_SHOW + $GUI_FOCUS)
     GuiCtrlSetTip ($POSInput, "Eg.1001")
     GUICtrlSetState ($ViewNow , $GUI_SHOW)             
EndFunc
   
Func ProcessData() 
     WHILE $RepeatFlag = 1
           $msg = GUIGetMsg()
           SELECT 
                 CASE $msg = $GUI_EVENT_CLOSE
                      Exit 
                      
                 CASE $msg = $ViewNow
                      EnvSet ("no", GUIRead($POSInput))
                      
                    ;# - - - - - - - - - - - - - - - - -
                    ;#  PING for PC network connection
                    ;# - - - - - - - - - - - - - - - - -
                      RunWait (@comspec & " /c ping " & "pos%no%" & " -n 1 -w 50 > "& @tempdir &"\ping.tmp","",@sw_hide)
                      $ping = FileReadLine (@tempdir & "\ping.tmp",13)
                      FileDelete(@tempdir & "\ping.tmp")
                    ;# - - - - - [ End of PING ] - - - - -
                      
                      IF StringInStr ($ping,"(0%") THEN  ; Search data of 0% in file contents
                         TrayTip (":: MIS Utilities ::", "Please wait while extracting...", 1, 1)
                         
                         IF FileExists ("\\pos%no%\Store\Dat\EJournal.txt") THEN 
                            $PID = Run ("Notepad.exe \\pos%no%\Store\Dat\Ejournal.txt")
                            ProcessWaitClose ($PID)
                            GUICtrlSetState ($CurrentRadio, $GUI_UNCHECKED)
                            GUICtrlSetState ($PreviousRadio, $GUI_ENABLE)
                            GUICtrlSetState ($PreviousMonthRadio, $GUI_ENABLE)
                            GUICtrlSetState ($POSLabel, $GUI_HIDE)
                            GUICtrlSetState ($POSInput, $GUI_HIDE)
                            GUICtrlSetState ($ViewNow, $GUI_HIDE) 
                            GUICtrlSetData ($POSInput, "")
                            $RepeatFlag = 0
                         ELSE 
                            $PID1 = MsgBox (16, ":: MIS Utilities ::", "File Not Found !")
                         ENDIF                                             
                      ELSE 
                          MsgBox (48, ":: MIS Utilities ::", "POS is not active / No network connection established !")                    
                      ENDIF                        
           ENDSELECT               
     WEND             
EndFunc

EDIT : Anybody please help me with it, please see the COMMENT part

Edited by friends
Link to comment
Share on other sites

anybody mind to help ?

here's the problem where it stops working !

Below is part of the coding....

While 1 
  
 $MSG = GuiGetMsg ()    [COLOR=green]; <== 2nd run it stops here, any ideas ?[/COLOR]
 SysTime() 
 
 Select
    Case $MSG = $GUI_EVENT_CLOSE   ;dialog box being closed
         TrayTip(":: MIS Utilities ::", "Closing program...", 3, 1)
         Sleep(2500)
         Exit
       
    Case $MSG = $CURRENTRADIO
         CurrentEJournal()
         ProcessData()         
                 
    Case $MSG = $PREVIOUSRADIO
      ;PreviousEJournal()
       
    Case $MSG = $PREVIOUSMONTHRADIO
      ;PreviousMonthEJournal()
  EndSelect      
Wend
Link to comment
Share on other sites

Edit:

What about this?:

Func ProcessData() 
    WHILE $RepeatFlag = 1

However you should set this value back to "1" in the first message-loop, i.e. like:

$MSG = GuiGetMsg ();  <== 2nd run it stops here, any ideas ?
 SysTime() 
 $RepeatFlag = 1

Regards Holger :)

Edited by Holger
Link to comment
Share on other sites

1. If you posted the whole script, you can remove Opt ("WinTitleMatchMode", 4)

2. How does it stop?

What do you mean and what do you expect?

<{POST_SNAPBACK}>

Thanks for the tip for 1)

I wanted my script to be like this :

When a user first run the script, it shows the result. When it closes,

it goes back to the selection part.

When it runs for the 2nd time, it suppose to prompt for user to

enter value (input). However, it just stops straight away right there

when the user select "Current E-Journal" radio button.

I wonder what goes wrong with my coding.... :)

Thanks for the help

Link to comment
Share on other sites

1. What result?

2. What selection part?

3. Do you want to show an inputbox for user?

You can do that and use GUICtrlSetData to write to the GUI input.

I think you want a value saved. Use INIWrite after user entered a value.

At the top put this: $Value = INIRead("path to ini", "Section", "Value", "")

$Value can be empty or contain the value previously entered

Link to comment
Share on other sites

@friends: did you read my posting?

I tested it out and this was the failure!

Regards Holger

<{POST_SNAPBACK}>

@Holger

Thanks.... it works ! Sorry for being a ignorant as did not

reall take note of yours. I did see it... but I don't see the

point that you showed me... silly me ! :)

I wanted to test it out yesterday at office, but I was so busy until

have no time.

Now I see where my mistake was, it keeps looping inside the loop.

Therefore it stops at $msg = GuiGetState()

Really appreciated...... :)

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