Extract the Date from UCCNC

This is where you talk about Macros, show examples of your macro scripting and SHARE handy segments of script code as examples.

Re: Extract the Date from UCCNC

Postby Dan911 » Wed Dec 07, 2016 1:19 am

Hi TP!
LOL...Just did a google search for DateTime.Now and came across this post, should of known just to email you. I've been experimenting with DateTime.Now but not for the date but computer clock.

string time1 = DateTime.Now.ToString(" m ");

MessageBox.Show(""+time1);

This will give me the minuets on comp clock. What I've been attempting to achieve is to save to a var and make a if compare to execute some code every 5 or 10 minuets. My problem is when saved to a Setvar its still updating with clock. Any suggestions? I read using a system timer is the better approach to this but had no luck with that either, my lack of experience has me going to bed with a headache past 2 nights.

As always your help is very much appreciated,
Dan
Dan911
 
Posts: 613
Joined: Mon Oct 31, 2016 1:22 am
Location: USA

Re: Extract the Date from UCCNC

Postby Dan911 » Fri Dec 09, 2016 4:59 pm

Hi TP,

What I found useful with DateTime.Now is extracting time from computer clock, whether its the time or just hour,minute or second.

Below is sample code to send whatever code every 2 min in macro loop. I've read using a timer is a more efficient way but just having fun learning this stuff.

Thanks for you tips, keep them coming!

Dan
-------------------------------------------------------
double time1 = DateTime.Now.Minute;

if (time1 == 59)

{exec.Getvar(???);
time1 = 0;
exec.Setvar(time1,???);
}

else

if (time1 > (exec.Getvar(???)+ 1)) // Sets time interval +1 = 2min / / +2 = 3min etc...
{

////Your code

exec.Setvar(time1,???);


}
Dan911
 
Posts: 613
Joined: Mon Oct 31, 2016 1:22 am
Location: USA


Return to Macros

Who is online

Users browsing this forum: No registered users and 11 guests