Page 1 of 1

using a Timestamp or Date as a variable

Posted: Fri Mar 27, 2015 8:39 am
by nico
Is there a way to use a Timestamp or Date as a variable?

I can't figure out a way how to do it

Re: using a Timestamp or Date as a variable

Posted: Fri Mar 27, 2015 9:06 am
by CookieMonster
Hi Nico,

Just on the "fly" it's not possible to get time stamp or date into a variable. But there are multiple ways to get them into a variable.

One of the solution is to create a UserCodemodule with a variable in it. But there is a small disadvantage, on UserCodeModule you can not pass any parameter, for e.g. if you want to pass the format of the time stamp. This has to be done directly in the Module.

Code: Select all

varTimeDateStamp = System.DateTime.Now.ToString("yy.MMM.dd_HHmmss");
And then you link this variable to the other modules.

The other solution is, that you have a recoding module, with a User Code Function with a string parameter, and there you can pass the format, when you call the function from the recording module.
Define a variable in the recording module like varTimeStamp.
Recording Module

Code: Select all

UserCode | GetTimeStamp | yy.MM.dd |

Code: Select all

private void GetTimeStamp(string format)
{
  varTimeStamp = System.DateTime.Now.ToString(forrmat);
}
And then the only thing you have to is, to link the variable to the other modules.

Cheers
Dan

Re: using a Timestamp or Date as a variable

Posted: Fri Mar 27, 2015 9:13 am
by nico
Thanks Dan!

Seems like a good solution.