Jump to content
Macro Express Forums

*urgent* Calculating Dates


danibecr
 Share

Recommended Posts

O.k. So I'm trying to figure out some kind of logic to add the correct dates maybe something a little like this

 

 

 

Set N1 from current date (but it only comes in a 2 digit # 02/10/2007 = 10)

Set N2 from prompt (for testing N2 will come from service order date in future)

Modify N3 = N1-N2 (02/10/2007 - 02 10 07 = -15) If reversed = 5

 

Maybe if I put the current month in N1 and the current date in N2 and had the month and date off the service order as N3 and N4, but then theres the problem of setting the addition and subtraction into another variable and I think that would get sticky. ANY HELP or IDEAS would be GREATLY apprecitated and at least tried. I'm kinda at a stand still on this. Thanks in advance.

Link to comment
Share on other sites

Macro Express does not have the ability to do date calculations, at least not built-in date calculations.

 

There are, however, solutions to your problem. Randall has already posted one of his.

 

Here is another possibility. Date Functions. It is a link to our add-on PGM Functions Library for Macro Express 3. The link shows a list of included date calculation functions and a short description of each.

 

Another solution would be similar to Randall's in that a simple VBScript program is written out to a file by Macro Express, run, and the the results read back in to Macro Express.

Link to comment
Share on other sites

I'd be surprised if there isn't such a macro already available somewhere, as it seems a common business requirement. But I can't find one so I've written one. Primarily as a training exercise for myself, as I've only recently started doing any serious work with ME. But I've tested this fairly thoroughly and it should do the job.

 

Of course, it makes some assumptions, but you should be able to make any necessary amendments as I've commented it heavily.

 

COMMANDS

// Finds number of days between today and a past order date.

// Enters details in appropriate one of 3 specified text files

// (Don't forget to save files regularly, unless you amend the macro to do so.)

// Uses USA date format mm/dd/yy

// Assumes no orders are dated before 1st Jan 2006; easily amended if that's not the case

 

// Automatically get current date into T1

Date/Time: Save "mm/dd/yy" into %T1%

// Automatically extract current day, month , year

Variable Set Integer %N1% from Current Month

Variable Set Integer %N2% from Current Day

Variable Set Integer %N3% from Current Year

// Manually set past date into T2

Date/Time: Save "mm/dd/yy" into %T2%

// Macro section to extract past day, month , year

// Copy first 2 chars of T2, month, to T10

Variable Modify String: Copy Part of %T2% to %T10%

// Copy chars 4-5 of T2, day, to T11

Variable Modify String: Copy Part of %T2% to %T11%

// Copy chars 7-8 of T2, year, to T12

Variable Modify String: Copy Part of %T2% to %T12%

// Convert strings to integers

Variable Modify String: Convert %T10% to integer %N10%

Variable Modify String: Convert %T11% to integer %N11%

Variable Modify String: Convert %T12% to integer %N12%

// Add 2000 to year for consistency

Variable Modify Integer: %N12% = 2000 + %N12%

// Calculate Past date from 1/1/06 = N51

If Variable %N10% = 1

Variable Modify Integer: %N51% = %N11% + 0

End If

If Variable %N10% = 2

Variable Modify Integer: %N51% = %N11% + 31

End If

If Variable %N10% = 3

Variable Modify Integer: %N51% = %N11% + 61

End If

If Variable %N10% = 4

Variable Modify Integer: %N51% = %N11% + 92

End If

If Variable %N10% = 5

Variable Modify Integer: %N51% = %N11% + 122

End If

If Variable %N10% = 6

Variable Modify Integer: %N51% = %N11% + 153

End If

If Variable %N10% = 7

Variable Modify Integer: %N51% = %N11% + 183

End If

If Variable %N10% = 8

Variable Modify Integer: %N51% = %N11% + 214

End If

If Variable %N10% = 9

Variable Modify Integer: %N51% = %N11% + 245

End If

If Variable %N10% = 10

Variable Modify Integer: %N51% = %N11% + 275

End If

If Variable %N10% = 11

Variable Modify Integer: %N51% = %N11% + 306

End If

If Variable %N10% = 12

Variable Modify Integer: %N51% = %N11% + 336

End If

// Add days for any previous full years

Variable Modify Integer: %N12% = %N12% - 2006

Variable Modify Integer: %N57% = %N12% * 365

Variable Modify Integer: %N51% = %N51% + %N57%

// Calculate Current date from 1/1/06 = N50

If Variable %N1% = 1

Variable Modify Integer: %N50% = %N2% + 0

End If

If Variable %N1% = 2

Variable Modify Integer: %N50% = %N2% + 31

End If

If Variable %N1% = 3

Variable Modify Integer: %N50% = %N2% + 61

End If

If Variable %N1% = 4

Variable Modify Integer: %N50% = %N2% + 92

End If

If Variable %N1% = 5

Variable Modify Integer: %N50% = %N2% + 122

End If

If Variable %N1% = 6

Variable Modify Integer: %N50% = %N2% + 153

End If

If Variable %N1% = 7

Variable Modify Integer: %N50% = %N2% + 183

End If

If Variable %N1% = 8

Variable Modify Integer: %N50% = %N2% + 214

End If

If Variable %N1% = 9

Variable Modify Integer: %N50% = %N2% + 245

End If

If Variable %N1% = 10

Variable Modify Integer: %N50% = %N2% + 275

End If

If Variable %N1% = 11

Variable Modify Integer: %N50% = %N2% + 306

End If

If Variable %N1% = 12

Variable Modify Integer: %N50% = %N2% + 336

End If

// Add days for any previous full years

Variable Modify Integer: %N3% = %N3% - 2006

Variable Modify Integer: %N57% = %N3% * 365

Variable Modify Integer: %N50% = %N50% + %N57%

// Calculate difference in days

Variable Modify Integer: %N99% = %N50% - %N51%

Text Box Display: Status

// Test if 93 or more days overdue

If Variable %N99% >= 93

Text Box Display: Status

// Go to fresh line in text file and enter the appropriate details

Activate or Launch: "Overdue93" OR "Notepad.exe"

Text Type: <CTRLD><END><CTRLU>

Text Type: Service Order Date = %T2%, which is %N99% days old<ENTER>

Macro Stop

End If

// Test if 62 or more days overdue

If Variable %N99% >= 62

Text Box Display: Status

// Go to fresh line in text file and enter the appropriate details

Activate or Launch: "Overdue62" OR "Notepad.exe"

Text Type: <CTRLD><END><CTRLU>

Text Type: Service Order Date = %T2%, which is %N99% days old<ENTER>

Macro Stop

End If

// Test if 31 or more days overdue

If Variable %N99% >= 31

Text Box Display: Status

// Go to fresh line in text file and enter the appropriate details

Activate or Launch: "Overdue31" OR "Notepad.exe"

Text Type: <CTRLD><END><CTRLU>

Text Type: Service Order Date = %T2%, which is %N99% days old<ENTER>

Macro Stop

End If

Text Box Display: Status

Macro Stop

 

You could paste it in from the following:

 

CODE

<REM2:Finds number of days between today and a past order date.><REM2:Enters details in appropriate one of 3 specified text files><REM2:(Don't forget to save files regularly, unless you amend the macro to do so.)><REM2:Uses USA date format mm/dd/yy><REM2:Assumes no orders are dated before 1st Jan 2006; easily amended if that's not the case><REM2:><REM2:Automatically get current date into T1><DT:mm/dd/yyT:01:1:><REM2:Automatically extract current day, month , year><IVAR2:01:17:><IVAR2:02:16:><IVAR2:03:18:><REM2:Manually set past date into T2><DT:mm/dd/yyT:02:4:CenterCenterEnter past order dateTF><REM2:Macro section to extract past day, month , year><REM2:Copy first 2 chars of T2, month, to T10><TMVAR2:10:10:02:001:002:><REM2:Copy chars 4-5 of T2, day, to T11><TMVAR2:10:11:02:004:002:><REM2:Copy chars 7-8 of T2, year, to T12><TMVAR2:10:12:02:007:002:><REM2:Convert strings to integers><TMVAR2:05:10:10:000:000:><TMVAR2:05:11:11:000:000:><TMVAR2:05:12:12:000:000:><REM2:Add 2000 to year for consistency><NMVAR:01:12:2:0002000:1:0000012><REM2:Calculate Past date from 1/1/06 = N51><IFVAR2:2:10:1:1><NMVAR:01:51:1:0000011:2:0000000><ENDIF><IFVAR2:2:10:1:2><NMVAR:01:51:1:0000011:2:0000031><ENDIF><IFVAR2:2:10:1:3><NMVAR:01:51:1:0000011:2:0000061><ENDIF><IFVAR2:2:10:1:4><NMVAR:01:51:1:0000011:2:0000092><ENDIF><IFVAR2:2:10:1:5><NMVAR:01:51:1:0000011:2:0000122><ENDIF><IFVAR2:2:10:1:6><NMVAR:01:51:1:0000011:2:0000153><ENDIF><IFVAR2:2:10:1:7><NMVAR:01:51:1:0000011:2:0000183><ENDIF><IFVAR2:2:10:1:8><NMVAR:01:51:1:0000011:2:0000214><ENDIF><IFVAR2:2:10:1:9><NMVAR:01:51:1:0000011:2:0000245><ENDIF><IFVAR2:2:10:1:10><NMVAR:01:51:1:0000011:2:0000275><ENDIF><IFVAR2:2:10:1:11><NMVAR:01:51:1:0000011:2:0000306><ENDIF><IFVAR2:2:10:1:12><NMVAR:01:51:1:0000011:2:0000336><ENDIF><REM2:Add days for any previous full years><NMVAR:02:12:1:0000012:2:0002006><NMVAR:03:57:1:0000012:2:0000365><NMVAR:01:51:1:0000051:1:0000057><REM2:Calculate Current date from 1/1/06 = N50><IFVAR2:2:01:1:1><NMVAR:01:50:1:0000002:2:0000000><ENDIF><IFVAR2:2:01:1:2><NMVAR:01:50:1:0000002:2:0000031><ENDIF><IFVAR2:2:01:1:3><NMVAR:01:50:1:0000002:2:0000061><ENDIF><IFVAR2:2:01:1:4><NMVAR:01:50:1:0000002:2:0000092><ENDIF><IFVAR2:2:01:1:5><NMVAR:01:50:1:0000002:2:0000122><ENDIF><IFVAR2:2:01:1:6><NMVAR:01:50:1:0000002:2:0000153><ENDIF><IFVAR2:2:01:1:7><NMVAR:01:50:1:0000002:2:0000183><ENDIF><IFVAR2:2:01:1:8><NMVAR:01:50:1:0000002:2:0000214><ENDIF><IFVAR2:2:01:1:9><NMVAR:01:50:1:0000002:2:0000245><ENDIF><IFVAR2:2:01:1:10><NMVAR:01:50:1:0000002:2:0000275><ENDIF><IFVAR2:2:01:1:11><NMVAR:01:50:1:0000002:2:0000306><ENDIF><IFVAR2:2:01:1:12><NMVAR:01:50:1:0000002:2:0000336><ENDIF><REM2:Add days for any previous full years><NMVAR:02:03:1:0000003:2:0002006><NMVAR:03:57:1:0000003:2:0000365><NMVAR:01:50:1:0000050:1:0000057><REM2:Calculate difference in days><NMVAR:02:99:1:0000050:1:0000051><DIS:<TBOX4:T:4:CenterCenter000278000200:000:StatusN99 = Days difference = %N99%><REM2:Test if 93 or more days overdue><IFVAR2:2:99:5:93><TBOX4:T:4:CenterCenter000278000200:000:StatusThis is 93 or more days old, so details will be entered into the file Overdue93.txt><REM2:Go to fresh line in text file and enter the appropriate details><LAUNCHYES3:0:0112Overdue93<LAUNCH:C:\Windows\Notepad.exe<PARAM>D:\Docs\SUNDRY\Overdue93.txt><TEXTTYPE:<CTRLD><END><CTRLU>><TEXTTYPE:Service Order Date = %T2%, which is %N99% days old<ENTER>><MSTOP><ENDIF><REM2:Test if 62 or more days overdue><IFVAR2:2:99:5:62><TBOX4:T:4:CenterCenter000278000200:000:StatusThis is 62 or more days old, so details will be entered into the file Overdue62.txt><REM2:Go to fresh line in text file and enter the appropriate details><LAUNCHYES3:0:0112Overdue62<LAUNCH:C:\Windows\Notepad.exe<PARAM>D:\Docs\SUNDRY\Overdue62.txt><TEXTTYPE:<CTRLD><END><CTRLU>><TEXTTYPE:Service Order Date = %T2%, which is %N99% days old<ENTER>><MSTOP><ENDIF><REM2:Test if 31 or more days overdue><IFVAR2:2:99:5:31><TBOX4:T:4:CenterCenter000278000200:000:StatusThis is 31 or more days old, so details will be entered into the file Overdue31.txt><REM2:Go to fresh line in text file and enter the appropriate details><LAUNCHYES3:0:0112Overdue31<LAUNCH:C:\Windows\Notepad.exe<PARAM>D:\Docs\SUNDRY\Overdue31.txt><TEXTTYPE:<CTRLD><END><CTRLU>><TEXTTYPE:Service Order Date = %T2%, which is %N99% days old<ENTER>><MSTOP><ENDIF><TBOX4:T:4:CenterCenter000278000200:000:StatusN99 = %N99%

This is less than 31 days old, so no details will be entered.><MSTOP>

 

Make 3 blank Notepad files before you run it: Overdue31.txt, Overdue62.txt and Overdue93.txt. Or amend to use whatever files you already have - you didn't provide any details. Or use clipboard for transfer instead.

 

Experts:

This is the first time I've used any of ME's Logical commands, so it's pretty crude. I'm sure there's a more elegant way of implementing all those If loops, and I'd appreciate suggestions.

 

 

--

Terry, West Sussex, UK

Link to comment
Share on other sites

Hey ya'll. Here I am again. I'm going through and doing some testing with the systems and I got another problem I may need help with. (Using the script below for testing) After I bring up the new service order I'v got it to where it will get the correct dates into the right variables i.e. 02 14 07 02 into N10 14 into N11 and 07 into N12. But after the calculations I can't seem to get it to append to a .txt file. Before I started incorporating the other stuff into the macro date calculation it worked fine. I don't see that I changed any variables just added a few more. Here's what I have: The basics of what I'm trying for are.

 

Pull new service order from access DB. Bring up CIS (program) and service order.

Then if it is X or C with T3 (SO#) log it as xxxx (<--Works)

 

If it's I with T3 and OPN 1 and J TAKEN BY do date calculation, append to correct .txt and repeat (<-- Doesn't work)

 

If it's I with T3 and REPO and J TAKEN BY do date calculation, append to correct .txt and repeat (<-- Doesn't work)

 

If it's I with T3 and KLOS and J TAKEN BY do date calculation, append to correct .txt and repeat (<-- Doesn't work)

 

If none of conditions exist I'm wanting it to log xxxxx. (<-- Works Kinda, I think it repeats just that one section @ end)

 

Repeat Start (Repeat 1000 times)

If Window Title "Oops..." is on top

Activate Window: "Oops..."

Text Type: <ENTER>

Wait Text Playback

Text Type: <ALTD>l<ALTU>

Wait Text Playback

Text Type: <ENTER><ENTER>

End If

Activate Window: "Work Assignment Database"

Text Type: <SHIFTD><SPACE><SPACE><SHIFTU><TAB>

Wait Text Playback

Clipboard Copy

Variable Set String %T3% from Prompt

Wait Text Playback

Activate Window: "TXUMDC"

Wait Text Playback

Text Type: <F12>

Wait Text Playback

Clipboard Paste

Text Type: <ENTER>

Wait Text Playback

Wait Time Elapse: 0 Minutes 1 Seconds

Text Type: <ALTD>e

Wait Text Playback

Text Type: y<ALTU>

Wait Text Playback

If Clipboard Contains "R E M I - PERMANENT CUSTOMER ACCOUNT REMARKS INQUIRY"

Text Type: <ENTER>

Wait Text Playback

End If

Text Type: <ALTD>e

Wait Text Playback

Text Type: y<ALTU>

Variable Set String %T2% from Clipboard

Wait Text Playback

If Clipboard Contains "%T3%"

If Clipboard Contains "STAT C HOLD RSN"

OR

If Clipboard Contains "STAT X HOLD RSN"

Activate Window: "Work Assignment Database"

Text Type: <ALTD>f<ALTU>a<ALTD>c<ALTU><ENTER>

Wait Text Playback

Else

If Clipboard Contains "STAT I HOLD RSN"

AND

If Clipboard Contains "R E P O -"

AND

If Clipboard Contains "J TAKEN BY"

Variable Modify String: Save %T2% to Clipboard

Pause: Basic

Variable Modify String: Copy Part of %T2% to %T10%

Variable Modify String: Copy Part of %T2% to %T11%

Variable Modify String: Copy Part of %T2% to %T12%

Variable Modify String: Convert %T10% to integer %N10%

Variable Modify String: Convert %T11% to integer %N11%

Variable Modify String: Convert %T12% to integer %N12%

Variable Modify String: Convert %T10% to integer %N10%

Variable Modify String: Convert %T11% to integer %N11%

Variable Modify String: Convert %T12% to integer %N12%

Variable Modify Integer: %N12% = 2000 + %N12%

If Variable %N10% = 1

Variable Modify Integer: %N51% = %N11% + 0

End If

If Variable %N10% = 2

Variable Modify Integer: %N51% = %N11% + 31

End If

If Variable %N10% = 3

Variable Modify Integer: %N51% = %N11% + 61

End If

If Variable %N10% = 4

Variable Modify Integer: %N51% = %N11% + 92

End If

If Variable %N10% = 5

Variable Modify Integer: %N51% = %N11% + 122

End If

If Variable %N10% = 6

Variable Modify Integer: %N51% = %N11% + 153

End If

If Variable %N10% = 7

Variable Modify Integer: %N51% = %N11% + 183

End If

If Variable %N10% = 8

Variable Modify Integer: %N51% = %N11% + 214

End If

If Variable %N10% = 9

Variable Modify Integer: %N51% = %N11% + 245

End If

If Variable %N10% = 10

Variable Modify Integer: %N51% = %N11% + 275

End If

If Variable %N10% = 11

Variable Modify Integer: %N51% = %N11% + 306

End If

If Variable %N10% = 12

Variable Modify Integer: %N51% = %N11% + 336

End If

Variable Modify Integer: %N12% = %N12% - 2006

Variable Modify Integer: %N57% = %N12% * 365

Variable Modify Integer: %N51% = %N51% + %N57%

If Variable %N1% = 1

Variable Modify Integer: %N50% = %N2% + 0

End If

If Variable %N1% = 2

Variable Modify Integer: %N50% = %N2% + 31

End If

If Variable %N1% = 3

Variable Modify Integer: %N50% = %N2% + 61

End If

If Variable %N1% = 4

Variable Modify Integer: %N50% = %N2% + 92

End If

If Variable %N1% = 5

Variable Modify Integer: %N50% = %N2% + 122

End If

If Variable %N1% = 6

Variable Modify Integer: %N50% = %N2% + 153

End If

If Variable %N1% = 7

Variable Modify Integer: %N50% = %N2% + 183

End If

If Variable %N1% = 8

Variable Modify Integer: %N50% = %N2% + 214

End If

If Variable %N1% = 9

Variable Modify Integer: %N50% = %N2% + 245

End If

If Variable %N1% = 10

Variable Modify Integer: %N50% = %N2% + 275

End If

If Variable %N1% = 11

Variable Modify Integer: %N50% = %N2% + 306

End If

If Variable %N1% = 12

Variable Modify Integer: %N50% = %N2% + 336

End If

Variable Modify Integer: %N3% = %N3% - 2006

Variable Modify Integer: %N57% = %N3% * 365

Variable Modify Integer: %N50% = %N50% + %N57%

Variable Modify Integer: %N99% = %N50% - %N51%

If Variable %N99% >= 93

Variable Modify String: Save %T3% to Clipboard

Clipboard Append Text: "Overdue 93.txt"

End If

If Variable %N99% >= 62

Variable Modify String: Save %T3% to Clipboard

Clipboard Append Text: "Overdue 62.txt"

End If

If Variable %N99% >= 31

Variable Modify String: Save %T3% to Clipboard

Clipboard Append Text: "Overdue 31.txt"

End If

End If

If Clipboard Contains "STAT I HOLD RSN"

AND

If Clipboard Contains "O P N 1 -"

AND

If Clipboard Contains "J TAKEN BY"

Variable Modify String: Save %T2% to Clipboard

Variable Modify String: Copy Part of %T2% to %T10%

Variable Modify String: Copy Part of %T2% to %T11%

Variable Modify String: Copy Part of %T2% to %T12%

Variable Modify String: Convert %T10% to integer %N10%

Variable Modify String: Convert %T11% to integer %N11%

Variable Modify String: Convert %T12% to integer %N12%

Variable Modify String: Convert %T10% to integer %N10%

Variable Modify String: Convert %T11% to integer %N11%

Variable Modify String: Convert %T12% to integer %N12%

Variable Modify Integer: %N12% = 2000 + %N12%

If Variable %N10% = 1

Variable Modify Integer: %N51% = %N11% + 0

End If

If Variable %N10% = 2

Variable Modify Integer: %N51% = %N11% + 31

End If

If Variable %N10% = 3

Variable Modify Integer: %N51% = %N11% + 61

End If

If Variable %N10% = 4

Variable Modify Integer: %N51% = %N11% + 92

End If

If Variable %N10% = 5

Variable Modify Integer: %N51% = %N11% + 122

End If

If Variable %N10% = 6

Variable Modify Integer: %N51% = %N11% + 153

End If

If Variable %N10% = 7

Variable Modify Integer: %N51% = %N11% + 183

End If

If Variable %N10% = 8

Variable Modify Integer: %N51% = %N11% + 214

End If

If Variable %N10% = 9

Variable Modify Integer: %N51% = %N11% + 245

End If

If Variable %N10% = 10

Variable Modify Integer: %N51% = %N11% + 275

End If

If Variable %N10% = 11

Variable Modify Integer: %N51% = %N11% + 306

End If

If Variable %N10% = 12

Variable Modify Integer: %N51% = %N11% + 336

End If

Variable Modify Integer: %N12% = %N12% - 2006

Variable Modify Integer: %N57% = %N12% * 365

Variable Modify Integer: %N51% = %N51% + %N57%

If Variable %N1% = 1

Variable Modify Integer: %N50% = %N2% + 0

End If

If Variable %N1% = 2

Variable Modify Integer: %N50% = %N2% + 31

End If

If Variable %N1% = 3

Variable Modify Integer: %N50% = %N2% + 61

End If

If Variable %N1% = 4

Variable Modify Integer: %N50% = %N2% + 92

End If

If Variable %N1% = 5

Variable Modify Integer: %N50% = %N2% + 122

End If

If Variable %N1% = 6

Variable Modify Integer: %N50% = %N2% + 153

End If

If Variable %N1% = 7

Variable Modify Integer: %N50% = %N2% + 183

End If

If Variable %N1% = 8

Variable Modify Integer: %N50% = %N2% + 214

End If

If Variable %N1% = 9

Variable Modify Integer: %N50% = %N2% + 245

End If

If Variable %N1% = 10

Variable Modify Integer: %N50% = %N2% + 275

End If

If Variable %N1% = 11

Variable Modify Integer: %N50% = %N2% + 306

End If

If Variable %N1% = 12

Variable Modify Integer: %N50% = %N2% + 336

End If

Variable Modify Integer: %N3% = %N3% - 2006

Variable Modify Integer: %N57% = %N3% * 365

Variable Modify Integer: %N50% = %N50% + %N57%

Variable Modify Integer: %N99% = %N50% - %N51%

If Variable %N99% >= 93

Variable Modify String: Save %T3% to Clipboard

Clipboard Append Text: "Overdue 93.txt"

Wait Text Playback

End If

If Variable %N99% >= 62

Variable Modify String: Save %T3% to Clipboard

Clipboard Append Text: "Overdue 62.txt"

Wait Text Playback

End If

If Variable %N99% >= 31

Variable Modify String: Save %T3% to Clipboard

Clipboard Append Text: "Overdue 31.txt"

Wait Text Playback

End If

Pause: Basic

End If

If Clipboard Contains "STAT I HOLD RSN"

AND

If Clipboard Contains "K L O S -"

AND

If Clipboard Contains "J TAKEN BY"

Variable Modify String: Save %T2% to Clipboard

Pause: Basic

Variable Modify String: Copy Part of %T2% to %T10%

Variable Modify String: Copy Part of %T2% to %T11%

Variable Modify String: Copy Part of %T2% to %T12%

Variable Modify String: Convert %T10% to integer %N10%

Variable Modify String: Convert %T11% to integer %N11%

Variable Modify String: Convert %T12% to integer %N12%

Variable Modify String: Convert %T10% to integer %N10%

Variable Modify String: Convert %T11% to integer %N11%

Variable Modify String: Convert %T12% to integer %N12%

Variable Modify Integer: %N12% = 2000 + %N12%

If Variable %N10% = 1

Variable Modify Integer: %N51% = %N11% + 0

End If

If Variable %N10% = 2

Variable Modify Integer: %N51% = %N11% + 31

End If

If Variable %N10% = 3

Variable Modify Integer: %N51% = %N11% + 61

End If

If Variable %N10% = 4

Variable Modify Integer: %N51% = %N11% + 92

End If

If Variable %N10% = 5

Variable Modify Integer: %N51% = %N11% + 122

End If

If Variable %N10% = 6

Variable Modify Integer: %N51% = %N11% + 153

End If

If Variable %N10% = 7

Variable Modify Integer: %N51% = %N11% + 183

End If

If Variable %N10% = 8

Variable Modify Integer: %N51% = %N11% + 214

End If

If Variable %N10% = 9

Variable Modify Integer: %N51% = %N11% + 245

End If

If Variable %N10% = 10

Variable Modify Integer: %N51% = %N11% + 275

End If

If Variable %N10% = 11

Variable Modify Integer: %N51% = %N11% + 306

End If

If Variable %N10% = 12

Variable Modify Integer: %N51% = %N11% + 336

End If

Variable Modify Integer: %N12% = %N12% - 2006

Variable Modify Integer: %N57% = %N12% * 365

Variable Modify Integer: %N51% = %N51% + %N57%

If Variable %N1% = 1

Variable Modify Integer: %N50% = %N2% + 0

End If

If Variable %N1% = 2

Variable Modify Integer: %N50% = %N2% + 31

End If

If Variable %N1% = 3

Variable Modify Integer: %N50% = %N2% + 61

End If

If Variable %N1% = 4

Variable Modify Integer: %N50% = %N2% + 92

End If

If Variable %N1% = 5

Variable Modify Integer: %N50% = %N2% + 122

End If

If Variable %N1% = 6

Variable Modify Integer: %N50% = %N2% + 153

End If

If Variable %N1% = 7

Variable Modify Integer: %N50% = %N2% + 183

End If

If Variable %N1% = 8

Variable Modify Integer: %N50% = %N2% + 214

End If

If Variable %N1% = 9

Variable Modify Integer: %N50% = %N2% + 245

End If

If Variable %N1% = 10

Variable Modify Integer: %N50% = %N2% + 275

End If

If Variable %N1% = 11

Variable Modify Integer: %N50% = %N2% + 306

End If

If Variable %N1% = 12

Variable Modify Integer: %N50% = %N2% + 336

End If

Variable Modify Integer: %N3% = %N3% - 2006

Variable Modify Integer: %N57% = %N3% * 365

Variable Modify Integer: %N50% = %N50% + %N57%

Variable Modify Integer: %N99% = %N50% - %N51%

If Variable %N99% >= 93

Variable Modify String: Save %T3% to Clipboard

Clipboard Append Text: "Overdue 93.txt"

End If

If Variable %N99% >= 62

Variable Modify String: Save %T3% to Clipboard

Clipboard Append Text: "Overdue 62.txt"

End If

If Variable %N99% >= 31

Variable Modify String: Save %T3% to Clipboard

Clipboard Append Text: "Overdue 31.txt"

End If

Activate Window: "Work Assignment Database"

Text Type: <ALTD>f<ALTU>mo

Wait Text Playback

Text Type: <ALTD>C<ALTU><ENTER>

Wait Text Playback

End If

End If

Activate Window: "Work Assignment Database"

Text Type: <ALTD>f<ALTU>F

Wait Text Playback

Text Type: <ALTD>C<ALTU><ENTER>

Wait Text Playback

End If

Repeat End

Link to comment
Share on other sites

Sorry for being such a pest...lol. Well, I'v decided to attack this in several different ways at once. While I'm still working with the macro above I have also broken it down into a couple of smaller ones. I have the main macro getting and logging service orders into the Access DB. And I put the date calculation macro seperate. Since the dates are in different places on different types of orders I have 3 calculation macros. And when the criteria are met it goes to that paricular macro to calculate date. But here's the swinger.... it ALWAYS comes back to saying the service order is 2600 days old. Regardless of the SO date...01/01/07 or 11/15/06. I went back through and checked the variables and they seem fine. I don't know. Oh- BTW I work for a Utility company and we're having to manually one-by-one search 200,000 + orders daily so this is needed to speed up the process.

 

Repeat Start (Repeat 1000 times)

If Window Title "Oops..." is on top

Activate Window: "Oops..."

Text Type: <ENTER>

Wait Text Playback

Text Type: <ALTD>l<ALTU>

Wait Text Playback

Text Type: <ENTER><ENTER>

End If

Activate Window: "Work Assignment Database"

Text Type: <SHIFTD><SPACE><SPACE><SHIFTU><TAB>

Wait Text Playback

Clipboard Copy

Variable Set String %T3% from Clipboard

Wait Text Playback

Activate Window: "TXUMDC"

Wait Text Playback

Text Type: <F12>

Wait Text Playback

Clipboard Paste

Text Type: <ENTER>

Wait Text Playback

Wait Time Elapse: 0 Minutes 1 Seconds

Text Type: <ALTD>e

Wait Text Playback

Text Type: y<ALTU>

Wait Text Playback

If Clipboard Contains "R E M I - PERMANENT CUSTOMER ACCOUNT REMARKS INQUIRY"

Text Type: <ENTER>

Wait Text Playback

End If

Text Type: <ALTD>e

Wait Text Playback

Text Type: y<ALTU>

Variable Set String %T2% from Clipboard

Wait Text Playback

If Clipboard Contains "%T3%"

If Clipboard Contains "STAT C HOLD RSN"

OR

If Clipboard Contains "STAT X HOLD RSN"

Activate Window: "Work Assignment Database"

Text Type: <ALTD>f<ALTU>a<ALTD>c<ALTU><ENTER>

Wait Text Playback

End If

If Clipboard Contains "STAT I HOLD RSN"

AND

If Clipboard Contains "R E P O -"

AND

If Clipboard Contains "J TAKEN BY"

Macro Run: Find Age of SO REPO

End If

If Clipboard Contains "STAT I HOLD RSN"

AND

If Clipboard Contains "O P N 1 -"

AND

If Clipboard Contains "J TAKEN BY"

Macro Run: Find Age of SO OPN1

End If

If Clipboard Contains "STAT I HOLD RSN"

AND

If Clipboard Contains "K L O S -"

AND

If Clipboard Contains "J TAKEN BY"

Macro Run: Find Age of SO KLOS

End If

Activate Window: "Work Assignment Database"

Text Type: <ALTD>f<ALTU>mo

Wait Text Playback

Text Type: <ALTD>c<ALTU><ENTER>

Wait Text Playback

Else

Activate Window: "Work Assignment Database"

Text Type: <ALTD>f<ALTU>f

Wait Text Playback

Text Type: <ALTD>c<ALTU><ENTER>

Wait Text Playback

End If

Repeat End

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...