Post Reply 
Question about displaying strings
10-20-2019, 04:13 PM
Post: #2
RE: Question about displaying strings
(10-20-2019 02:43 AM)DrDarius Wrote:  Is there a way to center a string given as a variable displayed on the screen with TEXTOUT (or ..._P) command?
I could not find any command which would return the length of the string in pixels.

The TEXTOUT_P help screen says
Quote:Returns the X coordinate at which the next character of the string should be drawn if the string had more characters

from which the width could be derived. For example:

Code:
#pragma mode( separator(.,;) integer(h64) )

EXPORT CENTERTEXT_P()
BEGIN
  LOCAL w,str1,str2;
 
  str1:="uncentered text"; 
  str2:="horizontally centered text";
  RECT_P();
  TEXTOUT_P(str1,160,0);
  PIXON_P(160,20);
  DIMGROB_P(G1,320,240);
  w:=TEXTOUT_P(str2,G1,0,0);
  TEXTOUT_P(str2,160-w/2,20);

  WAIT();
  RETURN w;
END;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Question about displaying strings - Wes Loewer - 10-20-2019 04:13 PM



User(s) browsing this thread: 1 Guest(s)