Jump to content

Time People Schedule Help!


Recommended Posts

I am trying to write a script that will eventually go into a GUI but for now I'm just trying to get the script to run. I am trying to see "Who's Working" according to the times. I am having trouble with the overlap. If the end of someone's shift is 3pm but you're coming in at 1pm I can't view the two people only one. Also Trying to figure out how correlate people with dates (haven't been able to figure out how to put that in for the whole month) and when I'm calling the times can I do 17:30? I have issues with that as well. Any help would be greatly appreciated! 

Attached is the txt file that should be on the Desktop and the au3 code. but I'll paste the code in here as well.

; Determine workgroup and shift  (These are hardcoded here but can be determined any way you want)
Local $workgroupName = _WorkGroup()
Local $shift = _Time()

; Build header to search the text file for
Local $contactHeader = $workgroupName & $shift

; Declare variable to hold the body of the contact info to display
Local $contactBody = ""

; Create file handle
Local $file = FileOpen(@DesktopDir & "\ContactInfo.txt", 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Read in lines of text until the EOF is reached
While 1
    ; Read line
    Local $line = FileReadLine($file)
    ;Handle Error
    If @error = -1 Then ExitLoop
    
    ; search for workgroup header
    if $line = $contactHeader then
    
        ; Read next line
        $line = FileReadLine($file)
        
        ; Build contact info body until terminator is reached
        Do      
            ; Add current line to contact body plus a carriage return ASCII code 
            ;   so that a new line begins next time through the loop
            $contactBody = $contactBody & $line & chr(13)
            ; Read next line
            $line = FileReadLine($file)
        
        Until $line = ";"
    
        ; Exit while loop to read file
        ExitLoop
    
    EndIf
    
WEnd

; Close file
FileClose($file)

; Populate label for message box
Local $contactString = "Workgroup: " & _WorkGroup() & chr(13)
$contactString = $contactString & "Shift: " & _Time() & chr(13) & chr(13)
$contactString = $contactString & $contactBody

; Display message box
MsgBox(4096, "Contact Info", $contactString)

Func _Time()
    Local $AMPM, $hour
    If @HOUR <= 05 Then
        $hour = ("Night")
    ElseIf @hour >= 18 Then
        $hour = ("Night")
    ElseIf
        $hour = ("Day")
    EndIf
    Return $hour
EndFunc ;==>_Time

Func _WorkGroup()
    Local $AMPM, $hour
    If @HOUR >= 02 And @HOUR <=11 Then
        $hour = ("Workgroup2")
    ElseIf @HOUR >= 10 And @HOUR <= 19  Then
        $hour = ("Workgroup3")
    ElseIf @HOUR >= 23 And @HOUR <= 08 Then
        $hour = ("Workgroup1")
    EndIf
    Return $hour
EndFunc ;==>_Time

ContactInfo.au3

ContactInfo.txt

Link to comment
Share on other sites

It sounds like you're trying to manage employee times and contact data.  Wouldn't you be better off using MS Access, MS Excel, or another program to view/manage all that data?  I have personally used both Access & Excel, and they're good at what they do (and VB has a built-in datatype for handling time/dates).  You can do this in AutoIt if you like, but it's usually better not to reinvent the wheel.  If you want to use AutoIt anyway, check out the UDF called Date.au3 in your Include directory (or Help File -> UDFs -> Date Management).  You'll find lots of useful functions there.

Edited by Artisan
Link to comment
Share on other sites

See I get all that information sent every month that is on an Excel spreadsheet with 6 different tabs. I was going to have all that information put on one tab then pull that data into a text file and you could hit a button and it wil show you these people (according to the time[i got that figured out] and date[no clue how to do this one] display who is working. The information needs to be access quickly and would be put into a GUI that i created that houses buttons that link to different information so it's easier and faster to access. I'm just stuck on how to refer this to the dates for each month..

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

×
×
  • Create New...