Page 1 of 1

A couple small problems

Posted: Sun Sep 07, 2008 10:58 pm
by pwdiener
I've discovered a couple small problems w/ the file_open built-in macro function. It appears that in spite of returning a bool (which I assume indicates success) that the function just fails quietly when it thinks the specified file does not exist, but reports success. I say "it thinks", because the second issue is that it does not appear to find files with .. in the path.

I was using the LUA code
local FileB = macro_tag("$FB")
local PSFName = macro_tag("$FDD").."..\\"..FileB..".psf"
local fop = file_open(PSFName)
if not fop then
message("Can't find PSF file "..PSFName)
to open a file related to the file I was editing, but got no error message but also no file opened. When I changed the line to:
local PSFName = string.sub(macro_tag("$FDD"),1,- 8 )..FileB..".psf"
it worked fine. The second version strips "Source\" off the end of $FDD so there is no need for the parent directory reference.

This was on 3.96q beta 8 - I haven't had a chance to verify it on my install of 3.96q at work.

Not exactly show stoppers... :?


Posted: Sun Sep 07, 2008 11:34 pm
by jussij
Hi Bill,

If you change this line of code:

Code: Select all

    if not fop then
to read as this:

Code: Select all

    if fop == 0 then
or this:

Code: Select all

    if fop ~= 1 then
then the macro works as expected :)

NOTE: The function definitely returns 0 on error and 1 on success.

So I am not 100% sure, but this looks like a but in the Lua not operator :?

In any case the file_open macro function has also been cleaned up a little bit ;)

Cheers Jussi