LCDOUT command followed by variable data
Hi,
This must be recurrent subject but/and I can't recall how to handle this.
My project is about displaying time and adapting the output format to the number of digits to display adjusting mainly the number of spaces.
Since each LCDOUT command is 47 WORDs heavy, I'd like to avoid having to repeat this command all over my program.
This is a piece of my current code where one can see that I need to repeat the LCDOUT command often to fit the placement of characters.
Code:
' Display time in "0:00:00" format
IF Hours > 0 THEN ' " 0:00:00"
LCDOUT $FE,$2," ",DEC Hours,":",DEC2 Minutes,":",DEC2 Seconds
RETURN
ENDIF
IF Minutes > 9 THEN ' " 00:00"
IF LapDisplay THEN 'Lap is displayed
IF Lap > 9 THEN 'Lap is 2 characters wide
LCDOUT $FE,2,DEC2 Lap," ",DEC Minutes,":",DEC2 Seconds
ELSE 'Lap is 1 character wide
LCDOUT $FE,2,DEC1 Lap," ",DEC Minutes,":",DEC2 Seconds
ENDIF
ELSE 'no Lap display
LCDOUT $FE,2," ",DEC Minutes,":",DEC2 Seconds
ENDIF
RETURN
ENDIF
IF Minutes >= 0 THEN ' " 0:00"
IF LapDisplay THEN
IF Lap > 9 THEN
LCDOUT $FE,2,DEC2 Lap," ",DEC Minutes,":",DEC2 Seconds
ELSE
LCDOUT $FE,2,DEC1 Lap," ",DEC Minutes,":",DEC2 Seconds
ENDIF
ELSE
LCDOUT $FE,2," ",DEC Minutes,":",DEC2 Seconds
ENDIF
RETURN
ENDIF
How can I set a number of SPACEs by the mean of a variable?
Is there another way to achieve this?