Confusing Error Message Generated by Object Resizing Handler

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
Gage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 224
Joined: Tue Mar 26, 2013 8:59 pm

Confusing Error Message Generated by Object Resizing Handler

Post by Gage » Wed Apr 17, 2013 7:54 pm

Hi all,

I have been laying out a card, and I have a simple handler to resize the objects on the card. When I run the script, it spits out an enigmatic error message that has me totally stumped.

The error message is as follows:

card "Contact Profile": execution error at line n/a (Object: property is not an integer) near "-14857.83"


I have no idea how I can cause an error with no line, or what property it's referring to that needs to be an integer. Nor have I any idea what the number in quotes is.

Let me know if I should post some of the code for inspection, but it truly is just scaling and locating the edges of various objects to keep the card layout ratios consistent upon window resizing.

Thanks,
Phil E.

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Confusing Error Message Generated by Object Resizing Han

Post by Dixie » Wed Apr 17, 2013 7:55 pm

Post your script...

Dixie

Gage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 224
Joined: Tue Mar 26, 2013 8:59 pm

Re: Confusing Error Message Generated by Object Resizing Han

Post by Gage » Wed Apr 17, 2013 7:58 pm

Code: Select all

global tGap

on preOpenCard
   put (the width of this stack * 0.025) into tGap
   scaleObjects
   layoutCard
end preOpenCard

on resizeStack
   scaleObjects
   layoutCard
end resizeStack

on scaleObjects
#Scale the title box header graphic to the card
   set the height of graphic "Title Box" of me to (the height of this stack * 0.1)
   set the width of graphic "Title Box" of me to the width of this stack

   #Scale the title label to the card
   set the width of field "title" of me to (the width of this stack * 0.25)
   set the height of field "title" of me to (the height of graphic "Title Box" of this card * 0.8)
   //put max(32,the height of group "contact list" of me/10) into tTextHeight
   put (the height of graphic "Title Box" of me/3) into tTextHeight
   set the textSize of field "Title" of me to tTextHeight
   //set the textHeight of field "title" of me to tTextHeight
   
   #Scale the contact picture image
   set the width of image "Contact Picture" of me to (the width of this stack * 0.3)
   set the height of image "Contact Picture" of me to (the width of this stack * 0.3)

   #Scale the contact information fields
   put (the height of this stack * 0.06) into tContactInfoHeight
   put (the width of this stack * 0.625) into tContactInfoWidth
   //Contact name field
   set the width of field "Contact Name" of me to the width of image "Contact Picture" of me
   set the height of field "Contact Name" of me to (tContactInfoHeight * 6 - the height of image "Contact Picture" of me - tGap)
   #scale the text size

   //Contact info fields
   set the height of field "PhNumber" of me to tContactInfoHeight
   set the width of field "PhNumber" of me to tContactInfoWidth
   set the height of field "Email" of me to tContactInfoHeight
   set the width of field "Email" of me to tContactInfoWidth
   set the height of field "Location" of me to tContactInfoHeight
   set the width of field "Location" of me to tContactInfoWidth
   set the height of field "Birthdate" of me to tContactInfoHeight
   set the width of field "Birthdate" of me to tContactInfoWidth
   set the height of field "Sort List" of me to tContactInfoHeight
   set the width of field "Sort List" of me to tContactInfoWidth
   set the height of field "Fish Type" of me to tContactInfoHeight
   set the width of field "Fish Type" of me to tContactInfoWidth

   #Scale the notes label
   set the width of field "Notes" of me to the width of this stack - 2 * tGap
   set the height of field "Notes" of me to the height of this stack * (0.54 - 3 * tGap)
   
   #Scale the header labels within the notes label
   layoutCard
end scaleObjects

on layoutCard
   #Position the title box header graphic
   set the topLeft of graphic "Title Box" of me to 0,0
   
   #Position the title label
   set the left of field "Title" of me to (the width of this stack * 0.375)
   set the top of field "Title" of me to (the height of graphic "Title Box" of me * 0.2)
   
   #Position the contact picture image
   set the topLeft of image "Contact Picture" of me to tGap,(the bottom of graphic "Title Box" of me + tGap)
   
   #Position the contact information labels
   //Contact name field
   set the topLeft of field "Contact Name" of me to tGap,(the bottom of image "Contact Picture" of me + tGap)
   
   //Contact info fields
   set the topLeft of field "PhNumber" of me to (the width of image "Contact Picture" of me + 2 * tGap),(the height of graphic "Title Box" of me + tGap)
   set the topLeft of field "Email" of me to the bottomLeft of field "PhNumber" of me
   set the topLeft of field "Location" of me to the bottomLeft of field "Email" of me
   set the topLeft of field "Birthdate" of me to the bottomLeft of field "Location" of me
   set the topLeft of field "Sort List" of me to the bottomLeft of field "Birthdate" of me
   set the topLeft of field "Fish Type" of me to the bottomLeft of field "Sort List" of me
   
   #Position the notes label
   set the topLeft of field "Notes" of me to tGap,(the height of graphic "Title Box" of me + the height of image "Contact Picture" of me + the height of field "Contact Name" + tGap * 3)
   
   #Position the header labels within the notes label
   
end layoutCard

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Confusing Error Message Generated by Object Resizing Han

Post by dunbarx » Wed Apr 17, 2013 8:23 pm

Hi.

Without going very deeply into your issue, please try the following:

put trunc(the width of this stack * 0.025) into tGap

and similarly for all of the decimal calculations you do farther down. Let's just make sure we have integers after all that scaling.

Craig Newman

Gage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 224
Joined: Tue Mar 26, 2013 8:59 pm

Re: Confusing Error Message Generated by Object Resizing Han

Post by Gage » Wed Apr 17, 2013 9:14 pm

Hi, Craig,

Thanks for the response!

So, that did make the number displayed in the error message an integer. However, the same error message is still displayed (albeit now, with the number "-14442" in place of what was previously "-14857.83").

So I don't know if the error message is saying that some property I inadvertently tried to make into an integer is instead a string, or something else...

I just do not know how to interpret the error message, particularly because I don't know where the number it references comes from.

Phil E.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Confusing Error Message Generated by Object Resizing Han

Post by Simon » Wed Apr 17, 2013 9:22 pm

Hi Phil,
This is the only "minus" line I see:
set the width of field "Notes" of me to the width of this stack - 2 * tGap
Doubt you can have a - width.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Confusing Error Message Generated by Object Resizing Han

Post by dunbarx » Wed Apr 17, 2013 10:04 pm

Simon likely found it.

Is 2 * tGap greater than the width of the stack?

Craig Newman

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Confusing Error Message Generated by Object Resizing Han

Post by Simon » Wed Apr 17, 2013 10:45 pm

Actually I just put together a stack and am finding an error with this line:
set the height of field "Contact Name" of me to (tContactInfoHeight * 6 - the height of image "Contact Picture" of me - tGap)

Phil, you should turn the boarders on for all your fields and watch them. The above causes the height of field "Contact Name" to go into negative numbers as the stack resizes.
I'm not saying that this is "the" line that is causing you trouble but any of the lines which could cause a negative number size will throw an error.

I'm guessing that -14442 is being used to set the size of one of your objects.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Gage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 224
Joined: Tue Mar 26, 2013 8:59 pm

Re: Confusing Error Message Generated by Object Resizing Han

Post by Gage » Thu Apr 18, 2013 2:43 am

Simon and Craig,

tGap is the global variable I am using for spacing the different objects throughout the app; it is relatively small, being 2.5% of the stack width.

I will look at alternative ways to assign the height of the Contact Name field. I am thinking the number is being passed somewhere that doesn't recognize it, either. Is there a way to tell where the value is ending up, since the error message doesn't cite any line as the problem?

Now, time to display my lack of experience: what are these borders I need to turn on?

Phil E.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Confusing Error Message Generated by Object Resizing Han

Post by Simon » Thu Apr 18, 2013 3:08 am

Hi Phil,
In the field inspector you have the option to turn on the borders of the fields. I used it so that I could watch the fields change size.
2 Things:
1) take the script out of the preOpenCard for now (until this gets solved)
2) resize by dragging the corner, not maximising the window. This is so you can watch your field and see which is getting too small.

If the IDE is locking when you open the stack then turn the messages off (little envelope in the menu bar).
Yes, on opening the stack I get an error with this line:
set the height of field "Notes" of me to the height of this stack * (0.54 - 3 * tGap)
similar -12284

Simon
Edit: double clicking on the error should show you the line the error is on, but when I resize and it hits the error the whole IDE locks up.
Edit 2: Yes, that (0.54 - 3 * tGap) will equal a negative number e.g. 0.54 - 3 * 9 maybe you wanted it the other way round (3 * tGap - 0.54).
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Gage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 224
Joined: Tue Mar 26, 2013 8:59 pm

Re: Confusing Error Message Generated by Object Resizing Han

Post by Gage » Fri Apr 19, 2013 12:08 am

Simon! You're the man!

tGap was declared and populated by a value that was already the result of multiplying the stack width by an integer, so to include it in the parentheses does indeed mess with everything. I need to just use the percentage, not the (percent x stack width) quantity, which is what the variable actually is. Very simple error, but I repeatedly overlooked it.

Thanks so much for helping me out with this!

Regards,
Phil E.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Confusing Error Message Generated by Object Resizing Han

Post by Simon » Fri Apr 19, 2013 12:18 am

Glad you got it working! :D

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply