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.

AppGameKit Classic Chat / Is there a clever way to write strings with linebreaks?

Author
Message
basicFanatic
7
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 24th Jun 2019 18:29


It's such a little thing, so I feel a little weird even asking about this. But I need to have a longer text with linebreaks instead of just "AAA". I know I can use chr(10) to make a line break. So I guess I can do something like:



... and then importing a into the array. But is there a smarter way?
Increase
7
Years of Service
User Offline
Joined: 21st Feb 2017
Location:
Posted: 24th Jun 2019 19:31 Edited at: 24th Jun 2019 19:35
as long as the strings are arrayed also , e.g. in strings as string [] ->

Global tutPages as string[0] : temp as string

for x = 1 to strings.length : strings[x] = strings[x] + chr(10) : tutPages.insert(strings[x]) : next x


or if the original string array shall not be changed :


for x = 1 to strings.length : temp = strings[x] + chr(10) : tutPages.insert(temp) : next x
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 24th Jun 2019 19:34 Edited at: 24th Jun 2019 19:37
word wrap is probably the way to go? see phaelax' post HERE for an idea.

ie, if you're using Text commands, have 1 temp text ID to "measure" each word's length and decide if it should be on the current line of text or start the next one.

Ortu
DBPro Master
17
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 24th Jun 2019 22:58 Edited at: 24th Jun 2019 23:01
#CONSTANT NEWLINE chr$(13)+chr$(10)

MyString = "oh hi" + NEWLINE + "goodbye"
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 25th Jun 2019 00:00


Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 25th Jun 2019 18:06
basicFanatic, i understood the OP as a "how to write strings with linebreaks to screen without using linebreaks" query. now i see that you might simply be asking how to include linebreaks in an array of strings?

basicFanatic
7
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 26th Jun 2019 02:28
a = a + "Yeah, I formulated that poorly. Sorry, it was late. But" + chr(10)
a = a + "sometimes I just has a bunch of lines which I want" + chr(10)
a = a + "to put on the screen in that exact order." + chr(10)
a = a + "I just wondered what would be most effective here" + chr(10)

Still, the automatizing linebreak stuff is much more interesting. Loads of great hacks here!

At my current project I go for monospace font, so I can just count the number of words:

Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 26th Jun 2019 23:22
Quote: "SetTextMaxWidth()"

that's handy but acts more like a "line wrap"? IE, will break words apart and probably allows for the next line to begin with a space? (not-tested)

Login to post a reply

Server time is: 2024-11-22 21:40:40
Your offset time is: 2024-11-22 21:40:40