Announcement

Collapse
No announcement yet.

How best to insert space in text...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How best to insert space in text...

    Here is what I have:
    <MvAssign name="l.info" value="LetsGetTogether">
    The output I want: Lets Get Together

    What is the best way to find the caps and insert a space before each one?
    William Gilligan - Orange Marmalade, Inc.
    www.OrangeMarmaladeinc.com

    #2
    Code:
    <MvCAPTURE VARIABLE = "l.data">
        <MvFOR INDEX = "l.pos" COUNT = "{ len_var( l.info ) }">
            <MvASSIGN NAME = "l.char"        VALUE = "{ substring_var( l.info, l.pos, 1 ) }">
            <MvASSIGN NAME = "l.asciivalue"  VALUE = "{ asciivalue( l.char ) }">
    
            <MvIF EXPR = "{ l.asciivalue GE 65 AND l.asciivalue LE 90 AND l.pos GT 1 }">
                <MvEVAL EXPR = " ">
            </MvIF>
    
            <MvEVAL EXPR = "{ l.char }">
        </MvFOR>
    </MvCAPTURE>
    David Carver
    Miva, Inc. | Software Developer

    Comment


      #3
      Nice solution... Showing great age - I didn't even know there was an MvCAPTURE command; but can't figure out why its different from just testing/capturing the output result of a function. Still waiting for an MvMAKECOFFEE command.

      Comment


        #4
        IMO, its just easier cause you don't have to escape anything. I use it a lot when i need to capture formatted output, say XML or HTML.
        Bruce Golub
        Phosphor Media - "Your Success is our Business"

        Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
        phosphormedia.com

        Comment


          #5
          I ran into an interesting issue with this code that got it on the back burner till this morning. Bottom line... doing this with either MvCapture with MvFor or MvWhile caused a space to be placed between every character. Turns out - when using sublime text 3.2.2 Mac - there was a space inserted every time due to the lines used.

          This is the code I ended up with (changed from MvCapture while troubleshooting the space issue):
          Code:
          <MvAssign name="l.pos" value="1">
          <MvWhile expr="{ l.pos LE len(gettoken(l.mytext' ',2)) }"><MvASSIGN NAME = "l.char" VALUE = "{ substring_var(l.mytext, l.pos, 1) }"><MvASSIGN NAME = "l.asciivalue"  VALUE = "{ asciivalue( l.char ) }"><MvIF EXPR = "{ l.asciivalue GE 65 AND l.asciivalue LE 90 AND l.pos GT 1 }"><MvEVAL EXPR = "{ ' ' $ l.char}"><MvElse><MvEVAL EXPR = "{ l.char }"></MvIF><MvAssign name="l.asciivalue" value=""><MvAssign name="l.pos" value="{ l.pos + 1 }"></MvWhile>
          Note - all on one single continuous line. Likely an issue with my sublime settings - if anyone has ideas on fixing that - feel free to share.
          William Gilligan - Orange Marmalade, Inc.
          www.OrangeMarmaladeinc.com

          Comment


            #6
            Sounds like you need to either set <MIVA STANDARDOUTPUTLEVEL = ""> for your entire file or on the function that is used in. Or you can even set it on the MvCAPTURE tag.

            Code:
            <MvCAPTURE VARIABLE = "l.data" STANDARDOUTPUTLEVEL = "">
            ...
            </MvCAPTURE>
            will give you what you want and still be readable.
            David Carver
            Miva, Inc. | Software Developer

            Comment


              #7
              Actually had tried "text" only - did not try the "". Just tested, and yup = you are right. That is the fix. Honestly, I don't recall ever actually doing that before (I feel like Jonathan!). Just re-read the docs, "If empty, output is suppressed unless explicitly output using the <MvEVAL> tag." I will remember that now.
              William Gilligan - Orange Marmalade, Inc.
              www.OrangeMarmaladeinc.com

              Comment

              Working...
              X