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

[SOLVED] bios:364: Expected string, string

Started by ValorCat, 12 April 2014 - 12:51 AM
ValorCat #1
Posted 12 April 2014 - 02:51 AM
I've been working on a simple custom shell lately, however I get a BIOS error when I try to verify that the file being executed by the user actually exists. The error appears to be occurring around line 170 (at fs.exists())

Here's a link to the full program: http://pastebin.com/styTtmzH

bios:364 is the part of loadfile() that calls fs.open(), so I presume the error means fs.open() did not receive a string as its first argument (the file name). However, I've checked with type() to assure that v and file (the arguments being passed to fs.exists()) are both strings.

It's been a while since I've done much with Lua, as I'm currently in the process of learning Java, so any help or advice would be appreciated. Thanks!
Edited on 12 April 2014 - 03:45 PM
CometWolf #2
Posted 12 April 2014 - 10:08 AM
line 364 in BIOS is actually os.run.

function os.run( _tEnv, _sPath, ... )
	local tArgs = { ... }
	local fnFile, err = loadfile( _sPath )
	if fnFile then
		local tEnv = _tEnv
		--setmetatable( tEnv, { __index = function(t,k) return _G[k] end } )
  setmetatable( tEnv, { __index = _G } )
		setfenv( fnFile, tEnv ) --this line
		local ok, err = pcall( function()
		 fnFile( unpack( tArgs ) )
		end )
		if not ok then
		 if err and err ~= "" then
		  printError( err )
		 end
		 return false
		end
		return true
	end
	if err and err ~= "" then
  printError( err )
end
	return false
end
Though from what i can tell, that line shouldn't be the cause of the error, or even the error you got at all.
What version of CC are you running? im on 1.58

Edit: Facepalm!

			    os.run(env, input)
input is your argument table, no? Shouldn't that be file? Also, quikc note, all fs functions use absolute paths, meaning that this

		    if fs.exists(v..file) and not fs.isDir(file) then
will probably not execute as desired :P/>
Edited on 12 April 2014 - 08:12 AM
ValorCat #3
Posted 12 April 2014 - 05:44 PM
I was just thinking this morning that I didn't actually know why I thought the error was on that line. Also, I'm not sure how I managed to both get the wrong line and look at the wrong part of the BIOS, but I appreciate the help.

Also, you're right, I forgot to add 'v..' in fs.isDir(). Thanks!