Attract-Mode Support Forum

Attract-Mode Support => Scripting => Topic started by: Arcadefan1 on February 11, 2018, 04:19:06 AM

Title: Need help with ".file_name.length ()" please
Post by: Arcadefan1 on February 11, 2018, 04:19:06 AM
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: [Select]
Picture [ "pic" ] <- surface.add_artwork (config "image",0,0,surface.width,surface.height)

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

Title: Re: Need help with ".file_name.length ()" please
Post by: Daeymon on February 11, 2018, 12:40:50 PM
Try:
Code: [Select]
if (Picture [ "pic" ].file_name.len() > 0)
{
    // do stuff
}
Title: Re: Need help with ".file_name.length ()" please
Post by: Arcadefan1 on February 11, 2018, 10:03:22 PM
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.