Jump to content

calculate the date.


Recommended Posts

hi i have some calculate problems...

here is the code.

Func date()
   if $ar=@year And (($dag+14 ) < @yday) then
   Call("monad")
   else
   MouseClick("left",448, 164)
   Sleep(500)
   MouseClick("left",466, 230)
   endif
EndFunc
Func monad()
do
  if $month = "jan " Then
   MouseClick("left",448, 164)
   Sleep(500)
   MouseClick("left",524, 228)
ExitLoop

  Else
   $dag=$dag +31
  EndIf
  if $month = "feb " Then
    MouseClick("left",448, 164)
   Sleep(500)
   MouseClick("left",524, 228)
ExitLoop
 
  Else
   $dag=$dag+29
  EndIf
  if $month = "mar " Then
    MouseClick("left",448, 164)
   Sleep(500)
   MouseClick("left",524, 228)
ExitLoop
 
  Else
   $dag=$dag+31
  EndIf
  if $month = "apr " Then
    MouseClick("left",448, 164)
   Sleep(500)
   MouseClick("left",524, 228)
ExitLoop
 
  Else
   $dag=$dag+30
  EndIf
    if $month = "may " Then
    MouseClick("left",448, 164)
   Sleep(500)
   MouseClick("left",524, 228)
ExitLoop
 
  Else
   $dag=$dag+31
  EndIf
    if $month = "jun " Then
    MouseClick("left",448, 164)
   Sleep(500)
   MouseClick("left",524, 228)
ExitLoop
 
  Else
   $dag=$dag+30
  EndIf
    if $month = "jul " Then
    MouseClick("left",448, 164)
   Sleep(500)
   MouseClick("left",524, 228)
ExitLoop
 
  Else
   $dag=$dag+31
  EndIf
    if $month = "agu " Then
    MouseClick("left",448, 164)
   Sleep(500)
   MouseClick("left",524, 228)
ExitLoop
 
  Else
  $dag=$dag+31
  EndIf
    if $month = "sep " Then
    MouseClick("left",448, 164)
   Sleep(500)
   MouseClick("left",524, 228)
ExitLoop
 
  Else
  $dag=$dag+30
  EndIf
    if $month = "oct " Then
    MouseClick("left",448, 164)
   Sleep(500)
   MouseClick("left",524, 228)
ExitLoop
 
  Else
   $dag=$dag+31
  EndIf
    if $month = "nov " Then
    MouseClick("left",448, 164)
   Sleep(500)
   MouseClick("left",524, 228)
ExitLoop
 
  Else
   $dag=$dag+30
  EndIf
    if $month = "dec " Then
    MouseClick("left",448, 164)
   Sleep(500)
   MouseClick("left",524, 228)
ExitLoop
 
  Else
   $dag=$dag+31
  EndIf
  until 1=1
EndFunc

and here is where the problems is.

Func date()
   if $ar=@year And (($dag+14 ) < @yday) then
   Call("monad")
   else
   MouseClick("left",448, 164)
   Sleep(500)
   MouseClick("left",466, 230)
   endif
EndFunc

the problem is that the calculation does not work. i want the script to take the year and the month and the day a person registerd on a forum, and thats works perfektly. but i have this calculation becuse i want the script to know if the person was last active on the forum in the past 14 days. but now it is saying that every one who registerd at the year of 2012 have been online during the past 14 days but that is not correct.

so if someone knows a cleaver way to slow this and like to share it with me i will be very thanks full and you will be a :king:

Link to comment
Share on other sites

Look at the _DateAdd function, it should do exactly what you're trying to do.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

thank you for the tip i have look it up and i agree that this could be the answer, but i do not understand what do to. i have chance the calculation to this insted.

Func datex()
If $dag = _DateAdd('d', -14, _NowCalcDate()) Then
MsgBox(4096, "d", "Today minus 14 days: " & $day)
monad()
   else
   MouseClick("left",448, 164)
   Sleep(500)
   MouseClick("left",466, 230)
   endif
EndFunc

what happens when i run the script with this calculation it says that this user have not been online in the past 14 days but when i look he was online 12 jul 2012 so that is not correct.

so if anyone know a way to make this calcutaion work i will be very happy ;)

Link to comment
Share on other sites

It all depends on what values $dag and $day equal whether that will work correctly.

This works fine for me.

#include <date.au3>
MsgBox(64, "", "Today is: " & _NowCalcDate() & @CRLF & "14 days ago it was: " & _DateAdd("d", -14, _NowCalcDate()))

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

It all depends on what values $dag and $day equal whether that will work correctly.

This works fine for me.

#include <date.au3>
MsgBox(64, "", "Today is: " & _NowCalcDate() & @CRLF & "14 days ago it was: " & _DateAdd("d", -14, _NowCalcDate()))

hm i think i understand. but my script need to work. the variable $dag incloude the day 12 in this case but it still does not work :/ i tryed your script to but that one i dont know how to make so it will work in my script. the thing with my script if that i have to make the script to know if the user have been online in the past 14 days then it will make him green. if not he will make him red.
Link to comment
Share on other sites

Well, you're going to have to give the function the date in the correct format or it won't ever work. Another function to look at is the _DateDiff function, you give it 2 dates and it tells you how far apart the dates are from each other, in Years/Months/Days etc. depending on which flag you use for the $sType value. BUT, you will still have to give it a date in the correct format for it to work, and that format is YYYY/MM/DD HH:MM:SS. The HH:MM:SS is optional and you don't need it if you're just checking how many days apart something is.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Well, you're going to have to give the function the date in the correct format or it won't ever work. Another function to look at is the _DateDiff function, you give it 2 dates and it tells you how far apart the dates are from each other, in Years/Months/Days etc. depending on which flag you use for the $sType value. BUT, you will still have to give it a date in the correct format for it to work, and that format is YYYY/MM/DD HH:MM:SS. The HH:MM:SS is optional and you don't need it if you're just checking how many days apart something is.

kk i think i got it now, but the problem is that the months is writen in laters. like juliy is jul and mars is mar. it is posible to maby make a translater? exampel if it takes the present month of juliy it will make the variable $month = jul but if i make a script thats take

if $month = jul then

$month = 07

else

endif

so then i will give the variable the correct format? is that possible`?

Link to comment
Share on other sites

kk i think i got it now, but the problem is that the months is writen in laters. like juliy is jul and mars is mar. it is posible to maby make a translater? exampel if it takes the present month of juliy it will make the variable $month = jul but if i make a script thats take

if $month = jul then

$month = 07

else

endif

so then i will give the variable the correct format? is that possible`?

Here are two methods of converting an abbreviated three character month name or a complete month name into an equivalent two digit month's number.

Local $s = "Jun" ; 'April'

Local $iNumRE = MonthToNumberRE($s)
ConsoleWrite('"' & $s & '" is month number ' & $iNumRE & @LF)

Local $iNumA = MonthToNumberA($s)
ConsoleWrite('"' & $s & '" is month number ' & $iNumA & @LF)


Func MonthToNumberRE($s)
    Return StringRight("0" & UBound(StringRegExp($s, '(?i)(jan)|(feb)|(mar)|(apr)|(may)|(jun)|(jul)|(aug)|(sep)|(oct)|(nov)|(dec)', 3)), 2)
EndFunc   ;==>MonthToNumberRE

Func MonthToNumberA($s)
    Local $aMonths[13] = ["", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
    For $i = 1 To UBound($aMonths) - 1
        If StringInStr($aMonths[$i], $s) Then Return StringRight("0" & $i, 2)
    Next
    Return 0
EndFunc   ;==>MonthToNumberA
Link to comment
Share on other sites

Malkey, that it is a very cool method. I like it.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

It was seeing the two methods 'side by side' that made it 'educational' for me. I have gotten fairly good now with array's, and since I was able to easily dissect that snippet and see it 'piece by piece', it made the RE snippet 'come to life' and understandable to me. That other thread is good too. Thanks again :graduated:

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

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