Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: PLCwannabe on April 09, 2021, 12:42:30 AM

Title: StringPrint Hours and Minutes
Post by: PLCwannabe on April 09, 2021, 12:42:30 AM
I'm trying to print to a  string 2 unsigned integers representing hours and minutes of a clock timer.  So I want the finished string to display the set time in   hh : mm    format to display on Hmi.  This works well for any minute value greater than 9 but omits the 0 for lower values. Eg. 12:04 displays as 12:4.    Is there a quick fix for this issue? 
Title: Re: StringPrint Hours and Minutes
Post by: franji1 on April 09, 2021, 08:39:24 AM
See FmtInt

If you have Designer 2.8, the STRPRINT has a new script based editor that provides helpful form edit for the various functions.  See the attached screen shot.

In the original Text-Based Editor, you would replace your element with a call to FmtInt():
FmtInt(V42,dec,2,zeropad)
Title: Re: StringPrint Hours and Minutes
Post by: PLCwannabe on April 10, 2021, 10:52:32 PM
Almost too easy. Thanks.