Check file exist after load stack.

LiveCode Builder is a language for extending LiveCode's capabilities, creating new object types as Widgets, and libraries that access lower-level APIs in OSes, applications, and DLLs.

Moderators: LCMark, LCfraser

Post Reply
Marken
Posts: 6
Joined: Thu Apr 10, 2014 3:34 am

Check file exist after load stack.

Post by Marken » Sat Apr 09, 2016 9:42 am

I wrote a widget with a property to set image file to show.
I don't want to save pixels data of image in stack. Instead, I just save the path information of the image file.
So after load stack, the widget need to check if the file exists.
Now I use " execute script "return there is a file" " to check file path.
But OnLoad(), OnAttach(), OnPaint() all can't use script object to execute script.
So anyone have other suggestions to check file path after load widget ( after open stack).

livecodeali
Livecode Staff Member
Livecode Staff Member
Posts: 192
Joined: Thu Apr 18, 2013 2:48 pm

Re: Check file exist after load stack.

Post by livecodeali » Mon Apr 11, 2016 2:21 pm

Hi Marken,
You could do such a thing in the widget's OnOpen handler.

livecodeali
Livecode Staff Member
Livecode Staff Member
Posts: 192
Joined: Thu Apr 18, 2013 2:48 pm

Re: Check file exist after load stack.

Post by livecodeali » Mon Apr 11, 2016 2:22 pm

Alternatively you could use LCB's the entries of directory <directory> operator to check if the file exists.

Marken
Posts: 6
Joined: Thu Apr 10, 2014 3:34 am

Re: Check file exist after load stack.

Post by Marken » Tue Apr 12, 2016 2:01 am

livecodeali wrote:Hi Marken,
You could do such a thing in the widget's OnOpen handler.
good, I never test OnOpen() handler. Thank you.

Marken
Posts: 6
Joined: Thu Apr 10, 2014 3:34 am

Re: Check file exist after load stack.

Post by Marken » Tue Apr 12, 2016 2:04 am

livecodeali wrote:Alternatively you could use LCB's the entries of directory <directory> operator to check if the file exists.
the entries of directory will crash with some path at Windows platform. Other other hand, if the <directory> does not exist and what will happen?
Thank you for your information.

Post Reply

Return to “LiveCode Builder”