Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

text string repeat in a Print statement?

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

    text string repeat in a Print statement?

    i'm searching for, but have not yet found [with Google and/or the Forum], a way to specify a character [or more generally a text string] to be repeated a specified number of times in a Print statement [eg] something like maybe Print(33("x")); to print a string of 33 x's. Help will be appreciated.

    #2
    Originally posted by joemiller View Post
    i'm searching for, but have not yet found [with Google and/or the Forum], a way to specify a character [or more generally a text string] to be repeated a specified number of times in a Print statement [eg] something like maybe Print(33("x")); to print a string of 33 x's. Help will be appreciated.
    In 25 years, I've never seen anything like that.

    You'll need to create your own function and return a string.

    pseudo code:

    function repeat_string ( string_to_repeat varchar2, repeat number )
    return varchar2
    is

    rString varchar2(1000);

    begin

    for i in 1..repeat
    loop
    rString := rString || string_to_repeat;
    end loop;

    return rString;

    end;

    Comment


      #3
      Originally posted by joemiller View Post
      i'm searching for, but have not yet found [with Google and/or the Forum], a way to specify a character [or more generally a text string] to be repeated a specified number of times in a Print statement [eg] something like maybe Print(33("x")); to print a string of 33 x's. Help will be appreciated.
      Well, here are some interesting ideas/hacks.

      Comment


        #4
        Originally posted by joemiller View Post
        i'm searching for, but have not yet found [with Google and/or the Forum], a way to specify a character [or more generally a text string] to be repeated a specified number of times in a Print statement [eg] something like maybe Print(33("x")); to print a string of 33 x's. Help will be appreciated.
        Write a "for loop".

        Comment


          #5
          thanks, that help a lot in that I will not waste any more time on it. I will just go ahead and type in a long string of whatever text I need whenever I need it.

          Comment


            #6
            Originally posted by sledge View Post
            In 25 years, I've never seen anything like that.

            You'll need to create your own function and return a string.

            pseudo code:

            function repeat_string ( string_to_repeat varchar2, repeat number )
            return varchar2
            is

            rString varchar2(1000);

            begin

            for i in 1..repeat
            loop
            rString := rString || string_to_repeat;
            end loop;

            return rString;

            end;
            Please stop frightening little boys and girls with Assembler pseudocode.

            Comment


              #7
              Originally posted by koganam View Post
              Please stop frightening little boys and girls with Assembler pseudocode.
              Actually, it is Oracle PL/SQL

              Comment


                #8
                Originally posted by joemiller View Post
                thanks, that help a lot in that I will not waste any more time on it. I will just go ahead and type in a long string of whatever text I need whenever I need it.
                Actually, my initial response was somewhat misleading. I was just reading some of my very ooooold code, and realized that I used to do this quite often then. You can actually do it using the string constructor itself!

                Code:
                string s = [URL="http://www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] String('X', 5);
                will make s contain XXXXX

                which you can then Print().

                That should be plain enough, but I can always post a quick-and-dirty 2 lines if you want.

                Better yet, here is a somewhat comprehensive reference for you.

                ref: http://msdn.microsoft.com/en-us/libr...#Ctor3_Example

                I need to polish up my Google-Fu.
                Last edited by koganam; 06-22-2013, 05:04 PM.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by junkone, 04-28-2024, 02:19 PM
                8 responses
                92 views
                1 like
                Last Post brucerobinson  
                Started by mkouitra, 10-23-2021, 04:40 PM
                17 responses
                1,964 views
                0 likes
                Last Post NinjaTrader_Jason  
                Started by Vietanhnguyen2hotmailcom, 05-03-2024, 10:29 AM
                4 responses
                29 views
                0 likes
                Last Post Vietanhnguyen2hotmailcom  
                Started by PhillT, 04-19-2024, 02:16 PM
                4 responses
                37 views
                0 likes
                Last Post PhillT
                by PhillT
                 
                Started by ageeholdings, 05-01-2024, 05:22 AM
                5 responses
                40 views
                0 likes
                Last Post ageeholdings  
                Working...
                X