User Tag List

Results 1 to 5 of 5

Thread: Extracting a line from Rich Edit Object or Edit Ob

  1. #1
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module
    Tiles's Avatar
    Join Date
    Jun 2006
    Posts
    1,359
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Extracting a line from Rich Edit Object or Edit Ob

    I try to extract a specific line in a text i have loaded into a Rich Edit Object that contains a specific word as the first word. But i cannot get it to work. I cannot find the right action.

    I can scroll to a line. But then there is no way to grab this line's text nor to check if the first word in this line is the one i need.

    How do i?

  2. #2
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module

    Join Date
    Feb 2007
    Location
    Queensland, Australia
    Posts
    317
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Extracting a line from Rich Edit Object or Edi

    You'd need to find how many characters until the next linebreak... Don't know how to do that though.

  3. #3
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module
    Tiles's Avatar
    Join Date
    Jun 2006
    Posts
    1,359
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Extracting a line from Rich Edit Object or Edi

    Heh, that's why i ask :P

    I managed to get it to work with a list object and an alterable string now, setting the string to the current line of list object and testing it with left string extract.

    Would be nevertheless interesting how you can select and extract a single line in RTF Object or the Edit Object. Because the List Object is limited in line numbers afaik. I think i have hit it before. And i may need to test a few hundrets of thousands of lines in the worst case.

  4. #4
    Clicker Multimedia Fusion 2

    Join Date
    Sep 2006
    Location
    Britain, South Coast
    Posts
    1,030
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Extracting a line from Rich Edit Object or Edi

    MMF2 cometh to the rescue in this case.

    I've been working on a system which uses a kind of language, so I had to do a similar thing. Some simple ways:

    Option 1: String Parser

    Set delimiter to newline$
    Set source text to the ascii version of the RTF text (use the Get Text function as opposed to Get RTF Text)
    Now use the 'get element x' expression to retrieve whichever line you want.

    Bear in mind that it's possible the element will start with a newline, like this:

    "
    blah"

    instead of "blah"

    ...because I don't think String Parser strips this out. So you'll wanna check the first and last characters to see what they are first.

    But this has the advantage of instantly letting you get whichever line you want.

    Option 2: Use RTF Object's own line functions

    Keep a record somewhere (counter or alterable value) of the current position of the caret (we'll save it as 'Current Pos'.
    Then use the Go To Line action, specifying a specific line number.
    Record the caret position NOW, as something else (we'll store it as 'Start pos'.
    Now do the Go To Line action AGAIN, but set it to go to the line you want + 1 (the next line).

    Now retrieve the text between the 'Start pos' and where the caret currently is.

    This is your line!

    Finally, return the caret to 'Current pos', where it was before. This is all doable in one event, so shouldn't notice too badly.

    Option 3: MMF's Built in String Functions

    If you need to find the actual LOCATION of a newline, or some other character, you can use two inbuilt functions which are awesome. I mention these because they rock, and you may find a different use for them even if you don't use them for this.

    They are:

    find( in string, look for, starting at)
    reversefind( in string, look for, ending at)


    They allow you to specify a position ('starting/ending at'), and search for a string ('look for') either before (reversefind()) or after (find()) this point.

    You can store an alterable value or counter, called Pointer. Then run a fastloop, where it does this on each loop:

    Set pointer to find([text of RTF object], newline$, pointer)

    It keeps advancing the pointer to the location of the next newline. So if you want line 6, run the loop 6 times.

    To get the whole loop, simply retrieve the text from the 'pointer' position to the find([text of RTF], newline$, pointer+1)

    This'll give you the line you want.

    Like I said the others are better, but these two functions WILL be useful if you ever develop an app that reads text. I love them, so it's a good thing to mention.

  5. #5
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module
    Tiles's Avatar
    Join Date
    Jun 2006
    Posts
    1,359
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Extracting a line from Rich Edit Object or Edi

    Excellent solutions. I haven't even figured out a single one, heh. Many thanks

Similar Threads

  1. Rich Edit Object help
    By kungsangun in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 22nd July 2011, 05:34 PM
  2. Rich Edit Object bug
    By Phi in forum Extension Development
    Replies: 2
    Last Post: 3rd February 2010, 01:04 PM
  3. Edit Object vs. Rich Edit
    By Jaffob in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 4th June 2008, 02:42 PM
  4. Rich Edit Object help
    By crugh in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 4th March 2007, 02:09 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
  •