User Tag List

Results 1 to 8 of 8

Thread: Parsing text by whole words onto lines with character limits?

  1. #1
    Clicker

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCHTML5 Export ModuleiOS Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)Universal Windows Platform Export Module (Steam)
    ratty's Avatar
    Join Date
    Apr 2012
    Posts
    1,165
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)

    Cool Parsing text by whole words onto lines with character limits?

    Is there an example of this that anyone knows of? I'm trying to have a program load any random .txt file and break it into different lines with character limits without breaking apart whole words. It's the breaking up whole words bit that I'm having trouble with. It doesn't matter if the extracted lines end up in a different object or are in the same one that loaded the .txt to begin with.

    For example, a 12 character limit of "Today is Friday, May 9th." results in:

    Today is Fri
    day, May 9th
    .

    I would like it to end up as:

    Today is
    Friday, May
    9th.


    As always, any help is greatly, greatly appreciated.

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export ModuleUnicode Add-on

    Join Date
    Nov 2010
    Location
    Switzerland
    Posts
    301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Ratty, perhaps it' s possible by using the Regex-Object. I have to admit that i haven' t used it (so far) and it looks complicated too. Anyway, i' ll post an example if i can figure Regex out...

    With kind regards,

    jahkri

  3. #3
    Clicker

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCHTML5 Export ModuleiOS Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)Universal Windows Platform Export Module (Steam)
    ratty's Avatar
    Join Date
    Apr 2012
    Posts
    1,165
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    I've got it! Well, just about. This works great except for one small thing. Punctuation breaks words apart, even in the case of apostrophes. Figuring out how to keep touching punctuation as part of the word which precedes it is the last thing to figure out here. I have no clue where to begin. I've used this to load documents which aren't punctuation heavy and it works great!

    Check out the attached file. You just need to add which file it loads on frame start and the rest should be pretty straight forward. For an example that contains a TON of punctuation, load the attached .txt file.


    wordwrap parser.mfa
    Snows of Kilimanjaro.txt

  4. #4
    Clicker

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCHTML5 Export ModuleiOS Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)Universal Windows Platform Export Module (Steam)
    ratty's Avatar
    Join Date
    Apr 2012
    Posts
    1,165
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Ouch! Just realized this causes issues if the .txt file loaded is in paragraph form or just a hard returned list of things...

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export ModuleUnicode Add-on

    Join Date
    Nov 2010
    Location
    Switzerland
    Posts
    301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Ratty, are you using the Regular-Expressions-Object to achieve this? (Sorry, i was not able yet to watch the Demos you posted). In the Regular-Expressions-Object, there' s an Option called "Treat Text as Sinle Line. This Option should turn the Text-Data to a Single-Line Text (which should get rid of the paragraphs / hard-returned Lists).

    With kind regards,
    jahkri

  6. #6
    Clicker

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCHTML5 Export ModuleiOS Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)Universal Windows Platform Export Module (Steam)
    ratty's Avatar
    Join Date
    Apr 2012
    Posts
    1,165
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    I have absolutely no knowledge on how to harness the Regular Expressions Object. Perhaps it's time to try if that's the only way to pull this off.

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export ModuleUnicode Add-on

    Join Date
    Nov 2010
    Location
    Switzerland
    Posts
    301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Ratty, there are also some Examples of the Regular-Expressions-Object but i could not find a "direct" Help-File for the Object. I found that Web-Page (via Google) that seems to explain it quite understandable, but it still seems to be a science on it' s own :P Here' s the Link to that Webpage: http://www.regular-expressions.info/tutorial.html

    Anyway, if i figure it out, i' ll let You know and will post a commented Example.

    Good Luck to You too with the Regular-Expressions-Object.

    By the Way, perhaps somebody on the Forum already knows how Regex works (some of the Programmer-Guys), would be nice if somebody could shed some Light on this Topic.

    with kind regards, jahkri

  8. #8
    Clicker

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCHTML5 Export ModuleiOS Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)Universal Windows Platform Export Module (Steam)
    ratty's Avatar
    Join Date
    Apr 2012
    Posts
    1,165
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)

    Parsing text by whole words onto lines with character limits?

    Oh! I have an idea I should try out.

    For the punctuation issue, Instead of having an action that moves X characters in, then to the beginning of whatever word it is, I'll have it move X characters in and then move back to the last space! That should work, I think. I just have to figure out how to program it.

    Now I just need to also come up with some sort of loop that first detects if each line in the txt file only has a single word on it, or a sentence. That will also fix another issue.

    This discussion has been enlightening!

Similar Threads

  1. Colourizing words in Text Blitter
    By MechatheSlag in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 10th January 2018, 08:20 PM
  2. Character Image - get number of lines?
    By AndyH in forum SWF/Flash Export Module Version 2.0
    Replies: 2
    Last Post: 6th October 2010, 04:21 PM
  3. Loading words from a text file
    By garciafigueres in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 13th August 2009, 06:25 PM
  4. Change some words in an text file
    By juanjo in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 21st May 2008, 10:07 PM
  5. Parsing text in TGF2?
    By Blizna in forum The Games Factory 2 - Technical Support
    Replies: 1
    Last Post: 11th September 2007, 04:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •