Hello All-
This is a simple question but I cannot figure out how to do this.
I have a byte variable and I want to display its value on the LCD.
My issue is when the value goes from '10' to '9', the display shows '90'.
How can I get it to show '09'?
Simple, but can not see it.......
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thomas, thanks for the info, however, not exactly what I am wanting. I did try what you suggested:
locate 3,5 : print leftpad(minutes,2)
locate 3,12 :print leftpad(seconds,2)
and it gave me strange symbols and not a 09.
Let me try be more clear.
In another compiler (PBP) I could use DEC(number of digits) and it would automatically show
11 then 10, then 09, then 08 as it was counting down.
Similarly, I could also use HEX(number of digits) and it would do the same for me.
I am wanting to display a minutes timer display which counts down to zero, then zeros out and the seconds timer display counts down from 60 to zero using leading zeros.
Does this make it any clearer?
I have spent time looking for other demos or code fragments for GCB but can not find any - I am certain I am not asking the correct question.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello All-
This is a simple question but I cannot figure out how to do this.
I have a byte variable and I want to display its value on the LCD.
My issue is when the value goes from '10' to '9', the display shows '90'.
How can I get it to show '09'?
Simple, but can not see it.......
leftpad()
Open the Demo folder in GCODE. Search 'EDIT'/'FIND' In Files. Search for leftpad. This returns 43 examples with some specific to LCD.
An example from the GitHub repository. https://github.com/GreatCowBASIC/Demonstration_Sources/blob/main/Training_Support/PIC16F18313/Training16.gcb - line 101
Thomas, thanks for the info, however, not exactly what I am wanting. I did try what you suggested:
locate 3,5 : print leftpad(minutes,2)
locate 3,12 :print leftpad(seconds,2)
and it gave me strange symbols and not a 09.
Let me try be more clear.
In another compiler (PBP) I could use DEC(number of digits) and it would automatically show
11 then 10, then 09, then 08 as it was counting down.
Similarly, I could also use HEX(number of digits) and it would do the same for me.
I am wanting to display a minutes timer display which counts down to zero, then zeros out and the seconds timer display counts down from 60 to zero using leading zeros.
Does this make it any clearer?
I have spent time looking for other demos or code fragments for GCB but can not find any - I am certain I am not asking the correct question.
Your syntax is wrong.
Print leftpad( str(Fract),4,"0")
implies Fract is an Integer.So is
minutes
an Int? tryprint leftpad(str(minutes),2)
to convert theBut, to use a lot less resources, try something simple.
~~~
locate 3,5
if minutes < 10 then
print "0"
print Minutes
else
print Minutes
end if
~~~
This program does not call the leftpad() function as that is resource hungry, or, str()
Kato,
Your second approach works great, I wish GCB had something to this is a single command, such as DEC(2) minutes!
You can create a function called DEC()
Thanks! Never used one, but I will try it out.