Jump to content

Problems with date in .txt files


Baster
 Share

Recommended Posts

How about this?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
#include <File.au3>

$Form1 = GUICreate("Territories", 477, 237, 192, 124)
$File = GUICtrlCreateMenu("&File")
$Exit = GUICtrlCreateMenuItem("E&xit", $File)
$Tools = GUICtrlCreateMenu("T&ools")
$OverTime = GUICtrlCreateMenuItem("Ch&eck expiration", $Tools)
GUISetState(@SW_SHOW)
Dim $Form1_AccelTable[2][2] = [["!x", $Exit],["^h", $OverTime]]
GUISetAccelerators($Form1_AccelTable)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
        Exit
    Case $Exit
        Exit
    Case $OverTime
        $file = FileOpen("C:Users\Utente\Documents\Date.txt")
        $AnyDate = FileReadLine($file,-1)
        FileClose($file)

        $TodayDate = _NowCalcDate()
        $AnyDate = StringMid($AnyDate, 7, 4) & "/" & StringMid($AnyDate, 4, 2) & "/" & StringMid($AnyDate, 1, 2)
        MsgBox(4096, "",  "Date read: " & $AnyDate & @CRLF & _
        "Today: " & _NowCalcDate() & @CRLF & _
        "Difference in days: " & _DateDiff("d", $AnyDate, $TodayDate) & @CRLF & _
        "Difference in months: " & _DateDiff("m", $AnyDate, $TodayDate))
    EndSwitch
WEnd
Edited by czardas
Link to comment
Share on other sites

Did you know that AutoIt isn't case sensitive? That was the problem! If you see in the KODA GUI REGION you will see a variable, $File, that has the same name of our $file variable..

Thank you for all your time spent on this problem.. Thank you very much :D

Edited by Baster
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...