This message contains graphics. If you do not see the graphics: Graphic Version.
Syntax Highlighting, TX Forum News, Italian TX App

Are You Getting The Most Out Of The TX Discussion Forum?

While looking at the back-end of the TX Text Control Discussion Forum last week, I noticed that only a very small percentage of people use the "Email replies to this thread, to the address above" function of the Forum.

I guess that quite a few people do not know what this little check box does. Whereas I know that we covered this feature a few months ago, I feel compelled to reiterate how to get the very best out of the TX Text Control Discussion Forum and how you can save your precious time, by checking this little box.

Say for example, you post a message posing a question about some TX issue, which intrigues you. But you forget (or more likely you don't have time) to look at the discussion forum on a daily basis, to see whether someone has answered your question. This is where the "Email replies to this thread, to the address above" comes is handy. Clicking the check box will cause all answers to your question to be e-mailed directly to you automatically, with no intervention on your part whatsoever. How convenient! However, convenience is not the only advantage. Once you have all the answers in your e-mail software you can archive them and use them for later reference, without having to reconnect to the TX Discussion Forum.

Having said that, we do of course recommend that you look at the TX Discussion Forum on a regular basis, as there always many interesting discussions taking place at any one time. Furthermore, many support questions have already been answered by other TX Users and TX Support personnel.

Yet More New Documentation

I know that we have written this in the last three newsletters :-) but there is yet more new HTML documentation for you to look at.

New Sample TX Application From Italy

Francesco Rumma from the Centro Studi di Informatica Giuridica Juris Quick was kind enough to send me a great example of how they are putting TX Text Control to work. Quick Organizer - that's their app - is an interactive software for European lawyers, which contains an index of files, a diary, invoicing software, a list of clients, opponents, witnesses and correspondents. Their software provides a classic example of what one can actually achieve with TX Text Control.

Top TX Tip: Syntax Highlighting

In the last few weeks, we have been receiving an ever increasing number of support requests, asking whether it is possible to create a programming / code editor that highlights a predefined set of keywords (like Ultraedit).

Well, of course it is! This week we are going to show you how to build your own TX Text Control-based Code Editor, or to put it in more technical terms, we gonna to show you 'Syntax Highlighting'. Cannot wait to get started? Read on.

Naturally, the first step is to create a list of the keywords that we want to highlight. In our example we are going to use HTML and C/C++ keywords, as they are pretty easy to find out.

We have decided to put all the information about the syntax - i.e. which words are to be highlighted - into a separate file. We will then load this file when we want that particular syntax. In our example, these files are called keyw_html.txt and keyw_c.txt. (Try and guess which one is for HTML and which one is for C++ :-) )

In this file, there is not only the keywords, but also other important information such as 'delimiters'. A delimiter is a character, which separates two words from another. Typical examples of delimiters are 'Space', 'vbCr', 'vbLf', ',' and '.'

You should note that these delimiters are dependant upon the particular type of language. In HTML, for example, the '<' is an opening delimiter and '>' is a closing delimiter, such as:

<p>Hello world.</p>
^ ^            ^  ^  These are the delimiters, in this case.

Separating the words with delimiters at this point, makes our life much easier later on when we come to parsing the text.

OK, enough talk about what we need to do and now down to how we are going to do it.

Once we have got all the keywords and delimiters into memory, we load the text from TX Text Control into the local variable szTmp and search for the first word. This is compared against a list of keywords. Should a match occur - i.e. the current words appears in the keyword file - then it is selected and changed to another color. Then we search for the next word and repeat for every word in the document.

Here is the Visual Basic code to do exactly that:

Public Function CheckEntireDoc() Dim nOldSelStart, nOldSelLength As Integer Dim nPos As Integer, nLen As Integer Dim nMax As Integer Dim szTmp As String Dim index As Integer Dim nPercent As Long With Form1.TXTextControl1 ' Turn off the wait cursor SendMessage .hwnd, TX_SETMODEEX, TF_NOWAITCURSOR, 0 ' Lock TX window update LockWindowUpdate .hwnd ' Store current selection nOldSelLength = .SelLength nOldSelStart = .SelStart szTmp = .Text nMax = Len(szTmp) ' Find next word nPos = NextWord(szTmp, 0) nLen = NextDelimiter(szTmp, nPos + 1) - nPos While nPos < nMax index = IsKeyWord(Mid(szTmp, nPos + 1, nLen)) If index <> -1 Then .SelStart = nPos .SelLength = nLen .ForeColor = Colors(index) End If ' Let the user know how far we are... nPercent = CLng(100) * nPos nPercent = nPercent / nMax ' Update only in 5% steps. It's a lot faster this way... If (nPercent Mod 5 = 0) Then Form1.Caption = "TX Syntax Highlighting Demo (" + str(nPercent) + "%)" End If ' Find next word nPos = NextWord(szTmp, nPos + nLen) nLen = NextDelimiter(szTmp, nPos + 1) - nPos Wend ' Restore current selection Form1.Caption = "TX Syntax Highlighting Demo" .SelStart = nOldSelStart .SelLength = nOldSelLength ' Unlock window update LockWindowUpdate 0 ' Turn on wait cursor SendMessage .hwnd, TX_SETMODEEX, TF_WAITCURSOR, 0 End With End Function

Using this function we are implementing the above-described principle and thus are able to check the entire document.

We have used LockwindowUpdate to prevent the user from seeing the text while it is being colored - the user can only see the text ONCE it has been colored and not DURING the phase that the coloring process is happening.

Next week, we will bring you the second part of this TX Tips and Tricks and show you how to create a text-checking function with which the user can interact. It would be possible to simply check the entire document again, but if we were confronted with a somewhat lengthy document, our little application could become a bit on the slow side. And we don't want that to happen, as we all know how impatient our end users really are! :-) But more on that next week...

Best regards

The Newsletter Team

Text Control GmbH respects your online time and privacy. We only send this newsletter to TX Text Control customers and people who have signed up to receive it. However, if you would prefer not to receive future issues of the newsletter, you may unsubscribe at any time. If you received this newsletter forwarded from a colleague or friend, you may wish to subscribe directly.

Sent to: N/A.

Imprint | Unsubscribe | Subscribe

© 2020 Text Control GmbH. All Rights Reserved.