PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 12/12/2017 11:15 AM by  FireGeek21
Create a field of spaces
 3 Replies
Sort:
You are not authorized to post a reply.
Author Messages
FireGeek21
Private
Private
Veteran Member
(141 points)
Veteran Member
Posts:61


Send Message:

--
12/11/2017 10:42 PM

    I am using process flow to build a fixed field .txt file.  Several of the fields require a specific number of spaces because no value is being passed.  In SQL it is quite easy to use space(10) for a field with 10 spaces.  How can I do this in an Assign node maybe with javascript?  I have tried the addtrailingspaces(" ", 10  but the spaces appear as %20%20%20...  instead of true spaces.  Using "      " is out of the question because the header and trailer require over 2,000 spaces each.

    Thanks for the help!

    Ragu Raghavan
    Private
    Private
    Veteran Member
    (902 points)
    Veteran Member
    Posts:314


    Send Message:

    --
    12/12/2017 6:00 AM
    isn't there a 3rd parameter? Try setting that to null. addTrailingSpaces(" ",10,"")
    Kyle Jorgensen
    Programmer/Analyst
    WoodmenLife
    Veteran Member
    (314 points)
    Veteran Member
    Posts:116


    Send Message:

    --
    12/12/2017 8:10 AM
    Straight from the pflow.js file:

    /************************************************************
        Function: addTrailingSpaces(String varValue, int finalLenthOfVarValue, isSpaceEscaped)
        
        Purpose:  returns the String with trailing space escape chars
        to be used while attaching a variable in form URL. Can also
        be used to add actual space characters instead of the escaped
        space char by passing false for the argument isSpaceEscaped.
        If the 3rd argument is not passed at all, space will be escaped
        and then added.
    ************************************************************/
    function addTrailingSpaces(varString, finalLengthOfVarString, isSpaceEscaped)
    {
        var retVal = ""
            var currLengthOfVarValue = varString.length;
        var leadingSpacesLength = finalLengthOfVarString - currLengthOfVarValue;
        var leadingSpacesStr = "";
        var spaceChar = "%20";
        if(isSpaceEscaped==undefined) isSpaceEscaped = true;
        if(!isSpaceEscaped)
            spaceChar = " ";
        for (var i=0;i
    FireGeek21
    Private
    Private
    Veteran Member
    (141 points)
    Veteran Member
    Posts:61


    Send Message:

    --
    12/12/2017 11:15 AM
    Ah, yes there is a 3rd parameter! Thanks. It helps to keep scrolling to the right to see all of the parameters. So simple! THANK YOU!!!
    You are not authorized to post a reply.