Jump to content

_DateAdd Problem


Recommended Posts

When I enter the Date, and click "Check Date" it results as a Zero -.- what did I do wrong?

CODE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;Randy's BlockBuster Thing V1.0;;;;;;;;;;;

;;;;;;;;Last Update: 04/01/07 @ 12:29am;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;includes

#include <GUIConstants.au3>

#include <File.au3>

#include<date.au3>

#NoTrayIcon ;Hide the tray icon

;Set Mouse Clicks to relitive

;Set Hotkeys

;Set Variables

$Times = 0

$Randy = ("diablo_rules78@hotmail.com")

$Credits = ("Randy S.")

$Title = ("BlockBuster 28 day wait")

$Version = (" V1.0")

$Date = ("April 4, 2007")

$Today = _NowCalcDate()

$createmain = GUICreate($Title & $Version, 300, 200)

;;;;; Menu ;;;;;

$filemenu = GUICtrlCreateMenu("File")

$fileabout = GUICtrlCreateMenuItem("About", $filemenu)

$fileclose = GUICtrlCreateMenuItem("Close", $filemenu)

$editmenu = GUICtrlCreateMenu("Edit")

$Wordlistedit = GUICtrlCreateMenuitem("Word List", $editmenu)

$internetedit = GUICtrlCreateMenuItem("Internet Settings", $editmenu)

$proxylist = GUICtrlCreateMenuItem("Proxy List", $editmenu)

$helpmenu = GUICtrlCreateMenu("Help")

$FAQmenu = GUICtrlCreateMenuItem("FAQ", $helpmenu)

;;;;; Labels ;;;;;

GUICtrlCreateLabel("Welcome to Free rental Tracker!", 0,0,160,17)

GuiCtrlCreateLabel("Todays Date is: " & $Today, 0, 20, 150, 17)

GuiCtrlCreateLabel("Please enter release date (YYYY/MM/DD)", 0, 50, 250, 17)

GuiCtrlCreateLabel("Your rental is free on ", 0, 100, 150, 17)

;;;;; Input Boxes ;;;;;

;gUICtrlCreateInput(

$YYYY=GUICtrlCreateInput("YYYY", 50, 70, 35, 17, $ES_NUMBER)

$MM=GUICtrlCreateInput("MM", 85, 70, 25, 17, $ES_NUMBER)

$DD=GUICtrlCreateInput("DD", 110, 70, 25, 17, $ES_NUMBER)

$Free = GUICtrlCreateLabel("",0,130,150,17)

;;;;; Boxes ;;;;;

$startbrutingbutton = GUICtrlCreateButton("Check Date", 100, 150, 100, 30)

GUISetState()

While 1

$msg = guigetmsg()

if $msg = $startbrutingbutton then

Start()

Endif

If $msg = $faqmenu Then

FAQ()

EndIf

If $msg = $fileclose Then

GUIDelete($createmain)

EndIf

If $msg = $GUI_EVENT_CLOSE Then

GUIDelete($createmain)

EndIf

If $msg = $GUI_EVENT_CLOSE Then

GuiDelete($createmain)

EndIf

if $msg = $FileAbout Then

About()

EndIf

WEnd

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;Start;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func Start()

$Actual = ($YYYY + "/" + $MM + "/" + $DD)

$29days = _DateAdd( "D", 29,$Actual)

$Free = GUICtrlCreateLabel($29Days,0,130,150,17)

EndFunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;Frequently Asked Questions;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func FAQ()

$createfaq = GUICreate("FAQ - " & $Title & $Version, 300, 300, 400, 500)

$buttonOkfaq = GUICtrlCreateButton("OK", 130, 260, 40, 30)

$labelfaq = GUICtrlCreateLabel("FAQ", 140, 25)

$labelq1 = GUICtrlCreateLabel("", 45, 60)

$labela1 = GUICtrlCreateLabel("", 12, 80)

$labela11 = GUICtrlCreateLabel("", 12, 95)

$labelq2 = GUICtrlCreateLabel("", 15, 120)

$labelq22 = GUICtrlCreateLabel("", 95, 135)

$labela2 = GUICtrlCreateLabel("", 23, 155)

$labela22 = GuiCtrlCreateLabel(", 55, 170)

GUISetState()

While 1

$msgfaq = GUIGetMsg()

If $msgfaq = $buttonokfaq Then

Return GUIDelete($createfaq)

EndIf

If $msgfaq = $GUI_EVENT_CLOSE Then

Return GUIDelete($createfaq)

EndIf

WEnd

EndFunc

Func About()

$createfaq = GUICreate("FAQ - " & $Title & $Version, 300, 300)

$buttonOkfaq = GUICtrlCreateButton("OK", 130, 260, 40, 30) ;Okay Button

$labelfaq = GUICtrlCreateLabel("FAQ", 140, 25)

$labelq1 = GUICtrlCreateLabel($Title & $Version & " was created by: " & $Credits & " on " & $Date , 15, 60)

$labela1 = GUICtrlCreateLabel("", 12, 80)

$labela11 = GUICtrlCreateLabel("", 12, 95)

$labelq2 = GUICtrlCreateLabel("", 15, 120)

$labelq22 = GUICtrlCreateLabel("", 95, 135)

$labela2 = GUICtrlCreateLabel("", 23, 155)

$labela22 = GuiCtrlCreateLabel("", 55, 170)

GUISetState()

While 1

$msgfaq = GUIGetMsg()

If $msgfaq = $buttonokfaq Then

Return GUIDelete($createfaq)

EndIf

If $msgfaq = $GUI_EVENT_CLOSE Then

Return GUIDelete($createfaq)

EndIf

WEnd

EndFunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;Pause Function;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func TogglePause()

$Paused = NOT $Paused

While $Paused

sleep(100)

ToolTip('Script is "Paused"',0,0)

WEnd

ToolTip("")

EndFunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;Force Close Function;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func Terminate()

Exit 0

EndFunc

Link to comment
Share on other sites

Func Start()

$Actual = ($YYYY + "/" + $MM + "/" + $DD);<-------------replace '+' with '&'

$29days = _DateAdd( "D", 29,$Actual)

$Free = GUICtrlCreateLabel($29Days,0,130,150,17)

EndFunc

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

$Actual = _DateAdd( 'd',29, _NowCalcDate())
$split = StringSplit($Actual, '/')
$calculed = $split[3] & '/' & _GetMonth($split[2]) & '/' & $split[1]
GUICtrlCreateLabel ("" & $calculed, 0,130,150,17)


Func _GetMonth($nMonth)
Local $aMonth = StringSplit('01,02,03,04,05,06,07,08,09,10,11,12', ',')
Return $aMonth[$nMonth]
EndFunc

Try it...

I'm a Italian a AutoIterMy scriptTxTediTor -->TxTediTor is a simple program similar notepad[center]Please vote me with five star ;)Antonio Caragliano for Nokia Nseries[/center]
Link to comment
Share on other sites

  • Developers

$Actual = _DateAdd( 'd',29, _NowCalcDate())
$split = StringSplit($Actual, '/')
$calculed = $split[3] & '/' & _GetMonth($split[2]) & '/' & $split[1]
GUICtrlCreateLabel ("" & $calculed, 0,130,150,17)
Func _GetMonth($nMonth)
Local $aMonth = StringSplit('01,02,03,04,05,06,07,08,09,10,11,12', ',')
Return $aMonth[$nMonth]
EndFunc

Try it...

The script doesn't run this way.... would be helpful to post a cscript we can run to see your issue.

But after changing it ... it seems to run fine.... now what exactly isnt working in it ?

#include<date.au3>
$Actual = _DateAdd( 'd',29, _NowCalcDate())
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Actual = ' & $Actual & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : _NowCalcDate = ' & _NowCalcDate() & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$split = StringSplit($Actual, '/')
$calculed = $split[3] & '/' & _GetMonth($split[2]) & '/' & $split[1]
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $calculed = ' & $calculed & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console


Func _GetMonth($nMonth)
Local $aMonth = StringSplit('01,02,03,04,05,06,07,08,09,10,11,12', ',')
Return $aMonth[$nMonth]
EndFunc
Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

The script doesn't run this way.... would be helpful to post a cscript we can run to see your issue.

But after changing it ... it seems to run fine.... now what exactly isnt working in it ?

#include<date.au3>
$Actual = _DateAdd( 'd',29, _NowCalcDate())
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Actual = ' & $Actual & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : _NowCalcDate = ' & _NowCalcDate() & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$split = StringSplit($Actual, '/')
$calculed = $split[3] & '/' & _GetMonth($split[2]) & '/' & $split[1]
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $calculed = ' & $calculed & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
Func _GetMonth($nMonth)
Local $aMonth = StringSplit('01,02,03,04,05,06,07,08,09,10,11,12', ',')
Return $aMonth[$nMonth]
EndFuncoÝ÷ Ú+-ë¬z¸§¦ël¶²yªæ¢{au¬­é¨¾'°jÊÞæ¬yÖ§vØ^Ø^¦º ­©uÛ6õÖ²²Ú-çZµëaz뮬uçâçZºÚ"µÍÌÍÌY^ÈHÑ]PY
    ][ÝÑ  ][ÝËK ÌÍÐXÝX[
oÝ÷ Ù»­¶©®åzh¬Æ®¶­sbb33c´7GVÂÒb33cµfײgV÷C²ògV÷C²fײb33c´ÔÒfײgV÷C²ògV÷C²fײb33c´DB
always = Zero
Edited by Ch1ldProd1gy
Link to comment
Share on other sites

but the problem is...is

$Actual = ($YYYY & "/" & $MM & "/" & $DD)
always = Zero

$YYYY is not a year it is the inpout box

You should use GuiCtrRead($YYYY), GuiCtrlRead($MM) etc

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • 2 weeks later...

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