Page 1 of 1

Hypertext and URLs

Posted: Tue Feb 14, 2006 1:35 pm
by martindholmes
Hi there,

I'm writing an editor that has to support hypertext links, but I can't use AllTagsArePChars because I'm using tags for other purposes elsewhere in the code. So I'm looking for advice on the best method of storing and retrieving the URLs associated with hypertext links, using the item tags.

One option is to store the URLs in a StringList as name-value pairs, with some arbitrary number generated for each item:

123456=http://hotpot.uvic.ca/
234567=http://www.halfbakedsoftware.com/

and then retrieve them like this:

URLList.Values[IntToStr(MyRichView.GetItemTag(ItemNo))]

I'd have to ensure the tag values were all unique, of course. Does this seem like a reasonable approach? Has anyone else faced this problem and found a better solution?

All help appreciated,
Martin

Posted: Tue Feb 14, 2006 9:38 pm
by Sergey Tkachenko
Since tags may be strings, you can encode any information in them.
For example, tags may be strings like:

Code: Select all

url="http://hotpot.uvic.ca/" mydata=15 yes=no
(tags must not contain line break and #0 characters, other characters are allowed)
You need to modify you code in OnReadHyperlink, OnWriteHyperlink and OnJump event to work only with "url" part of tags

Posted: Wed Feb 15, 2006 12:24 am
by martindholmes
That's a point; I guess I could set AllTagsArePChars and store my integers in the strings too. It'll slow down some other processing which uses integer tags, though.

Have you thought about adding a WideString field to every item by default? It would be SO handy to have a WideString and an integer tag as well.

Cheers,
Martin

Posted: Wed Feb 15, 2006 1:11 pm
by Sergey Tkachenko
I am afraid that integer/string switch is already too complicated solution.
If I add more options, such as widesting or objects, it would be even more complicated and hard to learn for novices.