Automatic numbering of chapters in comment lines?

Automatic numbering of chapters in comment lines?

1581
Power UserPower User
1581

    Sep 24, 2007#1

    Hello

    writing my programm code with UE 10.10 I use a lot of lines for comments, and inside these comments I use a "hand made numbering":

    Code: Select all

    ;; Step 1: setting variables
    programcode ...
    
    ;; Step 2: calculate something
    programcode ...
    
    ;; Step 3: display results
    programcode
    These numbers are in accordance with a program-description, written in MS Word.

    If I have to change my code - i.e. I have to insert a new "Step 2: controll data", I have to insert a new line in MS Word and all following numbers are changed automatic.

    In UE I have to change the numbering all following steps by hand:

    Code: Select all

    ;; Step 3: calculate something
    programcode ...
    
    ;; Step 4: display results
    programcode
    Is there any way to make this "numbering of comment lines" in an automatic way?

    Best regards

    Peter

    6,688586
    Grand MasterGrand Master
    6,688586

      Sep 24, 2007#2

      You have to put into a macro file first my universal CountUp submacro posted at counter and available also in the macro files in the ZIP archive at Macro examples and reference for beginners and experts.

      Then create the main macro which when executed renumbers your comments. The macro property Continue if a Find with Replace not found must be checked for this macro. If nothing is selected when the macro is executed it starts from top of the file and first number used is 1. If something is selected, it assumes that the number of the just inserted comment is selected and just renumbers everything below with the selected number+1 as first value for the next comment below.

      InsertMode
      ColumnModeOff
      HexOff
      UnixReOff
      Clipboard 9
      IfSel
      Copy
      Else
      Top
      "0"
      StartSelect
      Key LEFT ARROW
      Cut
      EndSelect
      EndIf
      Loop
      Find RegExp ";;[ ^t]+Step[ ^t]+[0-9]+:"
      IfNotFound
      ExitLoop
      EndIf
      Key LEFT ARROW
      SelectWord
      PlayMacro 1 "CountUp"
      EndLoop
      ClearClipboard
      Clipboard 0

      Add UnixReOn at the end of the macro if you do not use UltraEdit style regular expressions by default - see search configuration. Macro command UnixReOff sets the regular expression option to UltraEdit style.
      Best regards from an UC/UE/UES for Windows user from Austria

      1581
      Power UserPower User
      1581

        Sep 24, 2007#3

        Thank you Mofi

        I will check it.

        Peter