datagrid form multiple loop behavior?

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: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
cusingerBUSCw5N
Posts: 335
Joined: Wed Jul 11, 2012 9:24 pm

datagrid form multiple loop behavior?

Post by cusingerBUSCw5N » Tue Sep 11, 2012 8:42 pm

I am trying to get my datagrid to have multiple heights based on the contents. In the process of failing to do this and trying to debug it...it seems to be looping a zillion times - and I don't know why. Actually, I have two records in my datagrid. (confirmed when I switch to the table mode). But when I change it to form mode and put a test - answer "hello" - to figure out where my code is going screwy - it loops 15 times.

I put in: answer item 4 of pcontrolrect to debug it and it produced

280 280 280 280 475 670 280 280 264 280 475 670 280 475 670

Given that I only have two records...how can it have these wildly different heights - - and why are there 15 of them?

Maybe I don't care...but if I had 50 records -would this expand to 700+ loops?

My real problem is that I want to have this with varying heights - and my first record has a huge space...and the other seems OK...

Here's my code (including the spot where I put my answer item 4 of pcontrolrect:

Code: Select all

on LayoutControl pControlRect
 local theFieldRect
   
set the top of field "label" of me to item 2 of pcontrolrect + 5
set the right of field "label" of me to item 3 of pcontrolrect - 5
set the left of field "label" of me to item 1 of  pcontrolrect + 8
   put the rect of field "label" of me into theFieldRect
   set the top of field  "col3" of me to the bottom of field "label" of me + 20
   set the left of field "col3" of me to item 1 of pcontrolrect + 15
   set the right of field "col3" of me to item 3 of pcontrolrect - 10
   put the rect of field "col3" of me into theFieldRect

   put item 2 of thefieldrect + the formattedheight of field "label" of me + the formattedheight of field "col3" - the bottommargin of field "col3" of me - the bottommargin of field "label" of me into item 4 of thefieldrect
   put item 4 of thefieldrect into item 4 of pcontrolrect
   answer item 4 of pcontrolrect
   set the rect of graphic "background" of me to pcontrolrect   

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”