Page 2 of 2

Re: LiveCode Community for Windows has stopped working

Posted: Sat Mar 04, 2017 9:07 pm
by jacque
I haven't worked through the lengthy scripts posted here so I'm not quite sure what the desired result should be. But in case it helps, there's a quick way to remove all the html tags so that you can parse just the plain text for what you want to extract:

Code: Select all

set the htmlText of the templateField to tHTML -- the raw web page content
put the text of the templateField into tPlainText -- yields text without any tags

Re: LiveCode Community for Windows has stopped working

Posted: Thu Mar 09, 2017 11:36 am
by lewis
Thanks for your help AxWald.
But, - as I don't want any hypertext links I have gone my own way and deleted everything I don't want rather than as you have done, selected everything one might want. Rather simplistic but it works quite happily and quite fast. I have also used,

Code: Select all

set the htmlText of fld "output_fld" to myData
but I could/can just as easily have used;

Code: Select all

put myData into fld "output_fld"
the idea being to avoid any problems with foreign words needing diacritics.
Just to show you what I have achieved I have attached a sample stack which generates the output I want.
BookList.zip
List the author's books just the way I want and without the stuff I don't want.
(5.26 KiB) Downloaded 320 times
Obviously we have gone way off the topic heading where this all started and it's been great fun and really useful to me.
Now I have to look at the suggestion by jacque and figure out what it means, - cos at first glance I don't quite get it - but give me time and I will.

Re: LiveCode Community for Windows has stopped working

Posted: Fri Mar 10, 2017 1:59 pm
by lewis
Thankyou jacques... I now understand better that using put URL someWebSite gives me some 'html' from the website as just plain old text. Thus when I set the htmlText of a field or part of a field (which the Dictionary says it must be, i.e. not just a variable) to that text it gets made into something like it might appear as if viewing a web site.
I'm not really clear yet on whether/how that retains all the hyperlinks of the original 'cos I don't fully understand the Dictionary entry
<a> </a> Encloses text whose textStyle is "link" or whose linkText property is not empty. If the textStyle of the text contains "link", the linkText is included as the value of the "href" attribute. Otherwise, it is included as the value of the "name" attribute.
<img src="imageSpecifier"> Replaces a character whose imageSource property is not empty. The value of the imageSource property is included as the value of the "src" attribute.
In any case that does not concern me here as I only want the plain text extracted and these two things seem to be ignored.
***********************
The big difference though is that actually doing the set the htmlText into a 'real' field takes quite a few seconds (up to 10) whereas putting it into the templateField which is not displayed is close to instantaneous. And the put the text of the templateField into fld "output_fld" is similarly fast.
***********************
So all I have to do is to remove anything between '<script> and '</script>' which seems otherwise to be included as text, and a few other minor and simple things, e.g.replace "&nbsp;" with 'empty', to get the formatting the way I want it.

Re: LiveCode Community for Windows has stopped working

Posted: Fri Mar 10, 2017 4:54 pm
by FourthWorld
lewis wrote:The big difference though is that actually doing the set the htmlText into a 'real' field takes quite a few seconds (up to 10) whereas putting it into the templateField which is not displayed is close to instantaneous. And the put the text of the templateField into fld "output_fld" is similarly fast.
The templateField is handy that way. You can get similar performance with a field on an unopened card as well. The reason is that when a card is loaded for rendering the line wraps need to be calculated, but none of those calculations are done with the templateField or a field on an unopened card since they can't be seen anyway.