Need Help with 'String Replace' Function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • mystica
    No longer a forum member
    • May 2007
    • 1548

    Need Help with 'String Replace' Function

    Hi. Need some help with 'String Replace' Function. Can anyone help me with this, please:

    I'm trying to code a "String Replace" function using an Input-Object and Text-File. I've managed to successfully pass a string from one Text-File to another Text-File, but I want to pass the string from an Input-Object to a TextFile instead. But I can't get it to work.

    If anyone thinks they can help out with this, I've attached two Project-Files to demonstrate what I'm trying to do.

    NB.
    The first Project-File shows where I successfully passed a string from one Text-File to another Text-File (The Text-Files get dropped into the project's CD_Root Folder).

    The second Project-File doesn't work, but shows what I'm trying to do (ie. pass a string from the Input-Object to a Text-File that will be generated in the CD_Root Folder). Perhaps, if anyone can figure out a solution, they could could correctly code this second Project-File as an example, and re-attach it with their response.

    Thanks.
  • mwreyf1
    Indigo Rose Customer
    • Aug 2004
    • 417

    #2
    What is the purpose of the Input object?

    There is no reference to it at all in your code.

    Comment

    • mwreyf1
      Indigo Rose Customer
      • Aug 2004
      • 417

      #3
      Try this.

      It should get you started.
      Attached Files

      Comment

      • mystica
        No longer a forum member
        • May 2007
        • 1548

        #4
        Originally posted by mwreyf1 View Post
        What is the purpose of the Input object?

        There is no reference to it at all in your code.
        mwreyf1,

        The purpose of the InputObject is to replace the 1st TextFile used in the initial project-file. There is no reference to it in my code because that is what I'm having trouble coding and is what I'm seeking help with.

        Basically, I want the user to be able to type data into the InputObject so that when the button is clicked, a string-change is made to the data before it gets written to a TextFile in the CD_Root folder.

        In this particular case, when a user inputs a URL beginning with 'www', after clicking the button, the string-change is supposed to rewrite it to the TextFile as: 'http://www'. (ie. www.example1.com is supposed to be converted to http://www.example1.com).

        As I mentioned earlier, I've managed to achieve this in the 1st ProjectFile attached (passing the string-change from one TextFile to another) but NOT with the 2nd ProjectFile (passing the string-change from an InputObject to a TextFile).

        I'll have a look at the .Apz file you uploaded in your last response, when I get home and see how I go ... but thought it best to elaborate here and now on what I'm trying to do.

        Thanks dude.

        Comment

        • mwreyf1
          Indigo Rose Customer
          • Aug 2004
          • 417

          #5
          Now I see.

          This will probably be closer to what your looking for.

          No need to create the Links.txt before running.
          Attached Files

          Comment

          • mrdude
            Forum Member
            • Jun 2004
            • 143

            #6
            why not try doing something like this m8:

            I modded your code so you could get an idea of what to do.
            Attached Files

            Comment

            • mystica
              No longer a forum member
              • May 2007
              • 1548

              #7
              Originally posted by mwreyf1 View Post
              Now I see.

              This will probably be closer to what your looking for.

              No need to create the Links.txt before running.
              Thanks mwreyf1,

              I had a look at your first response last night, and although it's not quite what I'm looking for, I think your code will provide me with enough insight to be able to figure things out.

              I see you've attached a second example (many thanks) which I'll also look at later when I get home. Thankyou for your support.

              Comment

              • mystica
                No longer a forum member
                • May 2007
                • 1548

                #8
                Originally posted by mrdude View Post
                why not try doing something like this m8:

                I modded your code so you could get an idea of what to do.
                Thankyou mrdude,

                I've not had a look at your example yet as I have to wait until I get home but as both you and mwreyf1 have been so responsive to my question, I'm sure I'll be able to solve the problem using your code as exemplars.

                I'll get back to you both when I've had a chance to test things out.

                Cheers.

                Comment

                • RizlaUK
                  Indigo Rose Customer
                  • May 2006
                  • 5552

                  #9
                  if all you want to do is add the "HTTP://" to the string in the input object then there is no need to use String.Replace

                  eg:

                  Code:
                  strURL = Input.GetText("Input1")
                  -- make sure the http pars isent already added, if it isent then add it.
                  if String.Find(strURL, "HTTP://", 1, false) == -1 then
                  	strURL = "HTTP://"..strURL
                  end
                  
                  
                  -- Test
                  Dialog.Message("strURL", strURL);
                  Embrace change in your life, you never know, it could all work out for the best

                  Comment

                  • mystica
                    No longer a forum member
                    • May 2007
                    • 1548

                    #10
                    Originally posted by RizlaUK View Post
                    if all you want to do is add the "HTTP://" to the string in the input object then there is no need to use String.Replace

                    eg:

                    Code:
                    strURL = Input.GetText("Input1")
                    -- make sure the http pars isent already added, if it isent then add it.
                    if String.Find(strURL, "HTTP://", 1, false) == -1 then
                    	strURL = "HTTP://"..strURL
                    end
                    
                    
                    -- Test
                    Dialog.Message("strURL", strURL);
                    RizlaUK,

                    "http" was just an example. For actual useage, I'm requiring replacement of all kinds of characters. Thanks for your response though ... it's encouraging to receive input from the famous RizlaUK!

                    Comment

                    • mystica
                      No longer a forum member
                      • May 2007
                      • 1548

                      #11
                      mwreyf1 & mrdude,

                      Just getting back to you both regarding the help you provided me with and to give you both a huge Thankyou!

                      mwreyf1, the second example you posted was PERFECT! (exactly what I was looking for) ... so many thanks.

                      mrdude, many thanks to you also for taking mwreyf1's example one step further and producing something I would never even have thought of!

                      You've both saved me from weeks of banging my head against the wall, trying to figure it out on my own. So thanks to you guys, my problem is now solved! Only wish my level of coding experience was such that I could return the favour!

                      Comment

                      Working...
                      X