Left padding to string

clemboclembo Member Posts: 122
I need to fill string with blank char. So i built a function to do it but when exit function Nav delete blank space.
Why?

How I can do this?

Comments

  • David_SingletonDavid_Singleton Member Posts: 5,479
    exit(strubstno('%1',' '));

    I think that works.
    David Singleton
  • clemboclembo Member Posts: 122
    Not work.

    In my custom function i fill a string with blank spaces required then

    REPEAT
    Filler += ' ';
    Count := Count +1;
    UNTIL Count = Target;

    TextToFill := Filler + TextToFill;

    EXIT(TextToFill);
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Odd, it works for me. Of course fix the typo first 8)
    David Singleton
  • MBergerMBerger Member Posts: 413
    Maybe you are putting the result in a Code field ? Because those delete any preceding and trailing spaces.
    BTW, ehre is a simpler version for your function, without the need of a loop etc.

    FunctionName : PadLeft, returns text[1024]
    Parameters :
    - ToPad Text[1024]
    - ToLength : Integer
    - PadChar : Text[1]
    ToPad := padstr('',ToLength,PadChar) + ToPad ;
    exit(copystr(ToPad,strlen(ToPad) - (ToLength-1),ToLength)) ;
    
  • clemboclembo Member Posts: 122
    Thakyou. Is type code the error!!
  • MBergerMBerger Member Posts: 413
    clembo wrote:
    Thakyou. Is type code the error!!
    Great :) YOu might want to set the post as "solved" then !
Sign In or Register to comment.