-PROBLEM SOLVED- no further help needed.
Hey, I've got a script that when a file isn't found, instead of throwing an error and closing, it looks in another location, where the file definitely is, and moves the file to where it should be (I'm using this script to sort through my database, so I don't have a ~4gb game.)
The script works perfectly the first time an item isn't found, but after that it seems to not work, probably because the error method is calling itself, and that can't happen.
Anyway. This is used in conjunction with FileUtils.RB, a normal ruby method. This replaces the error handler in the main class.
The code works perfectly the first time each time the game is ran, how can I have it work multiple times each run?
Hey, I've got a script that when a file isn't found, instead of throwing an error and closing, it looks in another location, where the file definitely is, and moves the file to where it should be (I'm using this script to sort through my database, so I don't have a ~4gb game.)
The script works perfectly the first time an item isn't found, but after that it seems to not work, probably because the error method is calling itself, and that can't happen.
Anyway. This is used in conjunction with FileUtils.RB, a normal ruby method. This replaces the error handler in the main class.
Code:
rescue Errno::ENOENT
# Supplement Errno::ENOENT exception
# If unable to open file, display message and end
p $!.to_s
filename = $!.message.sub("No such file or directory - ", "")
$dest = "D:/Project3/" + filename
slashes = $dest.count "/"
loop do # Truncates the end of the string at the slash
$dest = $dest.chop
slashe = $dest.count "/"
if slashes != slashe
$dest = $dest + "/"
break
end
end
t = 0
loop do #This loop affixes the extension to the file, checking which extension is proper.
newfileloc = "D:/Project3/2/" + filename
t +=1
case t
when 1
newfileloc += ".mp3"
when 2
newfileloc += ".wav"
when 3
newfileloc += ".ogg"
when 4
newfileloc += ".mid"
when 5
newfileloc += ".jpg"
when 6
newfileloc += ".png"
when 7
newfileloc += ".bmp"
end
if FileTest.exist?( newfileloc ) == true
FileUtils.mv(newfileloc, $dest)
break
else
end
end
while $scene != nil
$scene.main
end
end
The code works perfectly the first time each time the game is ran, how can I have it work multiple times each run?