Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    May 2007
    Location
    Sydney, Australia
    Posts
    1,546

    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.

  2. #2
    Join Date
    Aug 2004
    Location
    Somewhere in Texas, USA
    Posts
    417
    What is the purpose of the Input object?

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

  3. #3
    Join Date
    Aug 2004
    Location
    Somewhere in Texas, USA
    Posts
    417
    Try this.

    It should get you started.
    Attached Files

  4. #4
    Join Date
    May 2007
    Location
    Sydney, Australia
    Posts
    1,546
    Quote 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.

  5. #5
    Join Date
    Aug 2004
    Location
    Somewhere in Texas, USA
    Posts
    417
    Now I see.

    This will probably be closer to what your looking for.

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

  6. #6
    Join Date
    Jun 2004
    Posts
    113
    why not try doing something like this m8:

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

  7. #7
    Join Date
    May 2007
    Location
    Sydney, Australia
    Posts
    1,546
    Quote 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.

  8. #8
    Join Date
    May 2007
    Location
    Sydney, Australia
    Posts
    1,546
    Quote 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.

  9. #9
    Join Date
    May 2006
    Posts
    5,380
    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);
    Open your eyes to Narcissism, Don't let her destroy your life!!

  10. #10
    Join Date
    May 2007
    Location
    Sydney, Australia
    Posts
    1,546
    Quote 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!

  11. #11
    Join Date
    May 2007
    Location
    Sydney, Australia
    Posts
    1,546
    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!

Similar Threads

  1. Another tough one... Interaction between Web and AMS
    By Agent Jones in forum AutoPlay Media Studio 5.0
    Replies: 13
    Last Post: 08-18-2005, 02:10 PM
  2. Function : Validate String (Great for passwords, etc.)
    By Corey in forum AutoPlay Media Studio 5.0 Examples
    Replies: 3
    Last Post: 04-28-2005, 02:42 AM
  3. Function: Convert boolean value to string
    By Desmond in forum AutoPlay Media Studio 5.0 Examples
    Replies: 0
    Last Post: 05-07-2004, 01:14 PM
  4. replace a character in a string
    By boudie in forum Setup Factory 6.0
    Replies: 7
    Last Post: 06-10-2003, 08:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts