Can I link date to a "period" number and have it a

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Brett
Newbie
Posts: 5
Joined: Tue Sep 18, 2007 7:38 pm

Can I link date to a "period" number and have it a

Post by Brett » Wed Jan 23, 2008 8:54 pm

Here's my scenario:
We run a report on the first business day of the month. We have to go into the application and set some variables and then click "RUN"

There are two variables I have a problem with:

YEAR: There is a field where I have to enter a year as 2008 for example. How can I tell the script to look at whatever the current year and insert it into field?

DATE -> PERIOD: This one is harder. We start the fiscal year in July. Each month is a "period" so July is 1, August is 2, etc... up to the 12th period which is June.

How do I tell the script to match the months to those period numbers? and then I need to insert the PREVIOUS MONTH's period number into the report field....

so for example, January is period 7 so on February 1st the script needs to insert the number 7 into the field

I hope this makes sense - and someone can help!!!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Jan 23, 2008 9:08 pm

To get the current year use the, er, Year command:

Year>theYear

Then you can send it to the field with:

Send>theYear

To convert a month to a period, first use the Month command to get the current month number. Then we need to translate it. All we need is a simple calculation:

Code: Select all

Month>mm

If>mm>6
  Let>period=mm-6
Else
  Let>period=mm+6
Endif
To determine the previous month number do:

Code: Select all

Month>mm
Let>mm=mm-1
If>mm=0
  Let>mm=12
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Brett
Newbie
Posts: 5
Joined: Tue Sep 18, 2007 7:38 pm

Post by Brett » Wed Jan 23, 2008 9:30 pm

Thanks Marcus,

I understand the year variable now but have another question about the month variable.

I'm not totally user I understand the month variable (the +/- 6 part) but no worries, we'll roll with it :wink:

When I get to the part of the script where I actually want to insert the period value, would I use this piece of the script there?

Code: Select all

Month>mm
Let>mm=mm-1
If>mm=0
Let>mm=12
Endif
Or would I include that with the +/- 6 piece at the top of the script?

If the latter, what "SEND" command do I use to insert the period's value?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Jan 23, 2008 9:44 pm

Brett wrote: When I get to the part of the script where I actually want to insert the period value, would I use this piece of the script there?

Code: Select all

Month>mm
Let>mm=mm-1
If>mm=0
Let>mm=12
Endif
Or would I include that with the +/- 6 piece at the top of the script?

If the latter, what "SEND" command do I use to insert the period's value?
Please read my last post again carefully. The bit you quote above is the bit that determines what LAST month was. When you want to do that you need to do it before calculating the period. Do it IN PLACE of Month>mm in my first snippet.

Yes, when you want to send the final result, use the Send command

And indeed you would want to send the calculated period value:

Send>period
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Brett
Newbie
Posts: 5
Joined: Tue Sep 18, 2007 7:38 pm

Post by Brett » Wed Jan 23, 2008 9:47 pm

Aha, I think I understand now - seeing them backwards confused me.

Thanks again!

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Wed Jan 23, 2008 9:51 pm

And remember to SetFocus>Windowname* before using Send commands.

May only need to be done once at beginning, it depends on what other things are happening that might open other windows.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts