String.Replace in a .htm file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Jim Smiley
    Indigo Rose Customer
    • Nov 2001
    • 39

    String.Replace in a .htm file

    Hi all;

    I'm trying to update a .htm file with info the user provides. Found this code in the Forum and it works well.


    -- Load in your html file
    SourceFile = TextFile.ReadToString("AutoPlay\\Docs\\FMP.htm")

    -- get the data from our input fields
    text1 = Input.GetText("Input1");

    -- Find and replace the text
    result = String.Replace(SourceFile, "Pers_Chrg", text1, true);

    -- Save the file
    TextFile.WriteFromString("AutoPlay\\Docs\\FMP2.htm ", result, false)


    Problem is I need to replace several sections of the SourceFile (Pers_Chrg, Address1, Address2, City, State, Zip, Phone, etc.)

    Am I going about this the "right" way? How would one go about getting all the info into the file?

    Regards

    Jim Smiley
  • TJ_Tigger
    Indigo Rose Customer
    • Sep 2002
    • 3159

    #2
    Yes you are going about it correctly.

    Read the html file to a string.
    Make your replace actions on the string
    Write the string out to a file.

    Tigg
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

    Comment

    • Desmond
      Indigo Rose Staff Member
      • Jul 2003
      • 710

      #3
      Hello,

      Attached is an example i cooked up. May not be the world's best (if you have a LOT of values, a table at the beginning and a loop would probably be better -- easier updates), but it works!!
      Attached Files

      Comment

      • Jim Smiley
        Indigo Rose Customer
        • Nov 2001
        • 39

        #4
        Desmond;

        Thanks. I was having trouble with the order in which to place the data. Your example tells me what I was missing.

        I do have quite a bit of data so look forward to "Table" questions in the near future.

        Regards;

        Jim Smiley

        Comment

        Working...
        X