Sometimes, particularly when I have other pressing things to do, I give myself what I call a "RAD challenge". This is usually sparked by an evaluation request, and today was no exception. Our evaluation request forms include a space for requesting information or samples. The one from today that sparked my interest said:
I am trying to find product that will programically generate anchor tag looking for list of certain texts, numbers in richTextField, and PDF file attachment.This is one of those requests which leaves a certain amount to interpretation, but I thought I would give it a quick whirl.
The rules I have for myself are that I cannot spend over an hour on one of these RAD challenges, as developing with Midas should be faster than that. Since I didn't know what words or numbers to search for, I just grabbed some content from a couple of websites and used the word 'Home' to search for. I also searched for paragraphs with numbers in them (the hard way) and finally, attachments with the extension .pdf.
The sample I came up with is attached. It took about fifty minutes, due to a couple of false starts and interruptions. It is pretty cool, although I would have to clean it up a bunch to make it worthy of a regular download. Still, feel free to try it.
For those who don't want to download it and try, here is one little excerpt, the one where the PDF attachments are identified:
' *** Search for the pdf attachments and make references to them
Set rtchunk = rtitem.DefineChunk("File 1")
If Instr(Lcase(rtchunk.OriginalFileName), ".pdf") Then
' *** Add an anchor before the PDF file
pdf_count = pdf_count + 1
Call toc_chunk.AppendLink(rtchunk.OriginalFileName, db.ReplicaID, view.UniversalID, doc.UniversalID, "Click to go to anchor...", "", "PDF-"+Cstr(pdf_count))
Call toc_chunk.AppendText(Chr(0), "Plain Black 10pt")
Copyright © 2005 Genii Software Ltd.