Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Manually Centering Text without using CENTER TEXT

Author
Message
Katyman
FPSC Reloaded TGC Backer
11
Years of Service
User Offline
Joined: 5th Oct 2012
Location: Katy, Texas USA
Posted: 23rd Sep 2015 22:28
I am having "Coder's block" with one simple problem. I used to know how to do this but just can't remember.

Without using "CENTER TEXT" how do I manually Center a line of text on different screen widths using LEN(MyTEXT$) to determine size of text and SET CURSOR X,Y to position the MYTEXT$ text line.

Reason is that I want to set up multi-color text on various letters or whole words on one or more lines. CENTER TEXT does not allow me to do this trick very well. Say MYTEXT$ = (D)ark (B)asic (P)rofessional and the letters within () change various colors. I have the code to do that but not how to center it manually on a screen. Does anyone have that formula?

When old programmers die...do they decompile?
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 23rd Sep 2015 22:58
(ScreenWidth-TextWidth)/2
Katyman
FPSC Reloaded TGC Backer
11
Years of Service
User Offline
Joined: 5th Oct 2012
Location: Katy, Texas USA
Posted: 24th Sep 2015 05:10
Thanks. Taking a rest from coding for a few. For me to forget this simple formula means I need a vacation ha!

When old programmers die...do they decompile?
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 24th Sep 2015 09:09
I can appreciate that, I've been there
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 15th Oct 2015 03:33
... bah, i feel silly, I've been doing screen width / 2 - text width / 2

Login to post a reply

Server time is: 2024-03-29 12:56:40
Your offset time is: 2024-03-29 12:56:40