Page 1 of 1

LiveCode crashes with wait command

Posted: Thu Jun 04, 2015 4:50 pm
by matthellstrom
I'm trying to do something, not sure I've got the right way to do it. I have a search box, I automatically want to run an external db command when they enter something in the search box, but I want it to wait a little so it doesn't try to do it after every character. So I used a wait command, but now if I type in a search term of 5 or 6 characters it crashes. I'm not sure it that's the problem. It actually finishes the command and does the db access, but when it loads the table it crashes. It doesn't crash when I change other parameters using a dropdown box.

Here's the code I use. Please let me know if you need anything else, or give me another idea how to do it.

on textChanged
wait 1 second with messages
set the uCurrentSearchTerm of me to the text of me
call loadItemTable
end textChanged

Re: LiveCode crashes with wait command

Posted: Thu Jun 04, 2015 6:02 pm
by matthellstrom
More experimenting, I don't think it has to do with the wait. I think it has to do with keying in multiple characters and doing a db access that takes a little while. If I put in one character, wait for it to finish, put in another, wait for it to finish, etc. It works fine. It's just if I put in more than one character. Can anyone give me an idea how to do this differently? I can use a search button so it doesn't do anything until they say go, I just thought it would be cool to do it automatically.

Re: LiveCode crashes with wait command

Posted: Mon Jun 08, 2015 3:38 pm
by MaxV
I'd split the code this way:

Code: Select all

on textChanged
  searchdb
end textChanged

on searchdb
  wait 1 second with messages
  set the uCurrentSearchTerm of me to the text of me
  call loadItemTable
end searchdb

Re: LiveCode crashes with wait command

Posted: Mon Jun 08, 2015 3:53 pm
by FourthWorld
If that's happening in the current version it may be helpful if you can spare a moment to file a bug report. No scripting engine should ever crash. Most do now and then, but if we stay on top of such reports we can bring that ever closer to zero.

Re: LiveCode crashes with wait command

Posted: Mon Jun 08, 2015 7:47 pm
by matthellstrom
MaxV wrote:I'd split the code this way:

Code: Select all

on textChanged
  searchdb
end textChanged

on searchdb
  wait 1 second with messages
  set the uCurrentSearchTerm of me to the text of me
  call loadItemTable
end searchdb
This way does the same thing. If I key in one letter and wait for it to read, it works fine. More than one it crashes.

Re: LiveCode crashes with wait command

Posted: Mon Jun 08, 2015 8:29 pm
by matthellstrom
Here's a super simple stack that I created. If you type in 1 character, it works. If you type in more than one, after you click on ok in the dialog box it crashes.

Re: LiveCode crashes with wait command

Posted: Mon Jun 08, 2015 8:59 pm
by FourthWorld
May be platform-specific: using v7.0.5 on Ubuntu 14.10 I can type as many characters as I like, slow or fast, and it seems to work just fine.

Re: LiveCode crashes with wait command

Posted: Mon Jun 08, 2015 9:02 pm
by matthellstrom
Maybe I'll try it standalone on Windows, that's what I'm going to be deploying it on.

Re: LiveCode crashes with wait command

Posted: Mon Jun 08, 2015 10:15 pm
by matthellstrom
I tried it on Windows standalone and it works perfectly. Does this happen often where something works on one platform but not on another? I submitted a bug report.