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

Replace string help please

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

  • Replace string help please

    Hi guys, can anyone tell me how to do this?

    Ok I have a document with a certain string value inside it, I then want to make APMS open that document, find the string and then replace it with one from an input box and then save/replace the document with the value from the input box.

    How do I go about this - I'm using the demo of APMS 6 but can't find any examples.

    Thanks.

  • #2
    Hi. What format is your "document"?

    Comment


    • #3
      Originally posted by Corey
      Hi. What format is your "document"?

      It's a html web page that has some text in it that I want to be able to change using a database, basically I select an entry in the database and it is then shown in an input box - from the input box I want the enrty to be writen to the html page so that the next time the page is loaded the new text value from the database is shown.

      I already have the database working fine and putting the entries in the input box - I am stuck on the searching for a string value part in the html document and then replacing it with the new value from the database.
      Last edited by mrdude; 09-18-2005, 11:07 AM.

      Comment


      • #4
        Try this

        Code:
        -- Load in your html file
        SourceFile = TextFile.ReadToString("Path and file name of your html file.html")
        
        -- Find and replace the text
        OutPutFile = String.Replace("SourceFile", "Text To Replace", "Text to replace with", false)
        
        -- Save the file
        TextFile.WriteFromString(OutPutFile, "Path and file name to save as.html", false)
        Dermot

        I am so out of here :yes

        Comment


        • #5
          Thanks - Got it working with this:

          Code:
          -- Load in your html file
          SourceFile = TextFile.ReadToString("AutoPlay\\Docs\\page1.htm")
          
          -- get the data from our input fields
          text1 = Input.GetText("Inputmac");
          
          -- Find and replace the text
          result = String.Replace(SourceFile, "000123456789", text1, false);
          
          -- Save the file
          TextFile.WriteFromString("AutoPlay\\Docs\\page2.htm", result, false)
          
          -- Reload web page ---
          Web.LoadURL("Web1", "AutoPlay\\Docs\\page2.htm");

          Comment

          Working...
          X