4 Replies Latest reply on Sep 12, 2007 8:16 AM by Chunick

    Retaining formating of text when write new file with FILEIO

    wgb14 Level 1
      Hi all,

      I wonder if there is any way to retain the formating of the text when I write it in a new file using FILEIO. In particular I have the following text in a field member:

      test <background = L1_garaz/> (text in the tag has color and itsbold) test


      I use the following code to write the above text in a new filw using FILEIO:

      on mouseup


      annot = member("annotator").text
      path = the moviepath & "Annotated_text\"
      whichanno = baGetFilename( "Save", ""&path&"", "", "doc files|*.doc", 0, "Save doc file", 0, -2, 0 )

      myanott = new(xtra "FileIO")

      myanott.createfile(whichanno) --create
      myanott.openFile(whichanno,0)
      writeString(myanott,annot) --write the new string
      myanott.closeFile()
      myanott = VOID

      end

      the problme is that despite the type of file that i will choose to save it (.doc, txt , etc) it refuses to save the text with its initial formating (with the color, and bold words). Any idea how to solve this?
        • 1. Re: Retaining formating of text when write new file with FILEIO
          Level 7

          "wgb14" <webforumsuser@macromedia.com> wrote in message
          news:fc7nf2$av3$1@forums.macromedia.com...
          > Hi all,
          >
          > I wonder if there is any way to retain the formating of the text when I
          > write
          > it in a new file using FILEIO. In particular I have the following text in
          > a
          > field member:
          >
          > test <background = L1_garaz/> (text in the tag has color and itsbold)
          > test
          >
          >
          > I use the following code to write the above text in a new filw using
          > FILEIO:
          >
          > on mouseup
          >
          >
          > annot = member("annotator").text
          > path = the moviepath & "Annotated_text\"
          > whichanno = baGetFilename( "Save", ""&path&"", "", "doc files|*.doc", 0,
          > "Save doc file", 0, -2, 0 )
          >
          > myanott = new(xtra "FileIO")
          >
          > myanott.createfile(whichanno) --create
          > myanott.openFile(whichanno,0)
          > writeString(myanott,annot) --write the new string
          > myanott.closeFile()
          > myanott = VOID
          >
          > end
          >
          > the problme is that despite the type of file that i will choose to save it
          > (.doc, txt , etc) it refuses to save the text with its initial formating
          > (with
          > the color, and bold words). Any idea how to solve this?
          >

          What file format do you use to save the text?
          Of course you need to use an appropriate file-format, or invent your own.

          Maybe try HTML or RTF.

          Richard.


          • 2. Re: Retaining formating of text when write new file with FILEIO
            McFazstp
            If you want the formatting try saving the rtf of the member

            annot = member( "annotator" ).rtf

            Save the file with rtf extension.
            • 3. Re: Retaining formating of text when write new file with FILEIO
              wgb14 Level 1
              Nop, its says property not found rtf. Then if will save as an rtf (without changing to proprty of the member("annotator") again it won't keep the formmat of the main text
              • 4. Re: Retaining formating of text when write new file with FILEIO
                Chunick Level 3
                Use a text member instead of a field member then you can access the formatting of the text thru .rtf property... then, save that info to a file:
                annot = member("annotator").rtf
                .....
                ...
                writeString(myanott,annot) --write the new string

                quote:

                Originally posted by: wgb14
                Nop, its says property not found rtf. Then if will save as an rtf (without changing to proprty of the member("annotator") again it won't keep the formmat of the main text

                quote:

                In particular I have the following text in a field member: