Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    File Manipulation Help

    Advanced
    seek help file manipulati eof file
    3
    5
    592
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      HeavyByte last edited by

      There doesn't seem to be very much documentation on file manipulation and I had a couple questions:

      1. How do you clear a file?

      I tried to write a char(0) , \0, \z but none of them clear out the data of the file or at the location they are being written.

      1. Can you seek by line?

      It would be nice to seek by line but I don't think this is an option. Do I just need to write a function that iterates through every char, counting the number of new line chars until it reaches the desired line?

      1. Is there any way to tell where the end of the file is?

      Does Fuze implement an EOF char or a way to access the number of chars in a file? When reading a file I have no idea when to stop.

      Thank you for any help 😊

      1 Reply Last reply Reply Quote 1
      • pianofire
        pianofire Fuze Team last edited by

        Not currently. I write a count at the start to record the number of records in the file. Take a look at this post: https://fuzearena.com/forum/topic/781/persistent-data

        1 Reply Last reply Reply Quote 2
        • L
          LucasJG25 last edited by

          To clear a file. You'll need to substitute a character for a NULL. Therefore if you use "#" as the substitute you'll need to ignore that character when reading from the file. If you want to read line by line, you'll need to put the read() function within a loop and read one char at a time until you reach a char(10) which will end the loop and concatenate the read chars to a string. Then repeat. When storing the length of the file. You could utilize the first 5 chars of a file or how many you need to store data about the current file. Such as file size, where the cursor should be, etc.

          H 1 Reply Last reply Reply Quote 0
          • H
            HeavyByte @LucasJG25 last edited by

            @LucasJG25 that seems like a lot to manage for simple file manipulation. Isn't EOF and Null chars the foundation of any file read/write implementation?
            This would get really sloppy especially when I am still in the process of developing and don't know the exact structure of my file. Now I just have this big file with a bunch of "#" in it?

            L 1 Reply Last reply Reply Quote 1
            • L
              LucasJG25 @HeavyByte last edited by

              @HeavyByte That is true, though for now we have to make do with what we can come up with so far. But I'm sure the Fuze team have these issues in mind and will make improvements in later patches.

              1 Reply Last reply Reply Quote 2
              • First post
                Last post