LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
BIX
- Posts: 33
- Joined: Fri Oct 27, 2006 2:54 pm
Post
by BIX » Wed Jan 17, 2007 6:30 pm
i don't know how to explain my question so i'll try like this:
i have two list fields, fdl1 and fld2. fld1 contains 8 filenames and fld2 contains 8 names of image controls (image "a", image "b" etc.). I need to set the filenames of images from fld2 to fld1.
i don't want to use
Code: Select all
set filename of image (line 1 of fld "fld2") to (line 1 of fld "fld1"
i tried to do this with repeat but i couldn't.
BIX
-
Mark
- Livecode Opensource Backer
- Posts: 5150
- Joined: Thu Feb 23, 2006 9:24 pm
-
Contact:
Post
by Mark » Wed Jan 17, 2007 7:21 pm
Bix,
Why couldn't you? Did you get any error messages? There is a bracket missing at the end of your line.
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
BIX
- Posts: 33
- Joined: Fri Oct 27, 2006 2:54 pm
Post
by BIX » Wed Jan 17, 2007 7:43 pm
" i tried to do this (not the code from above) with repeat but i couldn't"
i don't want to use the code from above. that code works but this one doesn't
Code: Select all
repeat for each line sl in fld "fld1"
put sl into thefilename
end repeat
repeat for each line someImage in fld "fld2"
set filename of someImage to thefilename
end repeat
After this it sets the filename of every image to last line of fld "fld2"
BIX
-
malte
- Posts: 1098
- Joined: Thu Feb 23, 2006 8:34 pm
- Location: Ostenfeld germany
-
Contact:
Post
by malte » Wed Jan 17, 2007 7:58 pm
Hi bix,
posting the code is helpful.
What you get is the correct behaviour, as first the first repeat loop is executed and the other one is executed after the first one is finished.. If you are sure that both fields contain the exact amount of lines you could do it like this
Code: Select all
local counter
put 0 into counter
repeat for each line theLine in fld "myField1"
add 1 to counter
set the fileName of img (line counter of fld "myField2") to theLine
end repeat
hope that helps,
Malte
-
Mark
- Livecode Opensource Backer
- Posts: 5150
- Joined: Thu Feb 23, 2006 9:24 pm
-
Contact:
Post
by Mark » Wed Jan 17, 2007 8:01 pm
Bix,
Maybe you want this:
Code: Select all
repeat with x = 1 to number of lines of fld "fld1"
set the filename of img (line x of fld "fld2") to ¬
line x of fld "fld1"
end repeat
If not, please explain more.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
BIX
- Posts: 33
- Joined: Fri Oct 27, 2006 2:54 pm
Post
by BIX » Wed Jan 17, 2007 8:21 pm
Thanks guys. Both codes work.
BIX