Switch Script

Getting into LiveCode for iOS? Ask your questions here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
conde
Posts: 51
Joined: Sun Nov 27, 2011 10:41 am
Location: Stuttgart, Germany

Switch Script

Post by conde » Sun Nov 18, 2012 11:55 am

Hello - maybe someone can help me?

State:

Mainstack
  • StartCard
--Substacks with cards--
iPadStack
iPhoneStack
iPhoneRetStack

The following procedure worked very well in iOS 4 and 5 - but not in 6.x

Mainstack script

Code: Select all

on getTheDevice
put the machine into tDevice
switch tDevice
case "iPhone Simulator"
case "iPhone"
case "iPod Touch"
if iphoneDeviceScale() is 2 then
   go to stack "iPhoneStack"
else 
go to stack "iPhoneStack320"
   end if
break
case "iPad Simulator"
case "iPad"
go to stack "iPadStack"
break
end switch
end getTheDevice
Startcard

Code: Select all

on preOpenStack
   set the visible of this stack to false -- hide it
end preOpenStack

on openstack
   getTheDevice -- your substack opens here; it is visible
end openstack
Now I try the following (the script of Ender Nafi http://forums.runrev.com/viewtopic.php?f=49&t=13371)

--Substacks with cards--
iPadRetStack
iPadStack
iPhoneStack
iPhoneRetStack
iPhoneRet4Stack

Mainstack script

Code: Select all

on getTheDevice
put the machine into tDevice
switch tDevice
case "iPod Touch"
         switch
            case (the screenLoc is "160,240") or (the screenLoc is "240,160")
               go stack "iPhoneStack320"
               break
            case (the screenLoc is "320,480") or (the screenLoc is "480,320")
               go stack "iPhoneStack"
               break
            case (the screenLoc is "320,568") or (the screenLoc is "568,320")
               go stack "iPhoneRet4Stack"
               break
         end switch
         break
      case "iPhone"
         switch
            case (the screenLoc is "160,240") or (the screenLoc is "240,160")
               go stack "iPhoneStack320"
               break
            case (the screenLoc is "320,480") or (the screenLoc is "480,320")
               go stack "iPhoneStack"
               break
            case (the screenLoc is "640,960") or (the screenLoc is "568,320")
                go stack "iPhoneRet4Stack"
               break
         end switch
         break
      case "iPhone Simulator"
         switch
            case (the screenLoc is "160,240") or (the screenLoc is "240,160")
              go stack "iPhoneStack320"
               break
            case (the screenLoc is "320,480") or (the screenLoc is "480,320")
              go stack "iPhoneStack"
               break
            case (the screenLoc is "568,320") or (the screenLoc is "320,568")
               go stack "iPhoneRet4Stack"
               break
         end switch
         break
      case "iPad"
         switch
            case (the screenLoc is "384,512") or (the screenLoc is "512,384")
               go stack "iPadStack"
               break
            case (the screenLoc is "768,1024") or (the screenLoc is "1024,768")
               go stack "iPadRetStack"
               break
         end switch
         break
      case "iPad Simulator"
         switch
            case (the screenLoc is "384,512") or (the screenLoc is "512,384")
              go stack "iPadStack" --iPad 1, iPad 2 or iPad Mini"
               break
            case (the screenLoc is "768,1024") or (the screenLoc is "1024,768")
              go stack "iPadRetStack"
               break
         end switch
         break
   end switch
end getTheDevice
Script in Mainstack > StartCard = same as above.

After splashscreen the screen is black.

Thanks in advance ... Guera

endernafi
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 296
Joined: Wed May 02, 2012 12:23 pm
Location: New York
Contact:

Re: Switch Script

Post by endernafi » Sun Nov 18, 2012 5:52 pm

Hi Guera,

* You've written
go stack "iPhoneStack320"
but there isn't any stack named as "iPhoneStack320"
* You can't hide mainstack, well it's the main stack and all others are its substacks.
* You have to use command iphoneUseDeviceResolution in order to determine the retina displays.
* And a friendly advice, it's always good to provide a simple, stripped-out sample stack.

I've attached a working one.
Hope it helps 8)


Best,

~ Ender Nafi

condeMainStack.zip
(1.83 KiB) Downloaded 210 times
~... together, we're smarter ...~
__________________________________________

macOS Sierra • LiveCode 7 & xCode 8

conde
Posts: 51
Joined: Sun Nov 27, 2011 10:41 am
Location: Stuttgart, Germany

Re: Switch Script

Post by conde » Mon Nov 19, 2012 1:56 am

Hello Ender Nafi,

YOU made my day - YOU made my week!!!! Thank YOU sooooooo much. It works great. :D

Sorry - I forgot the "iPhoneStack320" in the list and in the future I will follow your advice.

Thanks one more time ...
Guera

P.S.: There's a little problem that has something to do with my XCode configuration? In 5.1, it does not run in the simulator but on my real device iPad 1.

endernafi
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 296
Joined: Wed May 02, 2012 12:23 pm
Location: New York
Contact:

Re: Switch Script

Post by endernafi » Mon Nov 19, 2012 2:06 am

YOU made my day - YOU made my week!!!!
Well, you owe a beer then 8)
Just kidding, I'm really glad that I could help.

But, I couldn't understand your other problem.
P.S.: There's a little problem that has something to do with my XCode configuration? In 5.1, it does not run in the simulator but on my real device iPad 1.
Could you explain a little further?


Best,

~ Ender Nafi
~... together, we're smarter ...~
__________________________________________

macOS Sierra • LiveCode 7 & xCode 8

conde
Posts: 51
Joined: Sun Nov 27, 2011 10:41 am
Location: Stuttgart, Germany

Re: Switch Script

Post by conde » Mon Nov 19, 2012 10:41 am

Hello Ender Nafi
Well, you owe a beer then 8)
Sure - You have to know that here in the south west of Germany, it is brewed the best beer in the world.
Could you explain a little further?
OSX 10.8.2
Installed XCode 4.5 with 5.0 and 5.1 simulator packages
Installed XCode 4.4.1 - both in the Application folder under different names,
In Live Code Preferences/mobile preferences I've added both - showing: green box and Available device SDK: 5.1, 6.0; Available simulators: 5.0, 5.1, 6.0
In simulator 6.0 the app is running well, but in simulator 5.0 or 5.1 I see my splash screen and after 4/5 Minutes the app will appear in the simulator but without function (frozen).
No matter if the Standalone applications settings are set the "5.0 or later" setting and the "Armv7", "Armv6" or Universal.

On my iPad 1 the app is running well.iOS Settings: 5.1 or later, Armv7.

endernafi
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 296
Joined: Wed May 02, 2012 12:23 pm
Location: New York
Contact:

Re: Switch Script

Post by endernafi » Mon Nov 19, 2012 12:14 pm

Hi Guera,

I understand that the problem is about your actual code not my sample stack.
So, it's about your actual code :)
Try to debug, answer is your friend.
You must find which part of your code is creating problem.
Something like this would help:

Code: Select all

on preOpenCard
   answer "sending startUpMissions"
   send "startUpMissions" to me in 0 milliseconds
   answer "startUpMissions sent"
end preOpenCard

on startUpMissions
   if the environment is "mobile" then
      answer "checking installation"
      checkInstallation
      answer "installation checked, performing update"
      performUpdate
      answer "update done, going to second card"
   end if
   visual effect dissolve fast
   go to card "mySecondCard"
end startUpMissions
If you can't see a particular answer, then you know the problem is about that line of code.
For example if you see answer "checking installation",
but not see answer "installation checked, performing update";
then you'll know there's something about checkInstallation process.
Good luck mate, it'll be a long process but I don't think there's an easier solution.


Best,

~ Ender Nafi
~... together, we're smarter ...~
__________________________________________

macOS Sierra • LiveCode 7 & xCode 8

conde
Posts: 51
Joined: Sun Nov 27, 2011 10:41 am
Location: Stuttgart, Germany

Re: Switch Script

Post by conde » Tue Nov 20, 2012 12:51 am

Hello Ender Nafi,

thanks for your great help and for the debug script. But my app was running about 1 year and I changed nothing. I only replaced the switch script with your wonderful script above. No, it has nothing to do with your script, I think it's a problem of my XCodes or simulator installations.

Thanks again
Guera

Post Reply

Return to “iOS Deployment”