Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Having trouble with a conditional statement



  • Please log in to reply
4 replies to this topic
Iredditfromwork
  • Members
  • 145 posts
  • Last active: Oct 14 2014 12:36 AM
  • Joined: 11 Jul 2013

Hi! I'm brand new to the forum, and am very new to programming with AHK. I've taken a few classes that ranged from C++ to HTML over the years, and feel like I have a fairly rudimentary understanding of general syntax and the ability to flesh out, as least basic, programming laguanges.

 

I've been creating all sorts of simple scripts to make my job easier and improve my workflow, but have hit a wall with this one.

 

A part of my job is to tag things that I'm working on to be checked the next day, and that was easy to flesh out. However, when Friday rolls around, I'd like the tag to jump to Monday.

 

For my Mon-Thurs tag I've got:

 

 

var1 =  ; Make it blank so that the below will use the current time instead.
var1 += 1, days ; adds a day to the YYYYMMDDHH24MISS time for right now
FormatTime, TimeString, %var1%, M/dd
 

 

Where calling %TimeString% gives me the next day.

 

Here's where I'm having trouble with the syntax. On Friday, I want it to add two more days to TimeString. I tried adding another 'FormatTime' command that calls 'DayString, , ddd', and adding an if statement that checks for 'Fri'. However, it's not working. I've tried a bunch of different variations of this, and can't get it to recognize the command.

 

Here's my most recent failed attempt:

 

 

FormatTime, DayString, , ddd

var1 =  ; Make it blank so that the below will use the current time instead.
var1 += 1, days ; adds a day to the YYYYMMDDHH24MISS time for right now


FormatTime, TimeString, %var1%, MM/dd

FormatTime, DayString, , ddd

If DayString = Fri
    Var1 += 2

send, %TimeString%
sleep, 10
send, {enter}
sleep, 10
send, %DayString%
sleep, 10
send, {enter}
sleep, 10
send, %var1%

 

 

Any guru's that can help me make this work?

 

Thank you for your time!!



Alpha Bravo
  • Members
  • 1687 posts
  • Last active: Nov 07 2015 03:06 PM
  • Joined: 01 Sep 2011
✓  Best Answer
var1 =  					; Make it blank so that the below will use the current time instead.
var1 += 1, days 				; adds a day to the YYYYMMDDHH24MISS time for right now
FormatTime, DayString, , ddd
If DayString = Fri
    Var1 += 2, Days
FormatTime, TimeString, %var1%, MM/dd
FormatTime, DayString, %var1%, ddd
MsgBox % TimeString "`n" DayString  "`n"  var1


Iredditfromwork
  • Members
  • 145 posts
  • Last active: Oct 14 2014 12:36 AM
  • Joined: 11 Jul 2013

So does the if needs to follow the command immediately then? That looks like the primary difference between what you provided, and what I was doing before. I'm not sure why I didn't think of that.
 

 

Thank you very much!!!



Alpha Bravo
  • Members
  • 1687 posts
  • Last active: Nov 07 2015 03:06 PM
  • Joined: 01 Sep 2011

So does the if needs to follow the command immediately then? 

Nop,

you forgot to add the time unit in

If DayString = Fri
    Var1 += 2, Days    ; time unit here

and you needed to reformat DayString & TimeString after you added 2 days in case it was Friday.



Iredditfromwork
  • Members
  • 145 posts
  • Last active: Oct 14 2014 12:36 AM
  • Joined: 11 Jul 2013

yea, i figured it'd be something simple.

 

thank you again!!