
-----------------------------------
mike200015
Sun Jan 30, 2005 7:30 pm

Centre Text?!
-----------------------------------
Is there any way to centre text automatically instead of trial and error of trying to change the coordinates ??

-----------------------------------
Mr. T
Sun Jan 30, 2005 7:33 pm


-----------------------------------
no

-----------------------------------
person
Sun Jan 30, 2005 7:48 pm


-----------------------------------
i think there is, since a standard text screen, is 25 rows by 80 columns, so the centre is (1,40)

-----------------------------------
ssr
Sun Jan 30, 2005 7:58 pm


-----------------------------------
well, u can put the text in middle by doing something like index
first count how many chars are there
then div them by 2
locate (1,maxcol div 2 - the number of char div 2)
put the text
And there u go

Also, u can chaneg the size of thee output window by doing somethign liek
setscreen("graphics:x;y")
yep adn there u go
 8)

-----------------------------------
ssr
Sun Jan 30, 2005 8:05 pm


-----------------------------------
Here's a code for ya
use length to coutn how many chars are there and then use the way I mentioned above! :D  :) 


var word : string
var length1:int 
    get word:*
    length1:= length (word) div 2
locate ( maxrow div 2,maxcol div 2 - length1)
put word


-----------------------------------
basketball4ever
Sun Jan 30, 2005 8:09 pm


-----------------------------------
    var len : int := length ("Hello World")
    locate (1, (maxcol - len) div 2)
    put "Hello World" ..

hope it helps...
first u calculate how many letters are in ur string... and set it as a variable, so basically hello world has 11 characters.

Then in ur locate, you have 1 (being the row) then have the max col of the screen, minus the length, so in a default screen... (80-11) then div 2... = the center will be the center leter of ur text, in this case, a space.

-----------------------------------
ssr
Sun Jan 30, 2005 8:14 pm


-----------------------------------
srry made a mistake ,
subtract first then div
srry
basketball4ever is right, its the same thing as I said
and hopefully it helps! :roll:

-----------------------------------
mike200015
Sun Jan 30, 2005 11:17 pm


-----------------------------------
hey, yea thanx .. both of those helped me

but what i dont understand is why you use maxcol?.. isnt that maximum colour? what does that have to do with centring text?

-----------------------------------
mike200015
Sun Jan 30, 2005 11:20 pm


-----------------------------------
o wait.. never mind.. i figured it out.. its maximum column not colour lol

and also how would you incorporate that into Font.Draw , since i usually use that rather than jus the regular put

-----------------------------------
Bacchus
Sun Jan 30, 2005 11:23 pm


-----------------------------------
no maxcol is for the maximum column, for the maximum color its maxcolor close but no cigar. they use maxcol because the text (even when you use locatxy) gets printed in the row and column specified (nearest row and column for locatexy) except if you dont use locatexy or locate then it starts at the maxrow (or is it row 1? which one is the top lol, i dunno i never use locate :P) and either decreases or increases by one, depending on which is the top maxrow or 1 lol. rows go across and column go up and down. but you probably kno this so ive just wasted my time explaining.... meh

-----------------------------------
mike200015
Sun Jan 30, 2005 11:31 pm


-----------------------------------
lol.. yea knew some of that.. but watever.. thanx anyway  :D

-----------------------------------
Bacchus
Sun Jan 30, 2005 11:55 pm


-----------------------------------
lol im bored so i went a bit in depth :P

-----------------------------------
Cervantes
Mon Jan 31, 2005 8:26 am


-----------------------------------
and also how would you incorporate that into Font.Draw , since i usually use that rather than jus the regular put


var word := "Hello World"
const fontHeight := 48
var font := Font.New ("Times New Roman:" + intstr (fontHeight))
Font.Draw (word, round ((maxx - Font.Width (word, font)) / 2), round ((maxy - fontHeight) / 2), font, black)

It's the same idea.  THINK!  :roll:

-----------------------------------
ssr
Mon Jan 31, 2005 8:07 pm


-----------------------------------
Yep, but instead of using maxcol adn maxrow, u use maxx and maxy because font draw are measured in pixels instead of rows and columns! :idea:

-----------------------------------
basketball4ever
Mon Jan 31, 2005 8:13 pm


-----------------------------------
Yep, but instead of using maxcol adn maxrow, u use maxx and maxy because font draw are measured in pixels instead of rows and columns! :idea:

unless you're using locatexy go see my tutorial on basic text stuff :D

-----------------------------------
ssr
Mon Jan 31, 2005 8:19 pm


-----------------------------------
yep locatexy too :D actually its easier to use locatexy, um...
tnx
 :D

-----------------------------------
[Gandalf]
Tue Feb 01, 2005 12:34 pm


-----------------------------------
I do it ssr's way.  You could also (for left/right) use something like Center.Text or something, but I forget the exact command since like I said, I don't use it.

-----------------------------------
ste_louis26
Thu Feb 03, 2005 5:52 pm


-----------------------------------

var str:string:="what is this???"
locate (1,(maxcol - length (str)) div 2)
put str

