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

Help with a program to copy a program from a disk drive?

Started by Haland, 24 June 2013 - 02:22 AM
Haland #1
Posted 24 June 2013 - 04:22 AM
What is wrong with this code?


  local copyId= disk.getLabel("left")
if disk.isPresent("left") then
   print("Downloading "..copyId)



   fs.copy("disk/" ..copyId, copyId.." ")

print(copy)
end

it says
line 6( the fs.copy line) 'No such file'
idk how to fix this :/ any help would be nice.. and sorry for the terrible layout of this message :(/>/>
Edited by
Lyqyd #2
Posted 24 June 2013 - 01:16 PM
Split into new topic.

What does the program output before the error? What is the label of the disk? What files are on the disk?
H4X0RZ #3
Posted 25 June 2013 - 04:32 PM
Mybe there isn't a file with the Disks label on it…
Zambonie #4
Posted 25 June 2013 - 08:44 PM
Alright I see the prob. In terms of how you use your program your way, it's illeagal. Im seeing that you want a copy program so, I really kinda made it simpler to use. Heres a guide to use it: When it askes you for the item to copy, just copy down the path(ex:disk/file/file/image.nfp or something). And for when for where to paste it, paste the path like befor and always put down what you want to name the copy at the end.
Here it is:

--local copyId = disk.getLabel("left")
--if disk.isPresent("left") then
print("What do you want to copy?")
copy = read()

print("Type in where you want to copy the program to:")
location = read()

   print("Downloading "..copy)



   fs.copy(copy,location)

print("Copy done!")
end

Or for pastebin for easy download:
txwkA9Lw

Give me a thumbs up(1+) if this helped!
1lann #5
Posted 26 June 2013 - 11:52 AM

local copyId= disk.getLabel("left")
if disk.isPresent("left") then
   print("Downloading "..copyId)
   if fs.exists("/disk/" .. copyId) then
	 fs.delete("/" .. copyId)
	 fs.copy("/disk/" ..copyId, "/" .. copyId)
   else
	 print("Error: Could not find ", copyId, " on disk!")
   end
end
-- print(copy) What's this for???
end
H4X0RZ #6
Posted 26 June 2013 - 11:56 AM
^
The print(copy) will crash because there isn't a variable called "copy"!
Lyqyd #7
Posted 26 June 2013 - 12:37 PM
No, it would print "nil", not crash. If it weren't commented out.
MudkipTheEpic #8
Posted 26 June 2013 - 07:13 PM
It would print nothing if it was nil, just make a new line.