Setting up help for a Delphi app - delphi

What's the best way to set up help (specifically HTML Help) for a Delphi application? I can see several options, all of which has disadvantages. Specifically:
I could set HelpContext in the forms designer wherever appropriate, but then I'm stuck having to track numbers instead of symbolic constants.
I could set HelpContext programmatically. Then I can use symbolic constants, but I'd have more code to keep up with, and I couldn't easily check the text DFMs to see which forms still need help.
I could set HelpKeyword, but since that does a keyword lookup (like Application.HelpKeyword) rather than a topic jump (like Application.HelpJump), I'd have to make sure that each of my help pages has a unique, non-changing, top-level keyword; this seems like extra work. (And there are HelpKeyword-related VCL bugs like this and this.)
I could set HelpKeyword, set an Application.OnHelp handler to convert HelpKeyword requests to HelpJump requests so that I can assign help by topic ID instead of keyword lookup, and add code such as my own help viewer (based on HelpScribble's code) that fixes the VCL bugs and lets HelpJump work with anchors. By this point, though, I feel like I'm working against the VCL rather than with it.
Which approach did you choose for your app?

When I first started researching how to do this several years ago, I first got the "All About help files in Borland Delphi" tutorial from: http://www.ec-software.com/support_tutorials.html
In that document, the section "Preparing a help file for context sensitive help" (which in my version of the document starts on page 28). It describes a nice numbering scheme you can use to organize your numbers into sections, e.g. Starting with 100000 for your main form and continuing with 101000 or 110000 for each secondary form, etc.
But then I wanted to use descriptive string IDs instead of numbers for my Help topics. I started using THelpRouter, which is part of EC Software's free Help Suite at: http://www.ec-software.com/downloads_delphi.html
But then I settled on a Help tool that supported string ID's directly for topics (I use Dr. Explain: http://www.drexplain.com/) so now I simply use HelpJump, e.g.:
Application.HelpJump('UGQuickStart');
I hope that helps.

We use symbolic constants. Yes, it is a bit more work, but it pays off. Especially because some of our dialogs are dynamically built and sometimes require different help IDs.

I create the help file, which gets the help topic ID, and then go around the forms and set their HelpContext values to them. Since the level of maintenance needed is very low - the form is unlikely to change help file context unless something major happens - this works just fine.

We use Help&Manual - its a wonderful tool, outputting almost any format of stuff you could want, doc, rtf, html, pdf - all from the same source. It will even read in (or paste from rtf (eg MSWord). It uses topic ID's (strings) which I just keep a list of and I manually put each one into a form (or class) as it suits me. Sounds difficult but trust me you'll spend far longer hating the wrong authouring tool. I spent years finding it!
Brian

Related

Setting lsp-dart indentation

The Flutter/Dart project
recommends
using the lsp-dart package.
I'm quite partial to an indentation of 4 spaces. What's the appropriate way to set it in ~/.emacs?
Curiously, flutter format itself doesn't offer such an option, making for a rather heavy-handed set of tools.
flutter format uses the heavily road-tested values from the home office. And yes, it's highly opinionated, and ensures whitespace or rewrapping doesn't needlessly occur when editing someone else's code and submitting a pull request. Considering the hoarde of people working on Dart at Google, this is a wise choice.

Tools for searching full text in iOS bundle

Sorry for the generalized question...I have been hunting for a long time and haven't found anything I can use or easily adapt yet. I'd really appreciate any pointers!
I'm building a reference app that will contain several textbooks in plain-text format. I want the user to be able to perform a search, and get a table back with a list of results. I have a working prototype, but the search logic that I wrote isn't all that smart and it's been hell trying to make it better.
This is obviously a fairly common problem so I'm looking for a tool that I could adapt to the task. So far I've found Lucene (http://vafer.org/blog/20090107014544/) and Locayta (http://www.locayta.com/iOS-search-engine/locayta-search-mobile/)
Lucene appears to have been last updated for iOS 2...I don't even know if I'll be able to rework it myself. Maybe.
Locayta would probably work great, but a commercial license is $1,000 and I may not soon recoup that with this app, as it's a niche market.
Thanks!
We stumbled upon the same predicament where I work, and have yet to decide on a solution.
Locayta seems promising, but barring that, I've looked into SQLite's FTS3/FTS4 as well.
The only issue seemed the lack of a way to match partial words. It's easy to search for fields that contain whole words (eg. "paper" matches "printer paper", "paper punch", and "sketch paper"), or words that start with something (eg. "bi*" matches "binder", and "bicycle"), but there's no built in way to match a suffix.
If you don't require that functionality, FTS3/FTS4 might work.
I see you mentioned in the follow-up that your SQLite didn't recognize FTS3(), and I had the same issue at first.
Apparently it's not bundled into the iOS version by default, instead you have to download the SQLite3 amalgamation, and include it in the project manually. As found at is FTS available in the iOS build of SQLite?
Also note, the SQLITE_ENABLE_FTS3 variable is not enabled by default, you just have to add it to the configuration as detailed at http://www.sqlite.org/fts3.html#section_2
Hope this helps.
If you can translate plain C code to iOS Objective-C, then Apache Lucy (a loose "C" port of Lucene) might be worth a look.

Extracting ePub Excerpt

I've read about the ePub format, standard, structure, readers, tools and available developer techniques to manipulate/convert/create ePubs but there is no such thing as a magical function (so far) to extract a particular length of characters to create an excerpt of the book. And that's precisely what I'm looking for: A way to extract the first X words of an ePub.
The first approach I'm considering (not my favorite btw) is creating a parser to read all the ePub metadata and start parsing the xml files in the right order until I have enough words to create the excerpt of a determined ePub (I will appreciate some feedback in this direction)
The second way (which I can't find so far) is an existent tool/function or parser (in any language) which returns (hopefully) the plain text of the ePub so I can collect the first X words in order to create my excerpt.
Do you know about any tool which can help me achieve the second option?
You should have a look at Apache Tika: http://tika.apache.org/
You can use it from command line, or as a java library or even in server mode to extract text from ePub.
Hope this will help,
F.
Jose,
I'm not aware of any tool to do what you want. Let me comment on your first approach, though. If you do find a tool I hope these comments allow you to evaluate it.
I think your approach is fine and, if you want to do a good job of creating an extract, you may want to own this step anyway. I would suggest you,
grab the OPF file and look for a GUIDE section. If a GUIDE section exists, check the types that are given. Some are probably not relevant for an excerpt (cover,title-page,copyright-page). Many books will not have the types explicitly stated but this should help where they do.
now go through the files in sequence in the SPINE section, excluding anything that is irrelevant, and read through enough XHTML files to get your excerpt.
while in the OPF file grab a bunch of metadata if this is relevant for the excerpt (title, creator, date are mandatory, I think, and some authors will also put in a whole bunch of other metadata such as keywords).
If you are creating a mini-EPUB with this excerpt you will need to pick up any CSS, Audio, Video, Image and Custom Font files that get referenced in the XHTML files used to make your excerpt. You may even choose to use the original cover file for the cover file of your excerpt epub.
If you working with fixed layout books with fun stuff like Read Aloud AND you want to create a mini-EPUB as an excerpt, you may be better off going with a page count rather than a word count. Don't forget to include any SMIL files into your excerpt and to make it look nice: (i) don't split a two page spread and (ii) make sure that the first page is an odd numbered page if odd in the original or even if even numbered in the original - to do this you may need to add a blank filler page (get the odd/even wrong and subsequent two page spreads won't be facing each other)
I hope that helps.

Where should I begin when building a component?

I am looking to build my own component and have no idea where to begin. I have some Delphi books but they are old and outdated, and am looking for some recommendations on tutorials/books to help me do this. The component will be pretty simple, basically 2 labels and an image. I need hundreds of these in an array, so I thought a component would be the best route. The text will adjust based on width etc, and have some mouseover events. So basically, where do I begin?
I am using Delphi 2009, this will be a win32 app.
Thanks!
You can order Ray Konopka's book Dev. Custom Delphi 3 Components - PDF for 25$. It's a specialized book on the subject and very good for a beginner too.
The main principles behind developing components is:
Whether the component is visual or
not (Does it need a Canvas to paint on)
Does it need a window handle or not (visual or non-visual)
Once you answered those questions you can look at Delphi's source code for examples.
As far as I know, Delphi Component Design, by Danny Thorpe, is still the best book on the subject. Component design hasn't changed significantly in the last 15 years, so whatever books you have probably aren't as outdated as you think. There are three things to keep in mind while reading older references:
Names of certain units have changed. There's no DsgnIDE anymore, for example. It's DesignIDE instead.
Design-time code is strictly separated from run-time code now. This means you can't use DesignIDE in your component's unit, or else you're barred from using run-time packages. Older Delphi versions didn't have this technical restriction (although it's always been a legal restriction), so old code examples you find might need to change a little bit.
Strings are Unicode now, so as with all old code examples you find, there might be some invalid assumptions about character sizes that you'll need to recognize.
The biggest obstacle to writing components is that you're expected to use various protected members of the classes you descend from, but those frequently aren't documented, so you'll have to be much more willing to go read the VCL source code for examples of how various methods are used.
The easiest way to do what you want is to create a new form. Drop the labels and image and arrange them the way you want; if it suits your need, put them on a panel so they can be moved around as a unit.
Select all the components you want included (and including the panel if you chose to use one), and then click the Component item on the IDE's main menu, and select the "Create Component Template". (It's only enabled if you have selected components on the current form.) A dialog will appear asking you for a name for the new component, and the Component Palette page on which you want it to appear.
Take a look at this article, which describes how to build new components made up of a group of existing components.
Don't worry about your books being old.
Just about everything from the old days still works fine and what little doesn't is generally due to name conflicts or the addition of Unicode in the 2009 version.
They aren't Microsoft, they don't go breaking old code without good reason. In fact, take some code from the old DOS days--assuming it doesn't try to manipulate the screen it's likely to run with minimal fixup.
Don't worry about your old books! Since v3, Delphi hasn't changed much. This is why most of the programs compiled with D3 still compiles in D7 or even newer versions. And if it doesn't compile, probably you need to change a line or two, here and then.
I would recommend you to search other VERY simple components on Internet and see how they are made. Then make your own and post it here. Let other take a look at it and suggest improvements or spot bugs.
About your control's design:
1) maybe you DON'T need those two labels. You can just paint the text directly on the image. If you have lots of those components as you say, you may save a little bit of memory.
2) you may NOT want to have lots and lots and lots of images loading in one form. The overhead may be significant. What you can do is to load the pictures ONLY in images that are visible on screen - and you will put on screen ONLY 5-10 images (or whatever number of images you can show on the form without going out of screen). As the user scrolls down, you keep the same same TImage controls on screen but you load new (next) images in them.
3) You may not want to store labels and TImage in an array (I suppose it is an TImage because it seems you want to show them on the screen else you won't need labels - you need to explain your problem in more details if I got it wrong). But you can store a TBitmap and the text (that you want to display in labels) instead.
So, you may need to calculate how much CPU/disk overhead your hundreds of controls will create and how much memory they need. If you stay well under 1GB and the loading time is under 10 seconds, then it is relatively ok. IF not, you may want to think about your control's design before starting to actually implement it.
Hope this was helpful.
See ya.

Delphi printing primer

I need to add printing capabilities to an app and I have been looking around for information about printing. Logical/physical sizes, dpi, font scaling, etc, lots to digest since I never programmed printing into any app before.
Are there any sites that would offer a primer on the topics of page sizes, margins and all the other elements required to understand printing on Windows? I've been looking around for a while but what I find is either cryptic or years old...
I've been playing around with TPrinter, but I would like to build solid printing functionalities and understand what I'm doing better.
Using a report solution is not an option, even though I'm sure it would provide better results much sooner.
Two links to get you started:
Printing with TPrinter
Printing via the TPrinter Canvas
I think that you are looking too lowlevel.
Try looking at the build reporting tools (Rave or whatever is in your product).
Personally i am using a product called Report Builder from Digital Metaphors.
But if you want to do the lowlevel stuff lot og good information can be found at efg's computer lab - printing
Well, I have done things a variety of ways in the past, including the "hard way" with TPrinter. In fact, I recently had to do that again to run a special inventory label printer.
On the other hand, sometimes you are better off taking work others have done and using it for your benefit. I agree that ReportSmith isn't so great, and also it's Delphi (and Windows) specific. Using Excel or Word has those limitations, plus the fact that the user has to actually have them installed.
One thing I have done to make printing easy for some simple applications is just to generate an HTML file and call the user's web browser, then they can print it. HTML tables can be created relatively easily for numerical data, and you can include photos, etc. as well. This works well for some applications, and works on every platform where a web browser is installed. The downside, of course, is that HTML isn't the most precise layout language.
The version of Delphi you´re using is important. A number of Delphis came with print engines like ReportSmith (ugh). Another option thinking laterally is to use MS Word as a print engine. I´ve hooked into instances of Word & Excel before & utilised their functionality. As to raw printing using TPrinter or the print method of TForm you´d have to be pretty desperate. I seem to recall the Pacheo / Texeira Delphi books coming with a pretty good overview so you might want to see if you can find a copy of that somewhere.

Resources