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.

Author
Message
bitJericho
23
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 17th Mar 2004 07:13
Well ive been at this for 2 days and im close to giving up I need a function setup like this..

FUNCTION WORDWRAP(message$,startX,startY,maxCharX,maxLineY)

ENDFUNCTION messageleft$

where I can specify a message, itll print the message using wordwrap, never going over the maxCharX limit and hard returning to the next line until MaxLineY is reached, and will return the remaining text.. If all the text is used then it returns nothing. Thank you so much whoever knows how to do it

(I can't even find a good tut on this!!)

The Unofficial DarkBASIC Magazine : http://www.dbspot.com/j2dstudios/
Gu re gu
23
Years of Service
User Offline
Joined: 14th Dec 2002
Location: United Kingdom
Posted: 17th Mar 2004 11:07
There's a supprising lack of information on this ... I'm not sure why, it's quite a difficult thing to get your head 'round.

I've been working on a little function on and off for several weeks now for my MUD. I'll post up the function and contact you ASAP (soon as I finish it that is ).

Daih thel phae 'e, clann 'e phaen
Blame it on INSANITY!
jasuk70
23
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 17th Mar 2004 18:59
Not sure what the actual problem is but you may want to forget about Numbers of characters as such and check for the width of each character. It will depend on the font used to how many characters will fit in your text area.

Jas

----
Http://www.jsun.co.uk
bitJericho
23
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 17th Mar 2004 20:14
no actually, number of characters is fine for what I'm doing Width is fine too, it would be easy to convert it either way.. The function needs to take the text, print it on screen and wrap the words to a new line when the maximum amount of characters per line is reached.. and it needs to wrap it when it hits a space " " not in the middle of a word.

The Unofficial DarkBASIC Magazine : http://www.dbspot.com/j2dstudios/
Steverino X
22
Years of Service
User Offline
Joined: 24th Aug 2003
Location: Iowa
Posted: 17th Mar 2004 23:05
I have a wordwrap solution, but it's structured much more simply. You define a rectangular area of the screen and it wraps within that automatically and scrolls up when it gets to the bottom. Get it here: http://www.stevetiffany.com/darkbasic.html
bitJericho
23
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 17th Mar 2004 23:07
thanks, ill be able to edit it to suit my needs. Just for some reason I couldn't figure out the wrapping logic

The Unofficial DarkBASIC Magazine : http://www.dbspot.com/j2dstudios/
zircher
23
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 18th Mar 2004 00:08
Geez people, just insert a line feed character [chr$(10)] when you need a new line and count the number of inserts to determine your max lines. Works just fine for the PRINT statement.

Steverino X and jasuk70 have the right idea though. Use the TEXT WIDTH command to find the real width of the characters based on the current font type and size.
--
TAZ

bitJericho
23
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 18th Mar 2004 00:34
zircher, the size of the margins may be any length

The Unofficial DarkBASIC Magazine : http://www.dbspot.com/j2dstudios/
bitJericho
23
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 19th Mar 2004 23:50
ok...this is what I have so far, and I'm simply not understanding why this won't work properly....


the code will not wrap the words at the proper positions..
PRINTB(msg$,x,y) is a function that will print the letters, this part of the program works perfectly, ive tested it, and it even works in this function perfectly.

The Unofficial DarkBASIC Magazine : http://www.dbspot.com/j2dstudios/
kevil
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Netherlands
Posted: 20th Mar 2004 01:40
Here's something that works, although it doesn't limit the amount of lines.



Kevil
bitJericho
23
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 20th Mar 2004 02:00
doesnt work when I convert it to the library...

please don't pop this library into your programs yet, because its completely unfinished and won't work without a bit of work yet

and please don't tell me how using sprites/etc. is better, though I do value your opinions and such, I've already been in this discussion more than 3 times

PRINTB() works similar to the text functions, so I thought converting these sources would be easy, but for some reason it never works.. please help

http://www.dbspot.com/j2dstudios/misc/library.zip

The Unofficial DarkBASIC Magazine : http://www.dbspot.com/j2dstudios/

Login to post a reply

Server time is: 2026-06-05 07:05:15
Your offset time is: 2026-06-05 07:05:15