String Manipulation Question

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
User avatar
Dutchie_World_Wide
Posts: 31
Joined: Thu Jul 08, 2010 8:52 am
Location: The Netherlands, or Thailand, or Gabon West Africa
Has thanked: 4 times
Been thanked: 3 times
Contact:

String Manipulation Question

Post by Dutchie_World_Wide »

Hi guys,

I want to write the time from GPS to the EB076 Display.
I can print number Hour_Byte then print ":" and Print Number Minutes_Byte and Print "." and then Seconds_Byte
But then I have to calculate the X and Y position for every print command.

Is there a simpeler way?
Something like this?

Display_Time_String=ToString$ (Hour_Byte) ":" (Minutes_Byte) "." (Seconds_Byte)

How would you guys do this?

Dutchie
Dutchie

"This is not a bug, this is a feature!"

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: String Manipulation Question

Post by Benj »

Hello Dutchie,

You could do something like this.

Code: Select all

Display_Time_String = ToString$(Hour_Byte)
Display_Time_String = Display_Time_String + ":"
Display_Time_String = Display_Time_String + ToString$(Minutes_Byte)
Display_Time_String = Display_Time_String + "."
Display_Time_String = Display_Time_String + ToString$(Seconds_Byte)
A better way might be to add leading 0's if the hour, min or second variable is less than 10 so you get a nice consistent display.

Code: Select all

Display_Time_String = ""

if (Hour_Byte < 10)
 Display_Time_String = "0"

Display_Time_String = Display_Time_String + ToString$(Hour_Byte)
Display_Time_String = Display_Time_String + ":"

if (Minutes_Byte < 10)
 Display_Time_String = Display_Time_String + "0"

Display_Time_String = Display_Time_String + ToString$(Minutes_Byte)
Display_Time_String = Display_Time_String + "."

if (Seconds_Byte < 10)
 Display_Time_String = Display_Time_String + "0"

Display_Time_String = Display_Time_String + ToString$(Seconds_Byte)

Post Reply