Links within a Repeat

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
CElwell
Posts: 38
Joined: Thu Feb 04, 2016 6:29 pm

Links within a Repeat

Post by CElwell » Tue May 10, 2016 6:05 pm

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

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Links within a Repeat

Post by jmburnod » Tue May 10, 2016 7:00 pm

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
https://alternatic.ch

CElwell
Posts: 38
Joined: Thu Feb 04, 2016 6:29 pm

Re: Links within a Repeat

Post by CElwell » Tue May 10, 2016 7:19 pm

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.
Attachments
3.png
Here is what it looks like--ignore the random button

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Links within a Repeat

Post by dunbarx » Tue May 10, 2016 8:13 pm

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

CElwell
Posts: 38
Joined: Thu Feb 04, 2016 6:29 pm

Re: Links within a Repeat

Post by CElwell » Tue May 10, 2016 10:25 pm

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.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Links within a Repeat

Post by Klaus » Tue May 10, 2016 11:49 pm

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

CElwell
Posts: 38
Joined: Thu Feb 04, 2016 6:29 pm

Re: Links within a Repeat

Post by CElwell » Wed May 11, 2016 12:19 am

Oh I understand, it gets stuck within one loop and unable to complete another. Thank you so much!

Post Reply