Page 1 of 1

ini reads

Posted: 08 Jun 2019, 20:34
by Dyson
so im struggling a little bit with reading ini files, I have a couple of files than need reading from during the script and its basically "if" and "else" im struggling with

Code: Select all

ClockIn:
iniread, ClerkIn, Clerk.ini, Clerk, %MyVar%
FormatTime, TimeIn,, HH:mm:ss
FormatTime, DateIn,, ShortDate
if iniread %MyVar% = %MyVar% Clerk.ini, Clerk 
 {
---
if iniread Yes = Online.ini, Clocked In:, %ClerkIn% 
{
  msgbox, 262208,Attention ,%ClerkIn% Already Clocked In.,2
    GuiControl,, MyVar, % MyVar := ""
}
---
if iniread No, Online.ini, Clocked In:, %ClerkIn% 
{
iniwrite Yes, Online.ini, Clocked In:, %ClerkIn%
iniwrite %DateIn%, Hours.ini, %ClerkIn%, %TimeIn% Clock In
  msgbox, 262208,Attention ,%ClerkIn% Clocked In.,2
    GuiControl,, MyVar, % MyVar := ""
}
---
Else msgbox, 262208,Attention ,No such Clerk.,2
    GuiControl,, MyVar, % MyVar := ""
return
basically if my input is in the "Clerk" list it will continue to find out if this clerk is "clocked in", if so it will alert you that they are already clocked in, if not, it will clock you in and write to the "hours" file when u clocked in.
If the input is not in my "clerk" list it should notify you there is no such clerk and do nothing else

still wrapping my head around reading ini files, ive just about got it with writing them
Any help would be much appreciated :D

Re: ini reads

Posted: 09 Jun 2019, 16:33
by YoucefHam
Here try to follow this example

Online.ini

Code: Select all

[Settings]
IsActive=1

Code: Select all

q::
if IniRead("Online.ini", "Settings", "IsActive")
    MsgBox, True
else
    MsgBox, False
return

;  Function


IniRead(File, Section, key)
{
    IniRead, var, % File, % Section, % key
    return, var
}

Re: ini reads

Posted: 09 Jun 2019, 20:33
by Dyson
YoucefHam wrote:
09 Jun 2019, 16:33
Here try to follow this example

Online.ini

Code: Select all

[Settings]
IsActive=1

Code: Select all

q::
if IniRead("Online.ini", "Settings", "IsActive")
    MsgBox, True
else
    MsgBox, False
return

;  Function


IniRead(File, Section, key)
{
    IniRead, var, % File, % Section, % key
    return, var
}
So this gets me to the right path, but I don't quite understand how it gets me to read the key, (where u have it as IsActive=1 I need it to read the 1 and act, if its 2 it needs to do something different, does that make sense?

Re: ini reads

Posted: 09 Jun 2019, 21:16
by Dyson

Code: Select all

ClockIn:
FormatTime, TimeIn,, HH:mm:ss
FormatTime, DateIn,, ShortDate
iniread, ClerkIn, Clerk.ini, Clerk, %MyVar%
IniRead Value, Online.ini, Clocked In:, ClerkIn
if %Value% = No
    MsgBox, %Value%
Else
msgbox false
return
it keeps returning False, Maybe I have the syntax wrong on the if line?

here is my ini files:

Online.ini
[Clocked In:]
Test=No

Clerk.ini
[Clerk]
1=Test

Re: ini reads

Posted: 09 Jun 2019, 21:31
by wolf_II
Try this:

Code: Select all

MyVar := 1 ; <<< needed
ClockIn:
FormatTime, TimeIn,, HH:mm:ss
FormatTime, DateIn,, ShortDate
iniread, ClerkIn, Clerk.ini, Clerk, %MyVar%
IniRead Value, Online.ini, Clocked In:, %ClerkIn% ; <<< changed
if Value = No ; <<< changed
    MsgBox, %Value%
Else
msgbox false
return
I hope that helps.

Re: ini reads

Posted: 09 Jun 2019, 21:34
by gregster
Maybe I have the syntax wrong on the if line?
Have a look at the docs:
Either if (Value = "No") (expression syntax)
or if Value = No (traditional syntax; deprecated, will be removed in AHK v2)

Ah, wolf_II was faster...

Re: ini reads

Posted: 09 Jun 2019, 21:56
by Dyson
wolf_II wrote:
09 Jun 2019, 21:31
Try this:

Code: Select all

MyVar := 1 ; <<< needed
ClockIn:
FormatTime, TimeIn,, HH:mm:ss
FormatTime, DateIn,, ShortDate
iniread, ClerkIn, Clerk.ini, Clerk, %MyVar%
IniRead Value, Online.ini, Clocked In:, %ClerkIn% ; <<< changed
if Value = No ; <<< changed
    MsgBox, %Value%
Else
msgbox false
return
I hope that helps.
Already changed that i saw the error but playing around with it and got it to work added some more and its failing again,

Code: Select all

ClockIn:
FormatTime, TimeIn,, HH:mm:ss
FormatTime, DateIn,, ShortDate
iniread, ClerkIn, Clerk.ini, Clerk, %MyVar%
IniRead Value, Online.ini, Clocked In:, %ClerkIn%
if (%Value% = No) {
GuiControl,, MyVar, % MyVar := ""
   msgbox, 262208,Attention ,%ClerkIn% Clocked In.,2
iniwrite Yes, Online.ini, Clocked In:, %ClerkIn%
iniwrite In, Hours.ini, %ClerkIn% - %DateIn%, %TimeIn% Clocked
}
return
if (%Value% = Yes) {
GuiControl,, MyVar, % MyVar := ""
   msgbox, 262208,Attention ,Already Clocked In.,2
}
return
else {
   msgbox, 262208,Attention ,No such Clerk.,2
}
return
reading the code i cant see a problem, but once going, (without the else part as it doesnt work) it just keep saying clerk is clocked in, even if the value is set to yes where it shoulkd say already clocked in.

Re: ini reads

Posted: 10 Jun 2019, 00:53
by wolf_II
Try this:

Code: Select all

MyVar := 1                                                                      ; <<< changed, needed
ClockIn:
FormatTime, TimeIn,, HH:mm:ss
FormatTime, DateIn,, ShortDate
iniread, ClerkIn, Clerk.ini, Clerk, %MyVar%
IniRead Value, Online.ini, Clocked In:, %ClerkIn%
if (Value = "No") {                                                             ; <<< changed, syntax
GuiControl,, MyVar, % MyVar := ""
   msgbox, 262208,Attention ,%ClerkIn% Clocked In.,2
iniwrite Yes, Online.ini, Clocked In:, %ClerkIn%                                ; <<< Not working! Colon instead of decimal point !
iniwrite In, Hours.ini, %ClerkIn% - %DateIn%, %TimeIn% Clocked
}
;return                                                                         ; <<< changed, logical error
if (Value = "Yes") {                                                            ; <<< changed, syntax
GuiControl,, MyVar, % MyVar := ""
   msgbox, 262208,Attention ,Already Clocked In.,2
}
;return                                                                         ; <<< changed, breaks script when present
else {
   msgbox, 262208,Attention ,No such Clerk.,2
}
return
I hope that helps.

Re: ini reads

Posted: 10 Jun 2019, 02:10
by Dyson
wolf_II wrote:
10 Jun 2019, 00:53
Try this:

Code: Select all

MyVar := 1                                                                      ; <<< changed, needed
ClockIn:
FormatTime, TimeIn,, HH:mm:ss
FormatTime, DateIn,, ShortDate
iniread, ClerkIn, Clerk.ini, Clerk, %MyVar%
IniRead Value, Online.ini, Clocked In:, %ClerkIn%
if (Value = "No") {                                                             ; <<< changed, syntax
GuiControl,, MyVar, % MyVar := ""
   msgbox, 262208,Attention ,%ClerkIn% Clocked In.,2
iniwrite Yes, Online.ini, Clocked In:, %ClerkIn%                                ; <<< Not working! Colon instead of decimal point !
iniwrite In, Hours.ini, %ClerkIn% - %DateIn%, %TimeIn% Clocked
}
;return                                                                         ; <<< changed, logical error
if (Value = "Yes") {                                                            ; <<< changed, syntax
GuiControl,, MyVar, % MyVar := ""
   msgbox, 262208,Attention ,Already Clocked In.,2
}
;return                                                                         ; <<< changed, breaks script when present
else {
   msgbox, 262208,Attention ,No such Clerk.,2
}
return
I hope that helps.
i See the changes, and i understand them it works Almost flawlessly, exept if the value of the clerk is "no" it changes it to yes, msgbox appears to say they are clocked in, Followed by msgbox no such clerk, the script is ran on gui buttons ive played around a littlebit with it and still cant seem to resolve this last part of the clocking in script, would it be more benificial for you to see the whole script?

Re: ini reads

Posted: 10 Jun 2019, 07:18
by wolf_II
would it be more benificial for you to see the whole script?
Yes, that would be great.

Re: ini reads

Posted: 10 Jun 2019, 07:39
by Dyson
wolf_II wrote:
10 Jun 2019, 07:18
would it be more benificial for you to see the whole script?
Yes, that would be great.

Code: Select all

Sales:
Gui, 1:Destroy
Gui, 2:Show , w1540 h805, Sign On

gui, 2:add, edit, x1100 y10 w400 h100 vMyVar

Gui, 2:Add, Button, gHome x10 y10 w100 h100, Home

gui, 2:add, button, gClear x10 y113 w85 h85, C
Gui, 2:Add, Button, x95 y113 w170 h85, Sign on

Gui, 2:Add, Button, gAddText1 x10 y197 w85 h85, 1
Gui, 2:Add, Button, gAddText2 x95 y197 w85 h85, 2
Gui, 2:Add, Button, gAddText3 x180 y197 w85 h85, 3

gui, 2:add, button, gAddText4 x10 y281 w85 h85, 4
Gui, 2:Add, Button, gAddText5 x95 y281 w85 h85, 5
Gui, 2:Add, Button, gAddText6 x180 y281 w85 h85, 6

gui, 2:add, button, gAddText7 x10 y365 w85 h85, 7
Gui, 2:Add, Button, gAddText8 x95 y365 w85 h85, 8
Gui, 2:Add, Button, gAddText9 x180 y365 w85 h85, 9

gui, 2:add, button, gAddText0 x10 y449 w85 h85, 0
Gui, 2:Add, Button, gAddText00 x95 y449 w85 h85, 00
Gui, 2:Add, Button, gAddTextdot x180 y449 w85 h85, .


Gui, 2:Add, Button, gClockIn x280 y381 w200 h150 ,Clock in
Gui, 2:Add, Button, gClockOut x480 y381 w200 h150 ,Clock out

gui, 2:add, text, x660 y10, please sign on



return
-------------------------------------------------------------
Home:
gui, 2:Destroy
gui, 3:Destroy
gui, 4:Destroy

Gui, 1:Show , w1540 h805, Home

Gui, 1:Add, Button, x50 y50 w300 h300 gSales ,Sales Mode
Gui, 1:Add, Button, x350 y50 w300 h300 gManager ,Manager Functions



return
--------------------------------------------------------------------
Manager:
Gui, 1:Destroy
Gui, 3:Show , w1540 h805, Manager Functions
Gui, 3:Add, Button, gHome x10 y10 w100 h100, Home
Gui, 3:Add, Button, x150 y50 w250 h250 gAddClerk ,Add Clerk
return

Addclerk:
Gui, 3:Destroy
Gui, 4:Show , w1540 h805, Add Clerk
Gui, 4:Add, Button, gHome x10 y10 w100 h100, Home

gui, 4:add, edit, x150 y10 w400 h50 vMyVar
gui, 4:add, edit, x650 y10 w400 h50 vMyVar2

Gui, 4:Add, Button, gAddTextA x160 y175 w25 h25, A
Gui, 4:Add, Button, gAddTextB x240 y200 w25 h25, B
Gui, 4:Add, Button, gAddTextC x195 y200 w25 h25, C
Gui, 4:Add, Button, gAddTextD x210 y175 w25 h25, D
Gui, 4:Add, Button, gAddTextE x200 y150 w25 h25, E
Gui, 4:Add, Button, gAddTextF x235 y175 w25 h25, F
Gui, 4:Add, Button, gAddTextG x260 y175 w25 h25, G
Gui, 4:Add, Button, gAddTextH x285 y175 w25 h25, H
Gui, 4:Add, Button, gAddTextI x325 y150 w25 h25, I
Gui, 4:Add, Button, gAddTextJ x310 y175 w25 h25, J
Gui, 4:Add, Button, gAddTextK x335 y175 w25 h25, K
Gui, 4:Add, Button, gAddTextL x360 y175 w25 h25, L
Gui, 4:Add, Button, gAddTextM x290 y200 w25 h25, M
Gui, 4:Add, Button, gAddTextN x265 y200 w25 h25, N
Gui, 4:Add, Button, gAddTextO x350 y150 w25 h25, O
Gui, 4:Add, Button, gAddTextP x375 y150 w25 h25, P
Gui, 4:Add, Button, gAddTextQ x150 y150 w25 h25, Q
Gui, 4:Add, Button, gAddTextR x225 y150 w25 h25, R
Gui, 4:Add, Button, gAddTextS x185 y175 w25 h25, S
Gui, 4:Add, Button, gAddTextT x250 y150 w25 h25, T
Gui, 4:Add, Button, gAddTextU x300 y150 w25 h25, U
Gui, 4:Add, Button, gAddTextV x220 y200 w25 h25, V
Gui, 4:Add, Button, gAddTextW x175 y150 w25 h25, W
Gui, 4:Add, Button, gAddTextX x195 y200 w25 h25, X
Gui, 4:Add, Button, gAddTextY x275 y150 w25 h25, Y
Gui, 4:Add, Button, gAddTextZ x170 y200 w25 h25, Z
Gui, 4:Add, Button, gAddTextspace x315 y200 w75 h25, Space

gui, 4:add, button, gClear x10 y113 w85 h85, C

Gui, 4:Add, Button, gAddaText1 x650 y197 w85 h85, 1
Gui, 4:Add, Button, gAddaText2 x734 y197 w85 h85, 2
Gui, 4:Add, Button, gAddaText3 x818 y197 w85 h85, 3
gui, 4:add, button, gAddaText4 x650 y281 w85 h85, 4
Gui, 4:Add, Button, gAddaText5 x734 y281 w85 h85, 5
Gui, 4:Add, Button, gAddaText6 x818 y281 w85 h85, 6
gui, 4:add, button, gAddaText7 x650 y365 w85 h85, 7
Gui, 4:Add, Button, gAddaText8 x734 y365 w85 h85, 8
Gui, 4:Add, Button, gAddaText9 x818 y365 w85 h85, 9
gui, 4:add, button, gAddaText0 x734 y449 w85 h85, 0

gui, 4:add, Button, gAddclerk2 x150 y300 w150 h85, Add Clerk
return
-------------------------------------------------------------
GuiClose: 
ExitApp

Addclerk2:
IniWrite, %MyVar%, Clerk.ini, Clerk, %myVar2%
iniwrite No, Online.ini, Clocked In:, %MyVar%
return

ClockIn:
FormatTime, TimeIn,, HH:mm:ss
FormatTime, DateIn,, ShortDate
iniread, ClerkIn, Clerk.ini, Clerk, %MyVar%
IniRead Value, Online.ini, Clocked In:, %ClerkIn%
if (Value = "No") {                            
GuiControl,, MyVar, % MyVar := ""
   msgbox, 262208,Attention ,%ClerkIn% Clocked In.,2
iniwrite Yes, Online.ini, Clocked In:, %ClerkIn%            
iniwrite In, Hours.ini, %ClerkIn% - %DateIn%, %TimeIn% Clocked
}
;return                                              
if (Value = "Yes") {                              
GuiControl,, MyVar, % MyVar := ""
   msgbox, 262208,Attention ,Already Clocked In.,2
}
;return                                  
else {
GuiControl,, MyVar, % MyVar := ""
   msgbox, 262208,Attention ,No such Clerk.,2
}
return

ClockOut:
FormatTime, TimeOut,, HH:mm:ss
FormatTime, DateOut,, ShortDate
iniread, ClerkOut, Clerk.ini, Clerk, %MyVar%
    GuiControl,, MyVar, % MyVar := ""
    msgbox, 262208,Attention ,%ClerkOut% Clocked Out.,2

iniwrite No, Online.ini, Clocked In:, %ClerkOut%
iniwrite %DateOut%, Hours.ini, %ClerkOut%, %TimeOut% Clock Out
return

AddText1:
AddText2:
AddText3:
AddText4:
AddText5:
AddText6:
AddText7:
AddText8:
AddText9:
AddText0:
AddText00:
  GuiControl, , MyVar, % MyVar .= SubStr(A_ThisLabel,8)
Return
AddTextA:
AddTextB:
AddTextC:
AddTextD:
AddTextE:
AddTextF:
AddTextG:
AddTextH:
AddTextI:
AddTextJ:
AddTextK:
AddTextL:
AddTextM:
AddTextN:
AddTextO:
AddTextP:
AddTextQ:
AddTextR:
AddTextS:
AddTextT:
AddTextU:
AddTextV:
AddTextW:
AddTextX:
AddTextY:
AddTextZ:
  GuiControl, , MyVar, % MyVar .= SubStr(A_ThisLabel,8)
return
AddaText1:
AddaText2:
AddaText3:
AddaText4:
AddaText5:
AddaText6:
AddaText7:
AddaText8:
AddaText9:
AddaText0:
  GuiControl, , MyVar2, % MyVar2 .= SubStr(A_ThisLabel,9)
Return

AddTextdot:
  GuiControl, , MyVar, % MyVar .= "."
Return

AddTextspace:
  GuiControl, , MyVar, % MyVar .= " "
Return

Clear:
    GuiControl,, MyVar, % MyVar := ""
    GuiControl,, MyVar2, % MyVar2 := ""
return

Re: ini reads

Posted: 10 Jun 2019, 08:14
by wolf_II
First Look: I like your GUI. Especially the Keyboard layout. Is it meant to include X ? there is a Label for it, so that might be a Label too many, or a Key missing or something else.

I was surprised to see no errors popping up for your lines containing only ----.
I don't know if that is a correct syntax
(but I will not argue with the AHK-interpreter, He is boss and that's the end of story). however, I recommend to use a semicolon in front of those.
(Have you programmed in Euphoria before? over there, double -- would be a valid comment marker).

Don't keep the ;return, remove them, they are not needed.

It is possible to clean up the columns of labels, if you want, but let's not talk aesthetics before the code is stable.
What seems to be the problem? apart from awful flickering/flashing of the windows being constantly destroyed.

Re: ini reads

Posted: 10 Jun 2019, 08:51
by Dyson
if I type the clerk number in and press clock in it executes this:

Code: Select all

GuiControl,, MyVar, % MyVar := ""
   msgbox, 262208,Attention ,%ClerkIn% Clocked In.,2
iniwrite Yes, Online.ini, Clocked In:, %ClerkIn%            
iniwrite In, Hours.ini, %ClerkIn% - %DateIn%, %TimeIn% Clocked
AND:

Code: Select all

GuiControl,, MyVar, % MyVar := ""
   msgbox, 262208,Attention ,No such Clerk.,2
I don't want the second mshbox unless there is no valid key to read.

Re: ini reads

Posted: 10 Jun 2019, 12:12
by YoucefHam
Try it

Code: Select all

; ############################################################
Gui, 1:Add, Button, x50 y50 w300 h300 gSales ,Sales Mode
Gui, 1:Add, Button, x350 y50 w300 h300 gManager ,Manager Functions
; ############################################################

Gui, 2: Font, s16

Gui, 2:add, Edit, x1100 y10 w400 h100 vClerkNumIn Password* ;or Password#

;~ Gui, 2:Add, Picture, gHome x10 y10 w100 h-1, Home.png
Gui, 2:Add, Button, gHome x10 y10 w100 h100, Home

Gui, 2:add, button, gClear x10 y113 w85 h85, C
Gui, 2:Add, Button, x95 y113 w170 h85, Sign on
Gui, 2:Add, Button, gAddText x10 y197 w85 h85, 1
Gui, 2:Add, Button, gAddText x95 y197 w85 h85, 2
Gui, 2:Add, Button, gAddText x180 y197 w85 h85, 3
gui, 2:add, button, gAddText x10 y281 w85 h85, 4
Gui, 2:Add, Button, gAddText x95 y281 w85 h85, 5
Gui, 2:Add, Button, gAddText x180 y281 w85 h85, 6
gui, 2:add, button, gAddText x10 y365 w85 h85, 7
Gui, 2:Add, Button, gAddText x95 y365 w85 h85, 8
Gui, 2:Add, Button, gAddText x180 y365 w85 h85, 9
gui, 2:add, button, gAddText x10 y449 w85 h85, 0
Gui, 2:Add, Button, gAddText x95 y449 w85 h85, 00
Gui, 2:Add, Button, gAddText x180 y449 w85 h85, .
Gui, 2:Add, Button, gClockIn x280 y381 w200 h150 ,Clock in
Gui, 2:Add, Button, gClockOut x480 y381 w200 h150 ,Clock out
Gui, 2: Font, s28 
Gui, 2:add, text, x660 y10, Please sign on
Gui, 2: Font, s16

; ############################################################
Gui, 3:Add, Button, gHome x10 y10 w100 h100, Home
Gui, 3:Add, Button, x150 y50 w250 h250 gAddClerk ,Add Clerk
; ############################################################
Gui, 4:Add, Button, gHome x10 y10 w100 h100, Home

gui, 4:add, edit, x150 y10 w400 h50 vClerkName
gui, 4:add, edit, x650 y10 w400 h50 vClerkNum

Gui, 4:Add, Button, gAddTextName x160 y175 w25 h25, A
Gui, 4:Add, Button, gAddTextName x240 y200 w25 h25, B
Gui, 4:Add, Button, gAddTextName x195 y200 w25 h25, C
Gui, 4:Add, Button, gAddTextName x210 y175 w25 h25, D
Gui, 4:Add, Button, gAddTextName x200 y150 w25 h25, E
Gui, 4:Add, Button, gAddTextName x235 y175 w25 h25, F
Gui, 4:Add, Button, gAddTextName x260 y175 w25 h25, G
Gui, 4:Add, Button, gAddTextName x285 y175 w25 h25, H
Gui, 4:Add, Button, gAddTextName x325 y150 w25 h25, I
Gui, 4:Add, Button, gAddTextName x310 y175 w25 h25, J
Gui, 4:Add, Button, gAddTextName x335 y175 w25 h25, K
Gui, 4:Add, Button, gAddTextName x360 y175 w25 h25, L
Gui, 4:Add, Button, gAddTextName x290 y200 w25 h25, M
Gui, 4:Add, Button, gAddTextName x265 y200 w25 h25, N
Gui, 4:Add, Button, gAddTextName x350 y150 w25 h25, O
Gui, 4:Add, Button, gAddTextName x375 y150 w25 h25, P
Gui, 4:Add, Button, gAddTextName x150 y150 w25 h25, Q
Gui, 4:Add, Button, gAddTextName x225 y150 w25 h25, R
Gui, 4:Add, Button, gAddTextName x185 y175 w25 h25, S
Gui, 4:Add, Button, gAddTextName x250 y150 w25 h25, T
Gui, 4:Add, Button, gAddTextName x300 y150 w25 h25, U
Gui, 4:Add, Button, gAddTextName x220 y200 w25 h25, V
Gui, 4:Add, Button, gAddTextName x175 y150 w25 h25, W
Gui, 4:Add, Button, gAddTextName x195 y200 w25 h25, X
Gui, 4:Add, Button, gAddTextName x275 y150 w25 h25, Y
Gui, 4:Add, Button, gAddTextName x170 y200 w25 h25, Z
Gui, 4:Add, Button, gAddTextspace x315 y200 w75 h25, Space

gui, 4:add, button, gClear x10 y113 w85 h85, C

Gui, 4:Add, Button, gAddTextNum x650 y197 w85 h85, 1
Gui, 4:Add, Button, gAddTextNum x734 y197 w85 h85, 2
Gui, 4:Add, Button, gAddTextNum x818 y197 w85 h85, 3
gui, 4:add, button, gAddTextNum x650 y281 w85 h85, 4
Gui, 4:Add, Button, gAddTextNum x734 y281 w85 h85, 5
Gui, 4:Add, Button, gAddTextNum x818 y281 w85 h85, 6
gui, 4:add, button, gAddTextNum x650 y365 w85 h85, 7
Gui, 4:Add, Button, gAddTextNum x734 y365 w85 h85, 8
Gui, 4:Add, Button, gAddTextNum x818 y365 w85 h85, 9
gui, 4:add, button, gAddTextNum x734 y449 w85 h85, 0

gui, 4:add, Button, gAddclerk2 x150 y300 w150 h85, Add Clerk

Gui, 2:Show , w1540 h805, Home
return

Home:
Gui, 2:Hide
Gui, 3:Hide
Gui, 4:Hide
Gui, 1:Show , w1540 h805, Home
return

Sales:
Gui, 1:Hide
Gui, 2:Show , w1540 h805, Home
return

Manager:
Gui, 1:Hide
Gui, 3:Show , w1540 h805, Manager Functions
return

Addclerk:
Gui, 3:Hide
Gui, 4:Show , w1540 h805, Add Clerk
return

;-------------------------------------------------------------
1GuiClose:
Gui, 1:Hide
Gui, 2:Show , w1540 h805, Home
return

2GuiClose:
ExitApp
return

3GuiClose:
Gui, 3:Hide
Gui, 2:Show , w1540 h805, Home
return

4GuiClose:
Gui, 4:Hide
Gui, 3:Show , w1540 h805, Manager Functions
return

Addclerk2:
Gui, Submit, NoHide
IniRead, IsClerkNumExist, Clerk.ini, Clerk, %ClerkNum%
if (IsClerkNumExist == "ERROR")
{
    IniRead, ClerkList, Clerk.ini, ClerkList, ClerkList
    if (ClerkList == "ERROR")
    {
        IniWrite, |, Clerk.ini, ClerkList, ClerkList
        IniRead, ClerkList, Clerk.ini, ClerkList, ClerkList
    }
    IfNotInString, ClerkList, %ClerkName%
    {
        IniWrite, %ClerkName%, Clerk.ini, Clerk, %ClerkNum%
        IniWrite, %ClerkList%%ClerkName%|, Clerk.ini, ClerkList, ClerkList
        IniWrite, No, Online.ini, Clocked In:, %ClerkName%
        MsgBox, 262208,Attention ,%ClerkName% Created.,2
        return
    }
    else
    {
        MsgBox, 16,Attention ,%ClerkName% Exist.,2
    }
}
else
    MsgBox, 16,Attention ,%ClerkNum% Exist.,2
return

ClockIn:
Gui, Submit, NoHide
if (ClerkNumIn == "")
{
    MsgBox, 262192,Attention ,Please Type a password to Clock In.,2
    return
}
IniRead, ClerkInName, Clerk.ini, Clerk, %ClerkNumIn%
IniRead, Value, Online.ini, Clocked In:, %ClerkInName%
if (Value == "No")
{
    FormatTime, TimeIn,, HH:mm:ss
    FormatTime, DateIn,, ShortDate
    IniWrite, Yes, Online.ini, Clocked In:, %ClerkInName%
    IniWrite, %A_Now%, Online.ini, Clocked In:, %ClerkInName% Last Time Clocked in
    IniWrite, In, Hours.ini, %ClerkInName% - %DateIn%, %TimeIn% Clocked
    GuiControl,, ClerkNumIn
    MsgBox, 262208,Attention ,%ClerkInName% Clocked In.,2
}
else
    MsgBox, 262192,Attention , You are Clock In,2
return

ClockOut:
Gui, Submit, NoHide
if (ClerkNumIn == "")
{
    MsgBox, 262192,Attention ,Please Type a password to Clock Out.,2
    return
}
IniRead, ClerkInName, Clerk.ini, Clerk, %ClerkNumIn%
IniRead, Value, Online.ini, Clocked In:, %ClerkInName%
if (Value == "Yes")
{
    FormatTime, TimeIn,, HH:mm:ss
    FormatTime, DateIn,, ShortDate
    IniRead, LastTimeClockedin, Online.ini, Clocked In:, %ClerkInName% Last Time Clocked in
    RegExMatch(LastTimeClockedin, "(....)(..)(..)(..)(..)(..)",D)
    TimeClockedin := ((A_YYYY - D1) ? A_YYYY - D1 " Years, " : "") ((A_MM - D2) ? A_MM - D2 " Mounths, " : "") ((A_DD - D3) ? A_DD - D3 " Days, " : "") ((A_Hour - D4) ? A_Hour - D4 " Hours, " : "") ((A_Min - D5) ? A_Min - D5 " Minutes, " : "") ((A_Sec - D6) ? A_Sec - D6 " Seconds" : "")
    IniWrite, Out (After %TimeClockedin%), Hours.ini, %ClerkInName% - %DateIn%, %TimeIn% Clocked
    IniWrite, No, Online.ini, Clocked In:, %ClerkInName%
    GuiControl,, ClerkNumIn
    MsgBox, 262208,Attention ,%ClerkInName% Clocked Out.,2
}
else
    MsgBox, 262192,Attention ,Please Clock in First.,2
return

AddText:
Gui, Submit, NoHide
  GuiControl, , ClerkNumIn, % ClerkNumIn A_GuiControl
Return

Clear:
ClerkNumIn := ClerkNum := ClerkName := ""
GuiControl,, ClerkNumIn
GuiControl,, ClerkNum
GuiControl,, ClerkName
return

AddTextName:
Gui, Submit, NoHide
  GuiControl,, ClerkName, % ClerkName A_GuiControl
return

AddTextNum:
Gui, Submit, NoHide
  GuiControl,, ClerkNum, % ClerkNum A_GuiControl
return

AddTextspace:
  GuiControl,, ClerkName, % ClerkName " "
Return