Page 1 of 1
Setting the linktext of linked text in a field
Posted: Thu Jun 20, 2019 7:57 pm
by montymay
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
Re: Setting the linktext of linked text in a field
Posted: Thu Jun 20, 2019 8:13 pm
by dunbarx
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
Re: Setting the linktext of linked text in a field
Posted: Thu Jun 20, 2019 8:34 pm
by Klaus
Just tested on macOS 10.14.5 with LC 9.04 and it works as exspected.
Re: Setting the linktext of linked text in a field
Posted: Thu Jun 20, 2019 8:40 pm
by montymay
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.
Re: Setting the linktext of linked text in a field
Posted: Thu Jun 20, 2019 8:44 pm
by Klaus
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
Re: Setting the linktext of linked text in a field
Posted: Sun Jun 23, 2019 2:48 am
by montymay
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
Re: Setting the linktext of linked text in a field
Posted: Sun Jun 23, 2019 5:47 pm
by jacque
It sounds like a bug to me.