3 Replies Latest reply on Sep 27, 2006 2:20 AM by Newsgroup_User

    converting text to a variable

    Level 7
      Hi,

      I'm creating a mini database using external text files. The data is just
      a timetable which I want the user to edit:
      course, lecturer, room, day, time

      My text file will have:
      ["course": "history", "lecturer":"Mr Surname", "room": "G100", "day":
      Monday, " time":"12-2pm"]

      I have loaded the text into Director using fileIO but it loads:
      "["course": "history", "lecturer":"Mr Surname", "room": "G100", "day":
      Monday, " time":"12-2pm"]"

      How can I convert that into just the property list so I can start
      extracting stuff from it.

      Also, while I'm asking, I'm having a list for each day of the week. Was
      orginally thinking of having separate text files for each day. Now amd
      juts thinking one text file with multiple lists. However, I want to be
      able to save one record. Is it 'simple' to open a text file and just
      replace one line of that text file? Any advice on that would be
      appreciated. It may be easy once I know how. I'm a bit sick today so not
      thinking very clearly.

      Hope all taht makes sense.

      Thanks for any help.

        • 1. Re: converting text to a variable
          Level 7
          > I have loaded the text into Director using fileIO but it loads:
          > "["course": "history", "lecturer":"Mr Surname", "room": "G100", "day":
          > Monday, " time":"12-2pm"]"
          >
          > How can I convert that into just the property list so I can start
          > extracting stuff from it.

          You use the value() function:
          tList = value(aListAsString)
          • 2. Re: converting text to a variable
            Level 7
            Thanks Sean. All working now.

            I've got the loading working, now just have to get the saving working.




            • 3. Re: converting text to a variable
              Level 7
              Hi,

              you can look into propsave.X32. This is an xtra that reads/writes binary
              data instead of strings. No need to do the value() conversion.

              it's at:
              http://pimz.com/?id=xtras&section=propsave

              About the saving of data for just onde day, I wouldn't worry about the
              overhead that comes with saving the rest of the week with it.

              But OTTOMH you can use setPosition() or something similar (type: put
              Xtra("Fileio").new.interface() in the messagewindow) to define a
              position to start writing. Risk is that data for tuesday is suddenly
              longer than it used to be and you'll overwrite data of wednesday...

              Manno

              uni-student wrote:
              > Thanks Sean. All working now.
              >
              > I've got the loading working, now just have to get the saving working.
              >
              >
              >
              >

              --
              ----------
              Manno Bult
              manno@xs4all.nl