Page 1 of 1

Links within a Repeat

Posted: Tue May 10, 2016 6:05 pm
by CElwell
How can I make urls which are loaded data within a repeat function appear as links?

For example:
Name:
Click here (link)
Name:
Click here (link)

tLink is the url loaded within the repeat

Code: Select all

set the textStyle of ... to link
set the linkText of .... to tLink
Do I need to have a system which counts the lines or searches for data with http in it? If so how should I go about doing this?

Thak you,
Cassidy

Re: Links within a Repeat

Posted: Tue May 10, 2016 7:00 pm
by jmburnod
Hi Cassidy,
I think you can use something like that:

Code: Select all

  repeat with i = 1 to the num of lines of fld 1
      if "http" is in line i of fld 1 then
         set the textstyle of char 1 to -1 of line i of fld 1 to link
         set the linktext of  char 1 to -1 of line i of fld 1 to (line i of fld 1)
      end if
   end repeat
Best regards
Jean-Marc

Re: Links within a Repeat

Posted: Tue May 10, 2016 7:19 pm
by CElwell
This makes sense with me, but how do I use this repeat if I am already using another repeat to load data into the field? I currently have a bunch of urls, but they do not appear as links.

Re: Links within a Repeat

Posted: Tue May 10, 2016 8:13 pm
by dunbarx
Hi.

Not sure what you mean. You can nest repeats, of course, but also do several things within a single repeat loop. Or run yet a new repeat.

Craig Newman

Re: Links within a Repeat

Posted: Tue May 10, 2016 10:25 pm
by CElwell
As the code is, it doesnt work. I thought maybe it has to do with the repeat. I cant change my overall repeat because then my data doesnt work. Also, I cant put all off the other data that is loaded within the repeat for the urls because it also makes my other data not work.

Re: Links within a Repeat

Posted: Tue May 10, 2016 11:49 pm
by Klaus
Hi Cassidy,

according to your screenshot, you are looping through your field "tDate"
BEFORE you actually fill it with the data from your xml, that cannot work! 8)

Move the last repeat loop outside of the first repeat loop* and it should work.
*Right after :
...
set the textt of fld "tData" to tOutput
repeat with i = 1 to the num of lines of fld "tData"
...



Best

Klaus

Re: Links within a Repeat

Posted: Wed May 11, 2016 12:19 am
by CElwell
Oh I understand, it gets stuck within one loop and unable to complete another. Thank you so much!