File IO won't delete txt file

Ask a Question related to Macromedia Director Lingo, Design and Development.

  1. #1

    Default File IO won't delete txt file

    Hi,
    I just wrote this script so that when I change something in a list in the projector, this list is saved in an external txt file..
    the problem only is, the delete function of File IO doesn't work properly (Or I'm doing something wrong..).
    But when I don't include the delete function, the list is correctly written to the file, but when the new list is shorter, it just overwrites the number of characters needed and leeves the remaining characters intact...

    example:

    old list: [1,2,3,4,5,6], new list: [1,2]

    when I write the new list to the text file the result looks like this:

    [1,2]3,4,5,6], but 3,4,5,6] should actually be gone..

    Does anyone know what I'm doing wrong??

    Tnx

    Eelco
    --
    This is my script:

    global list

    on writedown

    fName=the moviepath&"lists\data.txt"
    tekst=list.string
    io = new(Xtra "fileIO")
    io.openFile(fName, 0)
    io.deleteFile(fName)
    io.createFile(fName)
    io.openFile(fName, 0)
    io.writeString(text)
    io.closeFile()
    io = VOID

    castLib("fieldstorage").save(the moviePath & "fieldstorage.cst")

    end


    Eelco Heuvelmans webforumsuser@macromedia.com Guest

  2. Similar Questions and Discussions

    1. I can't delete file
      Dear all, I can't delete file.. When my hdd was full, my set was down... After rebooting, hdd error detected and repair file system. but 16 GB...
    2. How to delete a file from the file system
      Hi, Is there any module which has methods that can be used to delete a file from the filesystem in the windows NT environment. Thanks in...
    3. Delete File Asp.NET Error: File is used by another process
      Please, help! I have set Permission to Full Control to the user ASPNet_wp account to my Security folder. I have set UserName = "System"...
    4. cannot delete a file
      Charles, This is a network newsgroup, so how did this affect your network? The information you provide implies that the file is in a different...
    5. Delete a file while its in use
      Do a search from yesterday posted by "AR" entitled - Cannot delete certain MP3 & WMA files - There are several suggesstions posted. -- Harry...
  3. #2

    Default Re: File IO won't delete txt file

    seems strange to me. your script looks correct. just in case you won't get
    a workaround, try the "File4Xtra"

    [url]http://kblab.net/xtras/[/url]

    it's a free xtra and can do everything that the fileIO xtra can do, also
    has more functions like creating folders etc.



    On Thu, 4 Dec 2003 10:55:32 +0000 (UTC), Eelco Heuvelmans
    <webforumsuser@macromedia.com> wrote:
    > Hi,
    > I just wrote this script so that when I change something in a list in
    > the projector, this list is saved in an external txt file..
    > the problem only is, the delete function of File IO doesn't work
    > properly (Or I'm doing something wrong..).
    > But when I don't include the delete function, the list is correctly
    > written to the file, but when the new list is shorter, it just
    > overwrites the number of characters needed and leeves the remaining
    > characters intact...
    >
    > example:
    >
    > old list: [1,2,3,4,5,6], new list: [1,2]
    >
    > when I write the new list to the text file the result looks like this:
    >
    > [1,2]3,4,5,6], but 3,4,5,6] should actually be gone..
    >
    > Does anyone know what I'm doing wrong??
    >
    > Tnx
    >
    > Eelco
    > --
    > This is my script:
    >
    > global list
    >
    > on writedown
    >
    > fName=the moviepath&"lists\data.txt"
    > tekst=list.string
    > io = new(Xtra "fileIO")
    > io.openFile(fName, 0)
    > io.deleteFile(fName)
    > io.createFile(fName)
    > io.openFile(fName, 0)
    > io.writeString(text)
    > io.closeFile()
    > io = VOID
    >
    > castLib("fieldstorage").save(the moviePath & "fieldstorage.cst")
    >
    > end
    >
    >
    >
    Christian Grass Guest

  4. #3

    Default Re: File IO won't delete txt file

    you can't delete an opened file :

    fName=the moviepath&"lists\data.txt"
    tekst=list.string
    io = new(Xtra "fileIO")
    -- io.openFile(fName, 0) -- here
    io.deleteFile(fName)
    io.createFile(fName)
    io.openFile(fName, 0)
    io.writeString(text)
    io.closeFile()
    io = VOID

    hth
    --
    ----------------
    -- Ned
    ----------------------------------------
    Bien faire et laisser braire
    ----------------------------------------
    "Eelco Heuvelmans" <webforumsuser@macromedia.com> a écrit dans le message de
    news:bqn3r4$r64$1@forums.macromedia.com...
    | Hi,
    | I just wrote this script so that when I change something in a list in the
    projector, this list is saved in an external txt file..
    | the problem only is, the delete function of File IO doesn't work properly
    (Or I'm doing something wrong..).
    | But when I don't include the delete function, the list is correctly
    written to the file, but when the new list is shorter, it just overwrites
    the number of characters needed and leeves the remaining characters
    intact...


    Ned Guest

  5. #4

    Default Re: File IO won't delete txt file

    A quick look suggests that your line

    io.deleteFile(fName)

    is incorrect (I don't know why it doesn't give error), try

    io.delete()


    hth

    johnAq


    johnAq webforumsuser@macromedia.com Guest

  6. #5

    Default Re: File IO won't delete txt file

    tnx, it worked!


    Eelco Heuvelmans webforumsuser@macromedia.com Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139