LiveCode Crashing

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
NigelS
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 83
Joined: Sat Oct 22, 2011 2:37 pm

LiveCode Crashing

Post by NigelS » Sun May 13, 2012 8:05 am

I'm a little frustrated as my application keeps crashing. I have two cards, the one picks a file and the other just displays it. I've attached some screen shots. Iv'e had a few issues with the following command and was wondering if this is not a problem within live code itself.

Code: Select all

on preOpenCard
   
   put the cMessageTitle of this stack into tMessageTitle
   put tMessageTitle into field "MessageTitle"
   
   put url("file:" & tMessageTitle ) into tMessageFileContents
   set the rtftext of fld "theMesage" to tMessageFileContenrs
   
end preOpenCard

specifically these two lines

Code: Select all

   
   put url("file:" & tMessageTitle ) into tMessageFileContents
   set the rtftext of fld "theMesage" to tMessageFileContents
Has anyone had problems with this at all? And if so, is there a work around.

NigelS
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 83
Joined: Sat Oct 22, 2011 2:37 pm

Re: LiveCode Crashing

Post by NigelS » Sun May 13, 2012 9:07 am

mmm can't get the screens attached for some reason

Klaus
Posts: 14213
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: LiveCode Crashing

Post by Klaus » Sun May 13, 2012 11:48 am

Hi Nigel,

of course LiveCode should NOT crash in any case!

Is this on Mac or Windows?

Are you sure that the file is where you exspect it?
Your snytax requires that the file is in the current defaultfolder, whereever that may be!

Try this:

Code: Select all

...
if there is a file tMessageTitle then
   put url("file:" & tMessageTitle ) into tMessageFileContents
   set the rtftext of fld "theMesage" to tMessageFileContenrs
else
  put "No file!" into fld  "theMesage"

  ### Check here where you really are:
  answer the directory
end if
...
OK, so the question is where is the current defaultfolder?
Or where do you exspect it to be?

You should construct absolute pathnames whenever possible,
especially when you don't know your current relative "position".


Best

Klaus

NigelS
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 83
Joined: Sat Oct 22, 2011 2:37 pm

Re: LiveCode Crashing

Post by NigelS » Tue May 15, 2012 4:02 am

It's on a MAc. Been playing around a little more and have found the sequence of events that leads to the crash. It's to do with the way the Stack open the second time around. The data is kept within the properties when executing the application. The directory location losses its place. I can accept that it's the way I've coded it, but what does surprise me is that there is no exception thrown by the engine.

O! well, we live and learn.

Klaus
Posts: 14213
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: LiveCode Crashing

Post by Klaus » Tue May 15, 2012 8:52 am

Hi Nigel,
NigelS wrote:The data is kept within the properties when executing the application.
You mean custom properties?
NigelS wrote:The directory location losses its place.
Sorry, I have noi idea what you are talking about, could you please explain?


Best

Klaus

NigelS
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 83
Joined: Sat Oct 22, 2011 2:37 pm

Re: LiveCode Crashing

Post by NigelS » Tue May 15, 2012 5:18 pm

Hi Klaus

When data (text) is entered into a field and you close the application and start it again, the data (text) is still in the property. I have a field that contains the directory location of where the RTF files are.

The following code is excecuted on pressing a button (obvious) and "defaultFolder" is set.

Code: Select all

on mouseUp
   
   ClearVariables
      
   local tFolder
   answer folder "Please choose folder"
   put it into tFolder
   if there is no folder tFolder then exit mouseUp
   
   put tFolder into field "Folder"
   put listFiles(currentFolder()) into field "Result"
   
   set the defaultFolder to "Folder"
   
   focus on fld "Result"
   
end mouseUp


Having done that then the user selects a RTF file that is shown in a list. The following code is executed.

Code: Select all


on mouseUp
   ActivatePreviewMessage
end mouseUp

Code: Select all

command ActivatePreviewMessage
   
   get the selectedText of field "Result" 
   put it into tMessageTitle
   
   put url("file:" & tMessageTitle ) into tMessageFileContents
   set the rtftext of fld "TheMessage" to tMessageFileContents
   
end ActivatePreviewMessage
My problem seems to stems from the "defaultfolder" property. I made an assumption which was incorrect. The manual does make a mention of a "gotcha" and that "gotcha" got me. :shock:

Anyway, thanks for your assistance.

Nigel

Klaus
Posts: 14213
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: LiveCode Crashing

Post by Klaus » Tue May 15, 2012 6:34 pm

Hi Nigel,

I guess this line caused the "hickup":
...
set the defaultFolder to "Folder"
...
doesn't make any sense and Liveocde did not like it, too ;-)

But again, try to avoid using/setting "the defaultfolder", there will always be a possibility to create any ABSOLUTE pathname!

AND you should really do some checks:
...
if the selectedText of field "Result" <> EMPTY then
### do your stuff
## otherwise you don't know what might happen!
...
When data (text) is entered into a field and you close the application and start it again, the data (text) is still in the property.
When you quit a standalone then NOTHING will be left in the field or property!??
Or am I misunderstanding you here?


Best

Klaus

NigelS
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 83
Joined: Sat Oct 22, 2011 2:37 pm

Re: LiveCode Crashing

Post by NigelS » Fri May 18, 2012 4:03 am

Your right on all point, and, Yea! I should do more checks. :oops:

Post Reply