Looping through all elements of same type

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
doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Looping through all elements of same type

Post by doobox » Sat Oct 27, 2012 9:49 am

The incorrect code below should say what i am looking to do. Though i guess i am way of the mark with my repeat statement :

Code: Select all

   repeat for each field of this card // this line is incorrect..?
      if the short name of me is "label"
      set the textsize of me to the textsize of me + 10
   end repeat
Kind Regards
Gary

https://www.doobox.co.uk

doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Re: Looping through all elements of same type

Post by doobox » Sat Oct 27, 2012 9:57 am

Managed to dig some similar code out of a runrev video, and modify the code to work for me :

Code: Select all

   repeat with x=1 to the number of fields of this card
       if the short name of field x is "label" then
         set the textsize of field x to the textsize of field x + 10
      end if
   end repeat
Kind Regards
Gary

https://www.doobox.co.uk

doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Re: Looping through all elements of same type

Post by doobox » Sat Oct 27, 2012 10:20 am

One of the issues a saw when returning to livecode dev, was the lack of support for iPhone 5 in MobGUI.

You can use the custom size in MobGUI for iphone 5, but one of the main issues a see with this, is that label texts are not scaled when seen on iPhone 5.
This overcomes that.
If you place this on every card, all the button labels and the nav label is scaled up as it is for retina.
I may not have the number exactly right here but that can be played with.

Code: Select all

on openCard
   put iphoneDeviceResolution() into tScreenResolution
   put item 2 of tScreenResolution into tScreenheight
   wait 10 ticks with messages // seems to only work with this waiting time
   if tScreenheight is 1136 then
      repeat with x=1 to the number of fields of this card
         if the short name of field x is "label" then
            set the textsize of field x to the textsize of field x + 10
            set the height of field x to the height of field x + 10
         end if
      end repeat
   end if
end openCard
Kind Regards
Gary

https://www.doobox.co.uk

Post Reply