User to user discussion and support for UltraEdit, UEStudio, UltraCompare, and other IDM applications.

Syntax highlighting, code folding, brace matching, code indenting, and function list
13 posts Page 1 of 1
The SAS statistical software uses comments in two styles: the usual block comment
Code: Select all
/* */
and additionally
Code: Select all
* ;
(asterisk ... semicolon). Statements are separated by semicolons in SAS. When I define
Code: Select all
Block Comment On Alt = * Block Comment Off Alt = ;
the part of the following expression
Code: Select all
after the asterisk gets highlighted as a comment, which is clearly wrong. I was unsuccessfull at using Line Comment definitions so far.
How can I fix this?
Impossible! How should UltraEdit know when * is used as multiplier and when as start of a comment. UltraEdit is a general text editor and not an SAS interpreter. Best you use always /* */.

Or you help UltraEdit's syntax highlighting engine on this bad syntax and use as start of the comment always for example *! and define also *! as alternate block comment on.
Danke, Mofi!
It might prove difficult to teach that trick to old programs written by other people... I'll stick to my imperfect solution. I guess only regexp would help in my situation.
How about this: I would say that, 95% (or more) of the time, when people use * and ; to define comments in SAS, the * appears in the first column. Maybe it is possible to tell UltraEdit to recognize * as the start of a block comment ONLY when * appears in column 1?
That's possible for line comments, but not for block comments. The nature of block comments in most program languages is that they can start everywhere and end everywhere whereas there are many program languages which specifies line comments to be valid only in certain columns.
I am having the same issue. Although, this thread is over 5 years old but the problem still persists.

Here are my thoughts. I did some research and found there is a Wordfile tag called "Line Comment Preceding Chars". I don't know the exact functionality of this tag but I assume that you can specify what charcters are valid BEFORE a Line Comment symbol which in this case is an asterisk. In SAS, line comment can start with an asterisk in any column provided all preceeding characters on that line are spaces. If the asterisk appears somewhere in middle of the line, then it is not a comment. So, I added the following in my wordfile to include only space and tab as valid character before line comment:

Line Comment Preceding Chars = [ ^t]

I was hoping that only the following line will be highlighted as a comment (asterisk in column 3, not column 1):
Code: Select all

And the following line should not be a comment:
Code: Select all

My problem is that it still doesn't work as expected.

Can anyone throw some more light why this particular tag not working as intended.

Line Comment Preceding Chars = is for line comments and not for block comments. I wrote already once in this topic that block comments can usually occur anywhere in a file in nearly all languages and therefore there are no additional limitations possible like for line comments.
Hi Mofi,

Thanks for the reply.

I am also referring to Line Comments and not Block Comments. In SAS, Line comments start with an asterisk (*) and block comments start and end with /* and */. For a text to qualify as Line comment, the line must start with an asterisk (in any column). The comment is terminated by SAS line terminator, semicolon. Here is c/p from SAS wordfile:

/L20"SAS 9.1.3" Nocase Line Comment = * Line Comment Preceding Chars = [ ^t] Block Comment On = /* Block Comment Off = */ String Chars = "' DisableMLS File Extensions = SAS LOG.

The bolded entry is what I added. Please let me know if I am interpreting it wrong.

The two users above posted that a single asterisk is the beginning of a block comment with a semicolon for marking end of the block comment. That is different to your statement.

However, it is possible to limit interpretation of an asterisk as start of a line comment. But according to help page with title Syntax Highlighting you have to specify a negative character set definition as by default all characters are already valid.

Line Comment Preceding Chars = [~!-~]

worked very well on your example. This expression means all characters except those in hexadecimal range 0x21 (exclamation mark) to 0x7E (tilde) are valid. I have tried also [~!-ÿ] to define the negative character set from decimal range 33 to 255, but for some reason it has not worked. Using any character greater decimal 127 as end of range results in a not working limitation. (Without knowing the code, I know how it looks like because of the observed behavior - the typical signed/unsigned problem on character comparisons.) However, I think that does not matter for SAS files.

The wordfile sas.uew which can be downloaded from user-submitted wordfiles has been updated accordingly.

PS: I have read now also Overview of the SAS Language - Comments and understand now the problem with asterisk being start of a line respectively block comment ending with a semicolon.
Hi Mofi,

That is just perfect. Thank you for a thorough testing and making it work exactly as intended.

On an separate note, it was not just a matter of highlighting of right comment lines but it was affecting other more important functionality of UE. I am referring to "Brace Matching". Without this fix, all text after the astrisk was being treated as comment and UE will not match braces in Comments UNLESS I turn on the option "Brace match in comments", which I would prefer not to do. It was really painful where I had 5 or more sets of braces in one statement.

So, thank you again for all the help.
I have a very long list of statements in a SAS script that I would like to be able to FOLD.

However, I cannot determine what folding indicators to use, as they can not be anything that SAS will interpret as usable code or generate an error. So I assume the open/close indicators will need to contained in a comment.

I have downloaded the newest wordfile from the UltraEdit site, but cannot get it to work as I desire.

I have modified the uew file with the following:
Code: Select all
/Open Fold Strings = "%macro" "data" "proc sql" "startfold"
/Close Fold Strings = "%mend" "run;" "quit;" "stopfold"

and if I place these into my script the code folds as expected.

However, when I load the script into SAS, the file fails, as the words startfold and stopfold are not approved for SAS code.

When I add a comment marker so SAS doesn't get upset, the folding no longer works. I have tried these two scenarios:

Code: Select all
* startfold ;
      blah, blah
      blah blah
* stopfold ;


Code: Select all
/* startfold */
        blah, blah
        blah blah
/* stopfold */

Is there a way to put the folding indicators inside a comment?

Open Help - Index, switch to tab Index, enter Syntax Highlighting and open this page. There are 3 chapters about folding:

  • Open/Close Fold Strings
  • Ignore Fold Strings
  • Open/Close Comment Fold Strings
What you most likely (not tested by me) need is:

Code: Select all
/Open Fold Strings = "%macro" "data" "proc sql"
/Close Fold Strings = "%mend" "run;" "quit;"
/Open Comment Fold Strings = "startfold"
/Close Comment Fold Strings = "stopfold"
Best regards from Austria

Thank you that worked exactly as I needed it to.

13 posts Page 1 of 1