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.

Dark GDK / Problem with wrap text function

Author
Message
Phosphoer
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location: Seattle
Posted: 19th Jun 2009 22:50
Hey guys, I am trying to write a function that displays wrapped text, but it doesn't work.



I then proceed to call the function with this:


However, the function prints nothing. If I don't null the 'Line' string, it prints some garbled text.

Any idea what I'm doing wrong?

WH8
15
Years of Service
User Offline
Joined: 17th Mar 2009
Location:
Posted: 19th Jun 2009 23:18
Try replacing char Text[256] with char *Text.
Phosphoer
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location: Seattle
Posted: 20th Jun 2009 00:27
Thanks, but doesn't seem to change anything ><

Phosphoer
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location: Seattle
Posted: 20th Jun 2009 02:04
Wow, I realized what was wrong ><

My while loop simply wasn't being run, because I was testing to see if CursorX was less than Width, rather than x + Width.

For anyone who's interested, here is my fully working wrapped text function, just input a string, the x and y coordinates, and the width of the paragraph.



kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 20th Jun 2009 02:09
Quote: " while ( CursorX < x + Width || Text[CurrentChar] != ' ' )"


You know that || means or, wouldnt you want it to be && for and?

Phosphoer
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location: Seattle
Posted: 20th Jun 2009 03:48
No, because then the while statement terminates when either condition is false. That would mean that if CursorX was past the margin, the line would terminate even though it might be in the middle of a word.

Phosphoer
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location: Seattle
Posted: 20th Jun 2009 08:02
Update, it started giving me errors again, but this update seemed to fix it:



Feel free to use it as you wish

Login to post a reply

Server time is: 2024-10-01 06:05:07
Your offset time is: 2024-10-01 06:05:07