Attract-Mode Support > Scripting

Need help with ".file_name.length ()" please

(1/1)

Arcadefan1:
Can someone please tell me why my code doesn't work? I want to do stuff when the length of a filename is larger then zero. Basically it should do stuff if the file is existing... the "if" statement always equals zero. Can someone tell me how to get the length of the filename?


--- Code: ---Picture [ "pic" ] <- surface.add_artwork (config "image",0,0,surface.width,surface.height)

If Picture [ "pic" ].file_name.length() > 0
{
// do stuff
}


--- End code ---

Daeymon:
Try:

--- Code: ---if (Picture [ "pic" ].file_name.len() > 0)
{
    // do stuff
}

--- End code ---

Arcadefan1:
Ah, ok. I wrote the lines from my memory here, so I guess I just forget the braces. Sorry. I think it has something to do with the way it references to the table "pictures". The code works, when used on a normal variable. But thx for pointing it out.

Navigation

[0] Message Index

Go to full version