Page 1 of 1

libraries not available?! and livecode hang

Posted: Thu Jan 05, 2012 11:08 pm
by kcorey
Hi All,

I'm sure I'm doing something silly here (hence this forum), could someone clue me in?

Just for context: Mac OSX 10.6.8, LiveCode 5.0.2, iPad 2 5.0.0, Xcode 4.2

I've got a tiny project. Doesn't even do anything much yet, as I was just playing with iOS features...but there are two strange things:
1) iphoneHideStatusBar (and all other iOS specific libraries) don't seem to be available unless the code is being tested in the simulator or on a real device. Must I always wrap specific function calls in an if statement like below?
if the platform is "iphone" then
do something
end if
if the environment is "mobile" then
do a mobile thing
end if
if the platform is "Win32" then
do the other thing
end if

I guess I could:
switch the environment
case "mobile"
doBlah
default
doNonBlah
end switch

Still, it's got the same smell as littering #ifdef statements all over a C program.

2) Anyway, on to the real problem. I've included a silly little project that demonstrates (on my machine at least) strange behaviour that locks up livecode. It's quick to do the steps below, but long to write.

Start Livecode.
Exit all stacks, clear them from memory, and then start my stack (just to get it on the list of recent stacks).
Exit Livecode completely.
Start Livecode.
When the list of previous projects is presented, start my stack.
An error screen appears because the Mac doesn't have a handler for the function "iphoneHideStatusDisplay". Note that this is before the card is displayed.
If you click on the 'close' window control, the error message goes away but the script is still running and so the card is not displayed (threw me the first time that happened). (I feel this should halt execution, and the 'script' button should let execution continue.)
If you click on the 'script' button, the stack's execution is halted, and the card is shown.
Click on the browse tool, and then resize the card.
The resizeStack handler is called with an error on the first iOS specific line, complaining that there's not a handler for this method.
...but now LiveCode seems to be borked. If I click on the 'halt' gadget in the code window (blue circle with black background), I see a highlight, but nothing else seems to happen. If you click in the script window, the text starts to be selected as you move the mouse, but there's no way to stop the selection.
LiveCode is now frozen and must be force-quit.

FWIW, I think this same bug happens on the iPhone Simulator, at least. If I change the resizeStack handler to be this:

Code: Select all

on resizeStack
   switch the environment
      case "mobile"
         answer "mobile" with "Ok"
      default
         answer "not mobile" with "Ok"
   end switch
   if the platform is "android" or the platform is "iphone" then
      put mobileOrientation() into field textline
      put iphoneDeviceResolution() after field textline
      put iphoneDeviceScale() after field textline
   end if
end resizeStack
And then test the app on the Simulator (or load it onto an iPad), the app opens saying first 'mobile' then 'not mobile', but when you rotate the device the answer 'mobile' shows, and then the program locks. You cannot click on the 'Ok' button. Only thing to do is click the 'Home' button to escape and kill the app.

Very strange.

-Ken