Andromo - Start Making Apps - Free Signup

Announcement

Collapse

New Forum Software

If you're here, you've found the new home for our forums. There will be some bugs to iron out, so thanks for your patience...
See more
See less

String.Replace in a .htm file

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #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


    • #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


      • #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