Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
ackley14

Create new file at runtime?

Question

Posted

So i'm working on a super simple logs library to make outputting errors/messages to a log alot simpler in a different program i'm working on. The issue is that i am completely unable to find a way to create a new file inside of code!

 

I remember in computercraft it was simply trying to open a file that didn't exist yet, would create a new one. but for some reason, it's not doing it in this instance.

 

my code is roughly:

local fname = "output.txt"
local file, err = io.open(fs.concat(shell.getWorkingDirectory(),"/logs/",fname),w)--i've tried both w and a

at this point i'm really not sure what i'm doing wrong! is there a specific function to create a new file? make directory only lets you create folders from what my experiences/documentation has said.

2 answers to this question

Recommended Posts

  • 0
Posted
5 hours ago, Gorzoid said:

Assuming you are require'ing the io and fs table, your only problem is that you need to put the w/r inside quotes, like "w"

OH....i'm dumb....thankya. forgot that it defaults to r if no w/a is present and...without quotes..its not v.v. thanks kind stranger! ;_;

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.