If ... Then not indenting properly in Visual Basic

If ... Then not indenting properly in Visual Basic

2
NewbieNewbie
2

    Apr 21, 2007#1

    Hi,

    trying to get indenting working with

    1.

    Code: Select all

    If x Then y
    rather than

    2.

    Code: Select all

    If x Then
       y
    End If
    I've tried telling UE v11 to only indent on "then$" but it seems to do it no matter where the string is found. Any way around this?

    6,687586
    Grand MasterGrand Master
    6,687586

      Apr 21, 2007#2

      Regular expression characters like $ can be used only in the function strings and nowhere else (except Member and Variable strings for the IDE of UEStudio).

      See also the forum topic indenting only when a character is at end of prior line?

      Look in help of UE on the Index tab if you can find the page Artistic Style Formatter dialog. This help page about the tool Artistic Style contains near the bottom of the page the description about the 4 main indent styles ansi, Kernighan&Ritchie, linux and gnu. If you compare the 4 styles, you will see the differences and then maybe you can tell us what is the style you would prefer for Visual Basic. The 4 indent styles are also explained on homepage of Artistic Style. To know which style you prefer could be helpful on your question.
      Best regards from an UC/UE/UES for Windows user from Austria

      2
      NewbieNewbie
      2

        Apr 21, 2007#3

        I don't really care which style. I just don't want UltraEdit v11 to do this:

        Code: Select all

        If x Then y
          next line indented
        This scenario is fine

        Code: Select all

        If x Then
          y
        End If

        6,687586
        Grand MasterGrand Master
        6,687586

          Apr 23, 2007#4

          Now I understand. But there is no solution for that problem. UE doesn't know if the text following indent string "Then" is the code which belongs to the If condition and so the next line should not be indented.

          If it would be possible to specify that an indent string must be on the end of a line, then this would not be a problem. But this is not possible. Write a feature request email to IDM support. But such a limitation would mean you must take care never to have trailing spaces/tabs or a line comment after "Then" when the code is on the next line or UE would be flexible enough to handle this also when the limitation with end of line is active.
          Best regards from an UC/UE/UES for Windows user from Austria

          25
          Basic UserBasic User
          25

            May 11, 2007#5

            dr: Yep, you+ue have a problem. UE syntax highlighting engine seems to be designed for white space insensitive syntaxes. It will fail in your case. Nice try with the $; regular expressions cannot be used for defining syntax tokens. I run into this myself. :cry:

            5
            NewbieNewbie
            5

              Jun 10, 2008#6

              I have If sentences indenting properly in UE 14.

              Simple if statements do not indent:

              Code: Select all

                If bStatus Then bStatus=File_CopyFile(gsRoot & "\Files\UV-Data.RDP", gsFiles & "\UV-Data.RDP", False)
                Custom=bStatus
              
              but if ... end if do indent:

              Code: Select all

                If bStatus And (sClientDir<>"") Then
                  Set oLocalFSO = CreateObject("Scripting.FileSystemObject")
                  sCmd = oLocalFSO.OpenTextFile(sClientDir & "\Lib\" & sScriptFile,1).ReadAll
                Else
                  bStatus=False
                End If
              
              What I did was: I removed "Then" from the /Indent line and added "If" instead, and then I remove "End" from /Unindent, adding "End Function", "End If", "End Sub", "End Select", and "End With", thus ending up with:

              Code: Select all

              /Indent Strings = "If" "Select Case" "Do While" "Do Until" "Else" "ElseIF" "Do" "<td>" "<tr>"
              /Unindent Strings = "Next" "End Function" "End If" "End Select" "End Sub" "End With" "Loop" "Loop While" "Else" "ElseIF" "</TD>" "</tr>"
              
              Regards from Denmark

              Dawk

              1
              NewbieNewbie
              1

                May 20, 2014#7

                Dawk wrote:/Indent Strings = "If" "Select Case" "Do While" "Do Until" "Else" "ElseIF" "Do" "<td>" "<tr>"
                /Unindent Strings = "Next" "End Function" "End If" "End Select" "End Sub" "End With" "Loop" "Loop While" "Else" "ElseIF" "</TD>" "</tr>"
                This is what I need as my code has many If ___ Then ___ on single lines. But I am new to UE and don't know where to insert the code above. Where do I put that code?

                6,687586
                Grand MasterGrand Master
                6,687586

                  May 21, 2014#8

                  With a Visual Basic file currently opened in UltraEdit and syntax highlighted, open Advanced - Configuration - Editor Display - Syntax Highlighting.

                  The installed wordfile respectively language Visual Basic is already selected from the list. Click on button Open and close the dialog with button Cancel.

                  The 2 lines to modify are at top of the opened wordfile. Replace them, save the syntax highlighting wordfile and close it. Now the indent settings have changed for files syntax highlighted with Visual Basic wordfile.
                  Best regards from an UC/UE/UES for Windows user from Austria