Page 1 of 1

List Fields

Posted: Wed Jan 17, 2007 6:30 pm
by BIX
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.

Posted: Wed Jan 17, 2007 7:21 pm
by Mark
Bix,

Why couldn't you? Did you get any error messages? There is a bracket missing at the end of your line.

Mark

Posted: Wed Jan 17, 2007 7:43 pm
by BIX
" 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"

Posted: Wed Jan 17, 2007 7:58 pm
by malte
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

Posted: Wed Jan 17, 2007 8:01 pm
by Mark
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

Posted: Wed Jan 17, 2007 8:21 pm
by BIX
Thanks guys. Both codes work.