Jump to content
Macro Express Forums

Calculating / subtracting time


Recommended Posts

I really thought i would know how it works but i struggle. I also guess MEX Pro did get some new commands regard time operations.

 

What i want is simple. Actually i want the macro to know when it was run the last time and do something additional via "If then... - command" when it was longer ago than 3 minutes.

 

As i could not find a function like "Set date/time variable to macro last run" i defined two date/time variables. One %TimeNow% for the current time and one saved each time the macro is run named %TimeLastrun%.

 

I thought %TimeNow% minus %TimeLastrun% would be the time elapsed since the last time the macro was run. But instead i only get the current time. Any ideas?

 

Thank You

Alexandra

Link to comment
Share on other sites

If the result is today and assuming you are setting the time now then your other time is probably zero date. Time in most computers is a decimal, each day worth where 1 is 1/1/1900. Though with some qualification. I have a web page. There are several ways to create a date in the variable, would you mind showing me how you save and recreate yours in your macro?

 

Here are a couple of articles I wrote on time in MEP if you're interested:

http://bluepointdesign.com/macros_old/Delphi_Serial_Time/

http://bluepointdesign.com/macros_old/Text_to_Serial_Time/

 

Link to comment
Share on other sites

Currently there is no way to read out the value "last run time" (of macro). But you can make a suggestion for future.

 

Calculating time in macro isn't easy. Is the "delay without ability to halt"-command an option ?

 

<LABEL Name="Start"/>
<COMMENT Value="commands"/>
<DELAY Flags="\x00" Time="180"/>
<GOTO Name="Start"/>

Look_Up

Link to comment
Share on other sites

You will first need to record your time at the completion at the end of the macro for the next time comparison. I suggest saving the value to the registry as decimal. Then when it runs the next time induct that value and subtract it from the current time. 3 minutes would be 0.002083R days so your condition might be something like "If greater than 0.002" which would roughly be 3 minutes.

Link to comment
Share on other sites

That´s my current macro where %WFZeit% ist the current time and %WFold% is set to the current time when the macro is played.

Then %WFold% is saved. The calculation "%WFZeit%="%WFZeit%" - %WFold% takes place before that.

<DATE/TIME Flags="\xB0" Date="15.01.2013 14:29:02" Day_Offset="0" Month_Offset="0" Year_Offset="0" Hour_Offset="0" Minute_Offset="0" Second_Offset="0" Left="Center" Top="Center" Monitor="1" Variable="%WFZeit%" IsDateVar="TRUE"/>
<VARIABLE MODIFY DATE/TIME DateVar="%WFZeit%" Option="\x01" LeftVar="%WFZeit%" RightVal="%WFold%" UseInteger="TRUE" MathOpt="\x00"/>
<DATE/TIME Flags="\xB0" Date="15.01.2013 14:29:02" Day_Offset="0" Month_Offset="0" Year_Offset="0" Hour_Offset="0" Minute_Offset="0" Second_Offset="0" Left="Center" Top="Center" Monitor="1" Variable="%WFold%" IsDateVar="TRUE"/>
<VARIABLE SAVE Option="\x06"/>
<IF VARIABLE Variable="%WFZeit%" Condition="\x03" Value="5" IgnoreCase="FALSE"/>
<TEXT TYPE Action="0" Text="<ARROW UP>"/>
<END IF/>

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...
×
×
  • Create New...