Setting the linktext of linked text in a field

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
montymay
Posts: 145
Joined: Thu Jul 18, 2013 5:23 am

Setting the linktext of linked text in a field

Post by montymay » Thu Jun 20, 2019 7:57 pm

I am trying to create linked text and set the linktext of the linked text of a locked field with the following code. Let's say the field just contains the word "instructions." and I selected it with the mouse:

Code: Select all

on mouseup
   put the selectedchunk into tLink
   ask question "Enter URL:"
   put it into tURL
   set the textstyle of tLink to "link"
   set the linktext of tLink to tURL 
end mouseup
The it variable definitely contains the URL that I entered into the text box, e.g., "http://www.website.com." The script puts it into tURL. My script (not stated) puts the field contents into a text file. When I check the htmltext of the text file, it states the following: <a href="OK">instructions</a>.</p> Why doesn't the URL appear instead of "OK"?

Thanks for your reply or replies.

Monty

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9663
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Setting the linktext of linked text in a field

Post by dunbarx » Thu Jun 20, 2019 8:13 pm

Hi.

Without your unstated handler, I couldn't say.

But the variable tURL does indeed contain the contents of the "ask" dialog, and I assume that is a URL. So where does that change to "OK?

Craig

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

Re: Setting the linktext of linked text in a field

Post by Klaus » Thu Jun 20, 2019 8:34 pm

Just tested on macOS 10.14.5 with LC 9.04 and it works as exspected.

montymay
Posts: 145
Joined: Thu Jul 18, 2013 5:23 am

Re: Setting the linktext of linked text in a field

Post by montymay » Thu Jun 20, 2019 8:40 pm

Thank you for your replies. Here is the unstated code that follows the code stated above.

Code: Select all

put the htmltext of fld 1 into URL ("file:"&gPath&"guides"&"/"&tTopic&".txt")
Don't yet know where the change occurs. Since I click "OK" to dismiss the Ask dialog box, maybe the "OK" originates there. Will keep trying to find the solution.

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

Re: Setting the linktext of linked text in a field

Post by Klaus » Thu Jun 20, 2019 8:44 pm

What version are you using?
You could add something like this to check:

Code: Select all

on mouseup
   put the selectedchunk into tLink
   ask question "Enter URL:"
   put it into tURL

   ## !!
   put tURL ## into fld "test"
   ## !!

   set the textstyle of tLink to "link"
   set the linktext of tLink to tURL 
end mouseup

montymay
Posts: 145
Joined: Thu Jul 18, 2013 5:23 am

Re: Setting the linktext of linked text in a field

Post by montymay » Sun Jun 23, 2019 2:48 am

To Klaus

Thank you for your reply. I executed your suggested script and the text "OK" was printed in the field "test." I am running LC 8.1.1. on a WIndows 10 platform.

The funny thing is, I ran the same program on my office computer, which runs WIndows 7, and to my surprise the correct htmltext was printed out, e.g., instead of <a href="OK"> etc., the following was printed: <a href="https://www.livecode.com"> etc. Clicking the link opens the Livecode website in my browser. Is this possibly a bug?

Monty

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Setting the linktext of linked text in a field

Post by jacque » Sun Jun 23, 2019 5:47 pm

It sounds like a bug to me.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”