syntax highlighting for numbers?

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
ryancw
Posts: 4
Joined: Tue May 13, 2003 6:39 am

syntax highlighting for numbers?

Post by ryancw »

Is there an easy way to highlight numbers in a different color? I have a file of ICD-9 codes (International Classification of Diseases): lots of text, most of the lines beginning with a 3-5 digit number (the ICD-9 code). The numbers range 001-999, with up to 2 decimal places. A minority of the numbers start with a "V". Can I do this without having to manually type in all the numbers I want in color. Obviously that's impractical, since there are aobut 100,000 of them.
Thanks.
User avatar
bbadmin
Site Admin
Posts: 816
Joined: Mon Feb 17, 2003 8:54 pm
Contact:

Post by bbadmin »

Create a new document class, for files with the appropriate extension, and use the following syntax definition file:

Code: Select all

; numbers.syn
; Syntax definition file for numbers, with optional V prefix

C=1

[Syntax]
KeyWordLength = 1
IgnoreCase = No

[Keywords 1]
V
Choose the same colors for Keywords 1 and Numbers, in your new document class.

Keith MacDonald
Helios Software Solutions
ryancw
Posts: 4
Joined: Tue May 13, 2003 6:39 am

Post by ryancw »

Sounds easy enough, but when I try this, I get an error message: something to the effect of "invalid data in line 4 . . . of numbers.syn" The problematic line seems to be C=1. I don't understand that, since the HELP says specifically that C=1, or a variant, should be the first line of a syntax definition file.

Also, where in the numbers.syn file is the instruction to color the numbers?

Thanks.
Ed
Posts: 103
Joined: Tue Mar 04, 2003 9:09 am
Location: Devon, UK

Post by Ed »

My syntax files have C=1 and they work OK. Can you post the actual file? Have you saved it in DOS format (not UNIX)? Are there any spurious tabs or spaces?

The color of the numbers is set in Configure->Preferences->Document Classes->"Your Class"->Colors->Numbers (At the bottom of the list)
ryancw
Posts: 4
Joined: Tue May 13, 2003 6:39 am

syntax definition file for numbers not working

Post by ryancw »

Well, just keep in mind that I know just enough about computers to be dangerous . . .
I copied the suggested code, and then pasted it into a new TextPad file. When I went to save it, I left all the defaults in the dialogue box alone, and saved it as numbers.syn. So I guess that would be ANSI encoding, and PC format. It ended up saved as numbers.syn.txt. I put that file in C:\Windows\ApplicationData\TextPad, and I renamed it to numbers.syn (via Windows Explorer.)

I then got the error message I posted previously.

Now I'm at home, and tried the whole thing again. This time, using the menus in TextPad, I associated .syn files with TextPad (I don't know if that's necessary or not, but it was the only way I cou8ld think of that would allow me to save it as a .syn file, rather than as a .syn.txt file and then have to rename it.) I also saved it as PC format and DOS encoding. Now I don't get the error message, but I also don't get colors. (I found what you are talking about regarding colors for numbers--thanks.) But still no highlighting.
ryancw
Posts: 4
Joined: Tue May 13, 2003 6:39 am

Whoa, now we're getting somewhere

Post by ryancw »

Well, another silly mistake on my part was associating .icd files (that's what I am calling my files full of ICD-9 codes) with TextPad, and with the particular syntax highlighting, rather than *.icd. Fixed that.

Then I set my *.syn files to have DOS encoding by default.

Then I started from scratch, and rather than copying and pasting the suggested code from this forum, I typed it into a new file, fresh, and saved it as numbers.syn.

That seems to have done the trick. I've got color!

Thanks for all your help. Great software, and great user-community support.
Post Reply