Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:41 12 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Format a string

Author Message
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1989
Posted: 09:09pm 08 Jan 2025
Copy link to clipboard 
Print this post

PicoW with the latest firmware.
I am printing days of the week to LCDPanel using Day$(Date$) , when Wednesday (9 characters) is replaced with Thursday ( 8 characters) the ends of Wednesday are still on the screen. How can I format Day$(Date$) to have 9 characters or another way of doing it. I tried (Day$Date$,9) that tells me I need a closing bracket?  and searched the manual.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2611
Posted: 09:41pm 08 Jan 2025
Copy link to clipboard 
Print this post

There 3 methods I use to erase old text.

1) Precede each Text statement with an identical one containing a sting of spaces equal to the longest word.

2) Precede each Text statement with a BOX command that clears the Text space.

3) Add padding spaces to short words to clear the space after shorter words. Spaces can also be added to the start if the text is aligned to the middle.

eg "Sunday"+"  " will cover "Thursday"+"  ".

Edit.
A variation on 1) would be precede each Text with a repeat of the previous Text with the foreground colour the same as the background.
Edited 2025-01-09 07:48 by phil99
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1989
Posted: 04:08am 09 Jan 2025
Copy link to clipboard 
Print this post

Thanks Phil.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2611
Posted: 05:13am 09 Jan 2025
Copy link to clipboard 
Print this post

And another to get exact padding of spaces.

TEXT 33, 33, Day$(Date$)+space$(9-len(Day$(Date$)))
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1989
Posted: 05:25am 09 Jan 2025
Copy link to clipboard 
Print this post

Thanks Phil.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025