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 DJ888, 04-16-2024, 06:09 PM
                6 responses
                18 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by Jon17, Today, 04:33 PM
                0 responses
                1 view
                0 likes
                Last Post Jon17
                by Jon17
                 
                Started by Javierw.ok, Today, 04:12 PM
                0 responses
                6 views
                0 likes
                Last Post Javierw.ok  
                Started by timmbbo, Today, 08:59 AM
                2 responses
                10 views
                0 likes
                Last Post bltdavid  
                Started by alifarahani, Today, 09:40 AM
                6 responses
                41 views
                0 likes
                Last Post alifarahani  
                Working...
                X