BASIC

Author Topic: text  (Read 2567 times)

Offline Richard Rae

  • Mr. Drawsprite
  • **
  • Posts: 79
    • View Profile
text
« on: 2007-Apr-20 »
Is there any way to centre justify printed text or any other justification(left,right)

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5014
  • O Rly?
    • View Profile
text
« Reply #1 on: 2007-Apr-20 »
I make a small function for you, one moment pls ;)
I <3 DGArray's :D

PC:
AMD RYzen 7 1700 @3.9Ghz, 16GB HyperX Fury 2666Mhz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5014
  • O Rly?
    • View Profile
text
« Reply #2 on: 2007-Apr-20 »
So i got it  :D

CENTER TEXT:

Code: GLBasic [Select]
// SX = String X (Center);    SY = StringY (Center)

FUNCTION Print_C: String$,SX,SY,Font_number

SETFONT Font_number

GETFONTSIZE FontX, FontY

PRINT String$, SX - (LEN(String$)*FontX)/2, SY - FontY / 2

ENDFUNCTION
TEXT RIGHT:
Code: GLBasic [Select]
FUNCTION Print_R: String$,SX,SY,Font_number

SETFONT Font_number

GETFONTSIZE FontX, FontY

PRINT String$, SX - (LEN(String$)*FontX), SY - FontY / 2

ENDFUNCTION
Text to the left are the normal Print ;)

For Example:

Code: GLBasic [Select]
GLOBAL WinX = 800
GLOBAL WinY = 600

SETSCREEN WinX,WinY,0




WHILE TRUE

PRINT "Whats up there",0,WinY/2+10
Print_R("Test at the right side of life..... XD",WinX,WinY/2,0) // Set the Text to the right
Print_C("Hello World",WinX/2,WinY/2+10,0) // Center Text

SHOWSCREEN
WEND
END




FUNCTION Print_C: String$,SX,SY,Font_number

SETFONT Font_number

GETFONTSIZE FontX, FontY

PRINT String$, SX - (LEN(String$)*FontX)/2, SY - FontY / 2

ENDFUNCTION



FUNCTION Print_R: String$,SX,SY,Font_number

SETFONT Font_number

GETFONTSIZE FontX, FontY

PRINT String$, SX - (LEN(String$)*FontX), SY - FontY / 2

ENDFUNCTION
I <3 DGArray's :D

PC:
AMD RYzen 7 1700 @3.9Ghz, 16GB HyperX Fury 2666Mhz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline Richard Rae

  • Mr. Drawsprite
  • **
  • Posts: 79
    • View Profile
text
« Reply #3 on: 2007-Apr-20 »
Works great.Thank you.

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5014
  • O Rly?
    • View Profile
text
« Reply #4 on: 2007-Apr-20 »
no problem ;)
I <3 DGArray's :D

PC:
AMD RYzen 7 1700 @3.9Ghz, 16GB HyperX Fury 2666Mhz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard