iphoneUseDeviceResolution throws error

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jekyllandhyde
Posts: 92
Joined: Thu Feb 14, 2013 7:17 pm

iphoneUseDeviceResolution throws error

Post by jekyllandhyde » Tue Feb 19, 2013 6:38 am

It seems after I upgraded from 5.5.3 the following lines of code are throwing a script error when I open the stack. They were fine in the previous version? The funny thing is that when I compile they have the intended result in the Xcode iphone IOS 6.0 simulator. When I comment them out then the scaling blows up. Something fishy here on the bleeding edge...

on openStack
if iphoneDeviceScale() is "2"
then
iphoneUseDeviceResolution true, true
end if
end openStack


this is the error message:
executing at 9:26:45 PM
Type Function: error in function handler
Object teststack
Line if iphoneDeviceScale() is "2"
Hint iphoneDeviceScale


My environment

Xcode 4.6
IOS 6.1 SDK
Mac OSX 10.8
Livecode 5.5.4

DRJ-UK
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 73
Joined: Tue Aug 23, 2011 2:50 pm
Contact:

Re: iphoneUseDeviceResolution throws error

Post by DRJ-UK » Tue Feb 19, 2013 1:51 pm

Hi

The clue appears in the error message and focuses on the line with the iphoneDeviceScale(). Try replacing the string "2" with just the ordinal number 2 as shown in the code below:

Code: Select all

on openStack
if iphoneDeviceScale() is 2 then  -- note the end of the if statement line should end with "then"
iphoneUseDeviceResolution true, true
end if
end openStack
We have had no problems using ordinal numbers with this command in our Apps generated with LC 5.5.4 and Xcode 4.6 on devices running iOS 6.1.

Hope this helps.

Dave
Last edited by DRJ-UK on Wed Feb 20, 2013 5:12 pm, edited 2 times in total.
LiveCode: Versions 8.0, 8.1
Xcode: Version 7.3, 8.0
Mac OS X: 10.11.12 (macOS Sierra) on iMacs with 3.4 Intel Core i7 & 16GB Memory

Creating Apps for educational professionals, effective teaching and learning.

jekyllandhyde
Posts: 92
Joined: Thu Feb 14, 2013 7:17 pm

Re: iphoneUseDeviceResolution throws error

Post by jekyllandhyde » Tue Feb 19, 2013 10:49 pm

Dave,

Thank you for your suggestion but unfortunately it makes no difference without the quotes, it works (set's the screen properly) either way but still causes the script error.

I also commented out a few lines and I get a new error message: stack "teststack'" execution error at line 17(Handler: can't find handler) near "iphoneUseDeviceResolution", char 1

my code that causes this error:
on openStack
-- if iphoneDeviceScale() is 2
-- then
iphoneUseDeviceResolution true, true
--end if
end openStack

It appears there is a problem with both commands?

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

Re: iphoneUseDeviceResolution throws error

Post by Klaus » Tue Feb 19, 2013 11:11 pm

Hi,

problem is, that the desktop version does NOT know all the mobile handlers and functions and complains heavily in these cases!
You need to script a IF...THEN clause like this:

Code: Select all

on openStack

  ## Prevent IDE errors:
  if the environment <> "mobile then
     exit openstack
  end if

  ## NOW we are safe :-)
  if iphoneDeviceScale() is 2 then
     iphoneUseDeviceResolution true, true
   end if
end openStack
Best

Klaus

jekyllandhyde
Posts: 92
Joined: Thu Feb 14, 2013 7:17 pm

Re: iphoneUseDeviceResolution throws error

Post by jekyllandhyde » Wed Feb 20, 2013 12:22 am

Klaus,

Case Closed!
Thanks so much. Your approach with checking for a mobile environment fixed the script error problem. I didn't have any luck compiling until I fixed up some of your syntax (missing quote, else statement etc) and added the accelerated rendering line: (for future viewers I am not supporting 320 wide displays so if you are, you will need to add a check for this) like:

if iphoneDeviceScale() is 2 then
iphoneUseDeviceResolution true, true

MY code that worked:
--------------------------
##these lines make the scaling work properly on 640 pixel wide displays
on openStack
  ## Prevent IDE errors:
  if the environment <> "mobile" then
     exit openstack
else
  ## NOW we are safe :-)
iphoneUseDeviceResolution true, true
set the acceleratedRendering of this stack to "true"
end if
end openStack

I am finding LiveCode usable despite being a beginner although I don't agree with one of the selling points that you can easily compile for any environment. Why? Because beginners like me have to put manual checks in the code for the specific environment! I didn't find this in beginner lessons 1 through 6 :)

Now if another genius like Klaus can figure out why the 4" Iphone 5 squeezes the screen's top and bottom every time, I will be eternally thankful.
http://forums.runrev.com/viewtopic.php?f=49&t=14156

Post Reply