The case of the changing dimensions

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
daryl
Posts: 47
Joined: Mon Apr 29, 2013 11:43 pm

The case of the changing dimensions

Post by daryl » Fri May 31, 2013 10:11 pm

Hi Folks,

I am having a very perplexing problem (for me anyway) and I am hoping someone here can point me in the right direction, as I suspect it is due to my lack of understanding and experience with LiveCode.

I have a small application that just attempts to set it's stack/window dimensions and print them to a scrolling list. So far so good, most of this works, but I am having a problem with the height. So, my code defines some variables to keep track of the width and height of the stack and initially set the width to 240 px and the height to 320 px, then if it is running on a desktop it resets the with to 400 and the height to 600. The code I am using looks like this:

-- initial setting
put 240 into theStackWidth
put 320 into theStackHeight
set the width of this stack to theStackWidth
set the height of this stack to theStackHeight

// some code here to determine the platform...

-- on a desktop we reset the width and height
put 400 into theStackWidth
put 600 into theStackHeight

set the width of this stack to theStackWidth
set the height of this stack to theStackHeight

// and if I print out or look at the value of theStackHeight container
// in the debugger it will be set to the height property in the stack's
// properties window which appears to be set to the last resized
// value, rather than the 320 used to set it initially.

This has me rather going around in circles trying to understand what is going on. I would like application not to remember any resizing values and always start with a known size.

Any help would be greatly appreciated.

Thanks,

Daryl

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: The case of the changing dimensions

Post by mwieder » Fri May 31, 2013 10:52 pm

Daryl- your code works here. Are you sure you're checking the platform correctly and executing that second section?

daryl
Posts: 47
Joined: Mon Apr 29, 2013 11:43 pm

Re: The case of the changing dimensions

Post by daryl » Fri May 31, 2013 11:15 pm

Hi MWieder,

Thanks for your reply. I am sure I am checking the platform correctly, although I am having a problem having the debugger follow the mobile code path. I am going to different cards based on the platform, and starting to think that design might be more trouble than it's worth. The debugger always chooses the desktop platform. Here is some of the actual code I am using:

global theScreenSize
global theStackWidth
global theStackHeight
global theScreenDim

on preOpenStack

put the screenrect into theScreenSize

-- Split the screen info string so we can access the individual properties.
put theScreenSize into theScreenDim
split theScreenDim by comma

put 240 into theStackWidth -- The width of the smallest device we know of, the Android QVGA 240x320.
put 320 into theStackHeight -- The height of the smallest device we know of, the Android QVGA 240x320.

-- Set up platform specific details.
switch
case (the platform is "MacOS") or (the platform is "Win32") or (the platform is "Linux")
-- Set the width and height of the stack to a reasonable desktop size.
put 400 into theStackWidth
put 600 into theStackHeight
set the width of this stack to theStackWidth
set the height of this stack to theStackHeight
// By now the theStackHeight container's value has been changed to
// the value from the Property Inspector's "Size and Position" height menu entry.
// Feels like bad magic; but I am running 6.0.2-rc-1, I wonder if it might be a bug?
go to card "Desktop Layout Card"
break
case (the platform is "android")
put theScreenDim[3] into theStackWidth
put theScreenDim[4] into theStackHeight
set the width of this stack to theScreenDim[3]
set the height of this stack to theScreenDim[4]
go to card "Mobile Layout Card"
break
end switch

Do you know if there is a way to get the debugger to follow the mobile code path?
Any help is greatly appreciated.

Thanks,

Daryl

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: The case of the changing dimensions

Post by mwieder » Fri May 31, 2013 11:57 pm

Daryl- now you're asking a different question, and it's the same one you asked in the Android Development forum.

daryl
Posts: 47
Joined: Mon Apr 29, 2013 11:43 pm

Re: The case of the changing dimensions

Post by daryl » Sat Jun 01, 2013 12:04 am

Hi MWieder,

Well it's really just an extension of the first question. I am just trying to find a way to get more information about the problem that I posted here originally, so I can fix it.

Best Regards,

Daryl

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: The case of the changing dimensions

Post by mwieder » Sat Jun 01, 2013 12:12 am

Daryl- there's nothing to "fix" - your code is doing exactly what you told it to do. You have two choices here:

1. Run the code on a mobile device instead of in the simulator
2. Don't switch on the platform.

daryl
Posts: 47
Joined: Mon Apr 29, 2013 11:43 pm

Re: The case of the changing dimensions

Post by daryl » Sat Jun 01, 2013 1:10 am

Thanks MWieder, I appreciate your help. I'm going to relax over the weekend and look the app on Monday, with a fresh perspective. Hope you have a good weekend as well.

Regards,

Daryl

Post Reply