Normalizing Group Code (not repeating code)

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
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm
Location: Seattle, USA

Normalizing Group Code (not repeating code)

Post by townsend » Sun Jul 02, 2017 8:07 pm

I have a Data Grid, a bunch of Buttons, and some Text Fields, all working fine. I place them into a Group. Copy and Paste the Group. Then rename the two groups: Group1 and Group2.

Both Groups have an identical Field: "Notes". I can populate each of the Fields with this code.

Code: Select all

put "hello" into fld "dNotes" of group "group1"
put "hello" into fld "dNotes" of group "group2"
Now lets say I pasted in a couple of more of these exact Groups. So then I have: Group1, Group2, Group3, Group4"

Is there any way I can update these Fields by referencing these Groups with an Index? Something like this:

Code: Select all

repeat with ii =1 to 4
     put "hello" into fld "dNotes" of group "group"[ii]
end repeat

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Normalizing Group Code (not repeating code)

Post by Klaus » Sun Jul 02, 2017 8:59 pm

Hi townsend,

string concatenation is the magic word:

Code: Select all

repeat with ii =1 to 4
     put "hello" into fld "dNotes" of group ("group" & ii)
end repeat
Best

Klaus

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”