Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    How can we do put a number to 3number

    Help
    5
    13
    597
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • pianofire
      pianofire Fuze Team @Richard last edited by

      @Richard Great minds think alike!

      R 1 Reply Last reply Reply Quote 2
      • R
        Richard F @pianofire last edited by

        @pianofire if only I could type faster.

        1 Reply Last reply Reply Quote 2
        • P
          popinet21 last edited by

          Thank you so much,
          I'm still not comfortable with the functions, I will try to understand them and I will put them in my program

          1 Reply Last reply Reply Quote 0
          • P
            popinet21 last edited by

            I understand your functiont, they are the same

            1 Reply Last reply Reply Quote 0
            • P
              popinet21 last edited by

              For my project digits or padlen must be equal to 3

              pianofire 1 Reply Last reply Reply Quote 0
              • pianofire
                pianofire Fuze Team @popinet21 last edited by

                @popinet21

                So you could just have a function:

                function zeroPadInt(integer)
                  result = str(integer)
                  while len(result) < 3 loop
                    result = "0" + result
                  repeat
                return result
                

                But in another project you may need a different length so the first version has more reuse value

                1 Reply Last reply Reply Quote 0
                • Discostew
                  Discostew F last edited by

                  One thing that Petit Computer did was allow multiplying of strings. For instance...

                  myvar = "01" * 4
                  

                  This would result in "01010101". Would be nice if that sort of feature were added.

                  1 Reply Last reply Reply Quote 0
                  • T
                    tony7059 last edited by pianofire

                    Though Petit Computer may provide this feature, I don't believe I've seen this feature in any other languages. It's really just as easy for you to write a simple function that does the same thing.

                    function appendCopy( str, times)
                        String appendCopy = str
                        for i = 0 to times loop
                            appendCopy = appendCopy + str
                        repeat
                    return appendCopy
                    
                    String newString = appendCopy("01", 4)
                    

                    BTW, I've not tried appendCopy += str which might also work. But, even if I got something not quite right, you get the idea.

                    1 Reply Last reply Reply Quote 1
                    • pianofire
                      pianofire Fuze Team last edited by pianofire

                      TIP: if you put 3 back ticks ``` around a block of code it will format it:

                      T 1 Reply Last reply Reply Quote 0
                      • T
                        tony7059 @pianofire last edited by

                        @pianofire, Thanks! I also see now that there is a "code" option in the above content choices... dah! : )

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post