SPSS syntax highlighting in UltraEdit

SPSS syntax highlighting in UltraEdit

3

    Nov 02, 2005#1

    Hi!

    Has anyone of you ever seen something to do SPSS syntax highlighting in UltraEdit. I'm not quite sure if I want to go through writing this myself.

    344
    MasterMaster
    344

      Nov 02, 2005#2

      Hi Michael,

      look here: User-submitted wordfiles for UltraEdit/UEStudio

      Please always first search and then ask. :wink:

      Regards Bego :D

      3

        Nov 02, 2005#3

        Thank you, you are right. :-)

        Still, is there anyone who has some experience with this highlighting?
        It works pretty well.

        I still have a problem with this part:
        Block Comment Off = .
        It says that the comment ends when an "." is encountered.
        In SPSS, "." ends an command, and the command that marks the beginning of an comment is "*".

        So if I have commented out a file opening line:
        *GET FILE='D:\spssfile.sav'.
        Then the "." between filename and extension is interpreted as the end of the command.
        The rest of the line:
        sav'.
        is interpreted in the normal way and so there is an unclosed string.

        Commands that follow later are interpreted as if they are part of that unclosed string.

        Any Idea, anyone? I can't find anything about distinguishing between commentary ending and command ending if the same character is used.

        So I need a way to ignore the ==> . when it is within quotes.

        6,615550
        Grand MasterGrand Master
        6,615550

          Nov 02, 2005#4

          I'm an expert for UltraEdit syntax highlighting and I'm sure, you will not be able to highlight your example correct.

          SPSS has a crazy syntax! How does the SPSS interpreter know, where the . is really the end of a comment? Does it also interpret the content of a comment?

          If you want highlighted such comments correctly in UltraEdit, you have to expand the block comment strings by yourself to a string, which is surely always the end of a comment.

          You could for example always use *<- instead of only * and ->. instead of only . in all such situations, where a single . exists inside a comment.

          Then you need this comment and string specifications in the wordfile:

          Code: Select all

          Block Comment On = *<- Block Comment Off = ->. Block Comment On Alt = * Block Comment Off Alt = . DisableMLS
          DisableMLS is to disable multi-line strings. Does SPSS allow multi-line strings?

          As you can see, the expanded block comment strings are used first and the single block comments are the alternative block comments. Now you only have to use the expanded block comment strings for comment contents like your example.

          You can set the color for alternative block comments to the same color as for line and normal block comments, if you don't want to see a difference. But I think, if you use this trick, it is helpful for you to set different colors (or only different background colors) for the 2 block comments, because then you can easily see, where you have added extra characters to highlight a comment with a . correct.
          Best regards from an UC/UE/UES for Windows user from Austria

          3

            Nov 02, 2005#5

            Mofi wrote:SPSS has a crazy syntax! How does the SPSS interpreter know, where the . is really the end of a comment? Does it also interpret the content of a comment?
            SPSS interprets "." as end of a command if it is the last character in the line.
            So,
            AAAAA
            AA"file.ext"AAA
            AAAAA.
            BBBBB.
            CCCCC
            CCC"file.ext"CC.
            are three commands with 3,1,2 lines, respectively.

            You don't have to use multiline commands, but it's rather annoying to change all your scripts that you use/expand more often to this less readable form.

            I can't get the new Block comments to work, and even if I did, I'm not quite sure If all the people here would change their scripts.

            The main problem still is that I dont want the "." in
            * GET FILE= "filename.ext".
            to be parsed.

            An example:
            SAVE OUTFILE='D:\dir\file.sav'.
            is parsed correctly. The "." is within quotes and is not considered end of command.

            But when you comment that whole line out:
            * SAVE OUTFILE='D:\dir\file.sav'.
            the comment ends on the "." after "file"
            So it's more a problem of priorities. If UEdit thinks that there is only comment coming and is ignorick quotes, then the comment is off when there is a "." within the comment, like here:
            * This is a comment and the last part is . ignored.
            SPSS is cool with that. Only UEdit screws up.

            Greetings from Frankfurt! :-)

            6,615550
            Grand MasterGrand Master
            6,615550

              Nov 02, 2005#6

              michael.steininger wrote:SPSS interprets "." as end of a command if it is the last character in the line.
              Aha! This is the special trick SPSS uses. Such an extra condition for block comment off is valid or not cannot be specified within UltraEdit. I have also never seen such an extra block comment condition.

              UltraEdit handles block comments like most language interpreters also do. First it searches for the "block comment on" string. If found, it searches for the "block comment off" string. What is between these two strings is not interpreted in any way. All characters between the two block strings are completely ignored.

              The only interpreters I know, which also analyze codes inside a comment are HTML browsers, which must interprete CSS styles and javascript code also inside the HTML commands <!-- -->. But browsers know when they have to look into the comments because the HTML element <script before the <!-- comment informs the browser, that a javascript code follows and <style element is the info for the browser, that a CSS code follows.

              If you don't like the workaround I wrote, you can only ask IDM by e-mail for a new feature. You would need for SPSS the possibility to define a line ending character like \r or \n (or ^r, ^n or ^p) as "character". This could help you.

              Block Comment Off = .\r should be intepreted by UltraEdit as hex string 2E 0D and not as 2E 5C 72.
              Best regards from an UC/UE/UES for Windows user from Austria

              2
              NewbieNewbie
              2

                Dec 12, 2006#7

                SPSS syntax has its roots in Fortran. The syntax highlighting works perfect when you add FORTRAN_LANG to the wordfile.txt Here is the start of the relevant line.

                /L20"SPSS Base" FORTRAN_LANG

                I am currently using SPSS 14 and UEdit32 12.20.

                UPDATE: using FORTRAN_LANG marks out all comments correctly, but following the FORTRAN specs all C characters starting a new line do also trigger the comment behavior. Thus all COMPUTE and CROSSTABS statements are marked as one line comments. For CROSSTABS it is not a big problem as they are usually devided on several lines anyway, and only the first is marked as a comment. For a series of subsequent COMPUTE statements it is unfortunate though.

                Currently on SPSS 15 and UEdit 32 13.20

                Best,
                Eero