3 Replies Latest reply on Jun 8, 2008 10:56 AM by aldus

    fileio

    bmohnsen3 Level 1
      Here is a script that I have been using prior to Director 11 - in order to make demo versions of my software - but it doesn't seem to work in Director 11 --- also any suggestions on a better demo method are welcome:
      ---Demo script
      on startMovie
      myFile = new(xtra "fileio")
      myPath = the moviePath&"xxyy.txt"

      openFile(myFile, myPath, 0) -- read/write access

      myVar = readFile(myFile)
      if voidP(myVar) then
      -- The file does not exist. Create it and open it.
      createFile (myFile, the moviePath &"xxyy.txt")
      openFile(myFile, myPath, 0) -- read/write access
      myVariable = 0

      else
      set myVariable = integer(myVar)
      end if

      if myVariable > 4 then
      alert("Sorry, this demo has expired.")
      halt -- doesn't quit Director at authortime
      end if

      set myVariable = myVariable + 1

      setPosition(myFile, 0) -- overwrite the beginning of the file
      writeString(myFile,string(myVariable))

      closeFile(myFile)
      myFile = 0
      end
        • 1. fileio
          aldus Level 1
          Instead of using fileIO to store only one (!) value i would
          prefer "getPref" and "setPref" to handle this situation. F. ex. like in
          the way of the attached one.

          Regards
          Aldus
          • 2. Re: fileio
            bmohnsen3 Level 1
            I am familiar with that and it does seem to be a better option - but I am on a Mac OSX10.5 and when I use it - the file use_counter is not created - I do a search for it?

            Any thoughts?
            • 3. fileio
              aldus Level 1
              The pref-file "use_counter" is created - but not beisde the projector,
              in the pref folder of director/shockwave - and, as far as i know, hidden;
              somewhere inside "user/var/sbin ..." - whatever ...

              Keep in mind that "getPref" and "setPref" works cross-plattform and
              is shockwavesave - instead of fileIO.

              -- Addition: after reading you code again i regonize the mixed of old and new syntax and clean
              it a little bit ... tested with Director 11 on MacOs 10.5.3 - if the problem still exists, try
              to check your userPermissions.

              Regards
              Aldus