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.

DarkBASIC Discussion / How do I keep text on the screen?

Author
Message
Adam Prime
17
Years of Service
User Offline
Joined: 26th Jan 2008
Location:
Posted: 28th Jan 2008 16:29
Hi everybody,

When I print, or load text from a file, it just goes off the edge of the screen in one long line. I know that there must be a way to stop this, but I can't find it in any help file, and none of the tutorials explain it. Can anybody help me?
Thanks.
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 28th Jan 2008 19:28 Edited at: 28th Jan 2008 19:40
Use the Text command instead of Print and if you are using a 3D screen, place it after the Sync at the end of the main program loop.

Quote: "and none of the tutorials explain it."


Oh really?

What about tutorial 3 here:

http://forum.thegamecreators.com/?m=forum_view&t=99497&b=10

[Edit] Just realised what you were saying wasn't covered in tutorials - about the printed`string going off the right edge of the screen. I thought you meant off the bottom of the screen...

I wrote a function for DBC which does what you want - I'll dig it out for you.

TDK_Man

Adam Prime
17
Years of Service
User Offline
Joined: 26th Jan 2008
Location:
Posted: 28th Jan 2008 19:52
Thanks, man. That'll be great.
Pixelator
17
Years of Service
User Offline
Joined: 8th Jul 2007
Location: here
Posted: 29th Jan 2008 00:43
no function necessary, just use the printc command instead of print

Your signature has been erased by a mod. Reduce the size!
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 29th Jan 2008 05:30
Quote: "no function necessary, just use the printc command instead of print"


OK then, if I am wrong and you are right, please show us your working example of PrintC doing what Adam Prime wants! You did actually write something to test out what you are saying is correct right?...

Or did you just post what someone in another thread suggested?

Note: If you are going to search the forum for answers to questions people ask, please be sure to read all of the threads you find - especially later posts which say that something suggested earlier in the thread doesn't work!

Adam Prime:

When you get fed up of waiting for Pixelator's code example, I've tidied up my scrolling text box function and posted it in Code Snippets...

TDK_Man

Sinani201
18
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 29th Jan 2008 05:36 Edited at: 29th Jan 2008 05:36
Here it is...
http://forum.thegamecreators.com/?m=forum_view&t=122891&b=6

Seriously, how do you make the little blue text come up below your message?
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 29th Jan 2008 10:47
Printc just adds print to the end of the line, so it would actually be worse

@TDK
Is there a command to find the position of the cursor?

Adam Prime
17
Years of Service
User Offline
Joined: 26th Jan 2008
Location:
Posted: 29th Jan 2008 14:27
Thanks everybody, you've been great.

Now, TDK, you are obviously a much better programmer than me! A lot of the stuff in your code snippet is way, way over my head and I'm having a bit of trouble customising it to my needs.

Could I have an "abridged" version, to just create one text box on the screen (encompassing, say, the lower two thirds of the screen)?

I really appreciate you all helping me, and I look forward to being able to return the favour someday!!
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 29th Jan 2008 21:30 Edited at: 29th Jan 2008 21:34
Quote: "Is there a command to find the position of the cursor"


Not that I know of.

Quote: "I'm having a bit of trouble customising it to my needs"


You shouldn't have to customise other people's functions - they are the one example where you can post code in without having to understand it. All you should have to do is alter the parameters in the function call. You just need to know how to do it.

Quote: "Could I have an "abridged" version, to just create one text box on the screen (encompassing, say, the lower two thirds of the screen)?"


You already have it - the function will already do that. The demo program is only to show what you can do with the function (if you want to) and it just uses the same function 3 times with different parameters - once for each text box.

You only need one text box, so you only need one set of parameters and one function call.

What to do:

1. Copy and paste the function into your program - put it at the end.

2. Copy the 3 DIM lines from the demo program and paste them in your program. At the very beginning is best, but anywhere will do so long as they are before the function call.

3. Where in your program you would use the Print (or Text) command, use the function call:

ScrollPrint(TextBoxNum,XPos,YPos,ScrollBoxWidth,ScrollBoxHeight,T$,BColour,TColour,Border)

TextBoxNum is the number of the text box on screen you want to write to. If you only have one box then naturally this stays as a 1.

XPos and YPos are the X and Y position of the top left corner of the text box. The values for the bottom section of the screen depend on the current screen mode, but for 800x600 mode try 0 for XPos and 400 for YPos.

ScrollBoxWidth and ScrollBoxHeight are the width and height of the text box. For the full width of the screen in 800x600 mode use 800 for ScrollBoxWidth and as the box starts at 400, ScrollBoxHeight would be 200.

T$ is the text to print in the text box.

BColour is the background colour of the text box. Use RGB() or a colour value to make it match the rest of your screen.

TColour is the colour of the text in the box. Use RGB() or a colour value to set it to whatever you want.

Border is a flag. Set it to 1 and you get a border around the text box. Set it to 0 if you don't want a border.

So, in your program, put the text to be printed into T$ with:

T$="The text to print"

and call the function:

ScrollPrint(1,0,400,800,200,T$,0,RGB(255,255,255),0)

This gives you a black, borderless text box occupying the bottom 200 pixels of the screen. All text will be white.

Simply alter the values in the function call to change what you get on the screen.

TDK_Man

Adam Prime
17
Years of Service
User Offline
Joined: 26th Jan 2008
Location:
Posted: 4th Feb 2008 11:59
Thanks, TDK Man! That's really helpful. You've been great.

Login to post a reply

Server time is: 2025-06-04 01:57:00
Your offset time is: 2025-06-04 01:57:00