This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
SNWLeader's profile picture

fs.copy([["disk/]]..input..[[", "startup") Does not work?

Started by SNWLeader, 20 January 2013 - 12:51 PM
SNWLeader #1
Posted 20 January 2013 - 01:51 PM
I am trying to make a part in my system that will update when you get past a password protection and after that will copy the program file on a floppy and replace the one currently running, but i cannot get passed the error of startup:185: expected string, string

I understand what the startup:185: is I am giving the segment of the code that I am trying to get happen.

I need it to take the input given by the user and put it in this.

fs.copy("disk/[Userinput Here!]", "startup")

I tried doing it this way.
fs.copy([["disk/]]..input..[[", "startup]])

that does not work with this one.
theoriginalbit #2
Posted 20 January 2013 - 01:53 PM

fs.copy( "disk/"..input, "startup" )

you had a few misplaced " in the first one

and the second one… well…. [[ ]] dont work in that way…
Edited on 20 January 2013 - 12:53 PM
SNWLeader #3
Posted 20 January 2013 - 02:25 PM
Yep that worked just nicely. Thanks. :D/>
theoriginalbit #4
Posted 20 January 2013 - 02:32 PM
Yep that worked just nicely. Thanks. :D/>
No problems :)/>

Just as a note:
common usage of [[ ]] is to have a string formatted exactly as it is provided… for example

local handle = fs.open( filePath, "w" )
handle.write([[
This would write the following
text into the file exactly
how it appears here.

Optionally some other data can be added
by doing this ]]..someData..[[

That is all :)/>
]])
handle.close()