News:

  • October 18, 2026, 05:45:26 PM

Login with username, password and session length

Author Topic: StringPrint Hours and Minutes  (Read 6807 times)

PLCwannabe

  • Hero Member
  • *****
  • Posts: 208
StringPrint Hours and Minutes
« 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? 

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3850
    • Host Engineering
Re: StringPrint Hours and Minutes
« Reply #1 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)

PLCwannabe

  • Hero Member
  • *****
  • Posts: 208
Re: StringPrint Hours and Minutes
« Reply #2 on: April 10, 2021, 10:52:32 PM »
Almost too easy. Thanks.