What is the meaning of a pipe "|" in Delphi 7? - delphi

As the title says, I would like to know what is the meaning of the pipe (or tube) "|" in a Delphi code. See that screenshot :
I know the meaning of "*" which is a wild card for one or more characters, but I can't find what means "|".
Thanks

This is a question that can be answered by reading the documentation. It can be found here:
Vcl.Dialogs.TOpenDialog.Filter
To create file masks in program code, assign a value to the Filter
property that consists of a description and a mask separated by a
vertical bar (pipe) character. Do not include spaces around the
vertical bar. For example,
OpenDialog1.Filter := 'Text files (*.txt)|*.TXT';
Multiple filters should be separated by vertical bars. For example,
OpenDialog1.Filter := 'Text files (*.txt)|*.TXT|Pascal files (*.pas)|*.PAS';
To include multiple masks in a single filter, separate the masks with
semicolons. This works both in the Object Inspector and in program
code. For example,
OpenDialog1.Filter := 'Pascal files|*.PAS;*.DPK;*.DPR';
You might like to absorb the hints found here (How can I search for Delphi documentation?) in order to help you in the future.

In Delphi, the | character is often used as separator in certain string properties to differentiate between:
The description and the mask of a file filter, as used in TOpenDialog.Filter.
The short part, the long part and the image index of a hint text, as used in all Hint properties.

The pipe separates the filter expression (on the right) from the caption the user will see (on the left). If you want to apply more than one filter, just append it, also separated by pipes.

For TOpenDialog this is just a syntax to specify in one line of Filter both:
friendly type name (here: Regles de chaurfage)
file extension related to the type (here .fuz)
This is not language operator. This is just some kind of convention TOpenDialog is using.

Multiple filters should be separated by vertical bars.
http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/Dialogs_TOpenDialog_Filter.html

Related

Eggplant : How to read text with special characters like ' _ etc

I am trying to read a text in a given rectangle using readText() function.
The function works correctly except when it has to read some text which has special characters like ' _ & etc.
I tried using validCharacters with readText() function. But it didn't help.
Code -
put ReadText((287,125,810,164),validCharacters:"_-'.ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890") into Login
I tried working with character collections. But that doesn't seem to be right because the text trying to pick is a dynamic text combination of numbers alphabets and a special character. So one cannot create a library of character collection of every alphabet (a-z, A-Z), numbers(0-9) and special characters.
Example of text trying to read:
Login_Userid1_1, Login'Userid1_1
So how do I read such text correctly
Debugging OCR is a bit of an imprecise science. EggPlant has a lot of OCR Parameters to tweak. When designing test cases it's best to try use other mechanisms to gather information whenever possible. ReadText() should be considered a last resort when more reliable methods are unavailable. When I've used it I've often needed to do a lot of trial and error to find the right set of settings, and SearchRectangle to get consistent results. Without seeing exactly what images you are trying to read text from it's difficult to impossible to troubleshoot where the issue might be.
One thing that does stand out to me is that you're trying to read strings that may contain underscores. ReadText() has an optional property IgnoreUnderscores which treats underscores as spaces. By default this property is set to ON. It defaults to ON because some OCR engines have problems identifying underscore characters consistently.
If you want to have ReadText() handle underscores you'll want to explicitly set this property to OFF.
ReadText(rect, validCharacters:chars, ignoreUnderscores:OFF)

Excluding place holder texts from localisations

When I design a cell layout I usually assign a sample text, e.g. 'John Appleseed' to a 'name' label so I can easily see where the field is on the layout and check the composition. Otherwise there is an empty label on a white background. Obviously this text does not need to be translated as it will be always replaced by another value at runtime.
Is there any property I can set in the Object Inspector to exclude this text from .strings / XLIFF file? Translators usually charge per word, so I don't want to send those texts for translation.
For the time being I use '~' prefix and then remove those texts using a Ruby script, but I was wondering whether there is an easier way to do it.
Unfortunately, if you are using ibtool (and you do not really have an alternative) you cannot exclude words directly.
What you can do, is to edit the XLIFF file after you export it and add the attribute translate="no" on the strings you want to exclude. You should make sure that your translators use a XLIFF-compatible tool to translate.
But, imho, this is not any better than your way.
Also see question 1, question 2 and ibtool's manual.

lazarus - TMemo text property

I am using a TMemo box intead of a TEdit box simply because of the multi-line ability.
I was guessing and I used the .Text property to assign a value at run-time. But then I realised that there was no Text property at design time. Rather I found the Lines property.
I checked this page: http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tmemo.html for more info.
I found out that there is no Text property but only a Lines property in that documentation.
Is my use of .Text correct or is it a problem using this?
Here's my code:
if dlgSave.Execute Then
begin
txtSaveName.Text := dlgSave.FileName;
end;
txtSaveName : TMemo
dlgSave : TSaveDialog
Thanks for any inputs.
Lines is a TStrings, a class that is basically a wrapper for an array of strings.
Text is a simple property that when read concatenates the strings together (with lineseparators between them), and when assigned too parses the single string into multiple strings.
I wouldn't worry too much about it, just think twice before using it for huge strings (think hundreds of MBs and bigger), since all the copying done by this highlevel functionality will eat quite some memory.
Another (minor) reason not to use it is if you want reading and writing to be binary the same. Assume you have a text with mixed line endings and you assign it to text and read it back, then the mixed lineendings will be uniform now.

Aligning 2 small molecules in PyMOL

I want to align to ligands in PyMOL like one would do it with protein structures, but I get an error message:
ExecutiveAlign: mobile selection must derive from one object only
I also copied the ligands into separate PDB files, renamed the HETATM entries to ATOM, but still I get this error. I am wondering why PyMOL has problems aligning those small molecules.
PS: Those ligands have similar structure, only different coordinates.
When you align with the align function pymol seeds the structural alignment by doing a sequence alignment first.
You can use the pair_fit function but will have to specify the corespondency between atoms. This function takes two selections, one for each element, that have the same number of atoms.
If the ligands have the exact same chemical structure you can pass the objects directly, if not you will have to make the appropriate selections.
Did you do this through the GUI? That's a bug, the align function never works from the GUI. Try doing it by command line.
align mol1, mol2

How do I put a literal vertical bar "|" in a control's Hint property?

I have an application that allows the users to enter a regular expression (that they craft) to parse a repository of documents. The results of the search are displayed in a TTreeView control. I want to set the TreeView's Hint property (not each Treenode) to the regular expression that was used, but the problem I'm having is that the regular expression can have a pipe (|) character within it (regex OR), which Delphi interprets as the separation between the hint and long hint. I tried replacing each occurrence of | with || hoping it would have the same effect as using && rather than & (such as in menu items) to no avail.
Is there any way to embed a | within a hint without it being interpreted as the separator?
Not exact but perhaps near enough
Component.Hint := Stringreplace(TheHintText,'|',#5,[rfReplaceAll]);

Resources