Jump to content




H.readAll() returning {} when written to it in the exact same program is something else

utility api

7 replies to this topic

#1 Famous5000

  • Members
  • 10 posts

Posted 21 May 2016 - 02:39 AM

Here is the code
http://pastebin.com/ifgypV4A
and the thing it's writing:
This is a test.
The thing it outputs:
{}
Any solutions?
NOTE: Please ignore the P == "No". It's not encrypted due to the fact that I don't care if it's breached or not.

#2 Waitdev_

  • Members
  • 432 posts
  • LocationWherever you want me to be

Posted 21 May 2016 - 02:55 AM

I can't find what line the problem is, but did you do H = fs.open("file","r")? With the "r" ?

#3 Dog

  • Members
  • 1,177 posts
  • LocationEarth orbit

Posted 21 May 2016 - 03:08 AM

Well, I noticed on lines 42, 45 and 56 you're using colon notation where you should probably be using dot notation. e.g....
Tr = D.readAll()

Take another look as the fs api (specifically fs.open) and double check all your read and write calls.

#4 Famous5000

  • Members
  • 10 posts

Posted 21 May 2016 - 08:07 PM

View PostDog, on 21 May 2016 - 03:08 AM, said:

Well, I noticed on lines 42, 45 and 56 you're using colon notation where you should probably be using dot notation. e.g....
Tr = D.readAll()

Take another look as the fs api (specifically fs.open) and double check all your read and write calls.
I look inside the FS api, and the FS.Open computercraft wiki entries before I posted this. Nothing seemed to help me out.
I've tried using both : and ., with both failing to write.

View PostWaitdev_, on 21 May 2016 - 02:55 AM, said:

I can't find what line the problem is, but did you do H = fs.open("file","r")? With the "r" ?
Yes I did.

Edited by Famous5000, 21 May 2016 - 08:08 PM.


#5 supernicejohn

  • Members
  • 98 posts
  • LocationSweden

Posted 21 May 2016 - 08:12 PM

I had this problem when saving an image to file, turns out I was using test:write instead of test.write, so I agree with Dog's comment.

Quote

I look inside the FS api, and the FS.Open computercraft wiki entries before I posted this. Nothing seemed to help me out.
I've tried using both : and ., with both failing to write.
Oh. thats weird =/

Edited by supernicejohn, 21 May 2016 - 08:15 PM.


#6 Dog

  • Members
  • 1,177 posts
  • LocationEarth orbit

Posted 21 May 2016 - 08:26 PM

View PostFamous5000, on 21 May 2016 - 08:07 PM, said:

I look inside the FS api, and the FS.Open computercraft wiki entries before I posted this. Nothing seemed to help me out.
I've tried using both : and ., with both failing to write.
Well, if you take a closer look at the wiki you will notice that all the examples use dot notation, not colon notation
Are you sure you changed all your write and read statements to use dot notation? How do you know nothing is being written? Are you viewing the written file directly with edit?

#7 Dragon53535

  • Members
  • 971 posts
  • LocationIn the Matrix

Posted 21 May 2016 - 08:29 PM

Tutorial

#8 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 22 May 2016 - 01:03 AM

View PostFamous5000, on 21 May 2016 - 08:07 PM, said:

I've tried using both : and ., with both failing to write.

Dog's still right, though. You're getting "{}" because you incorrectly used colon notation when you wrote that particular file. You need to switch ALL your fs API interactions to dot notation.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users