Community
    • Login

    there is a plugin for inster sequence numbers?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 2 Posters 1.9k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Extreme GioE
      Extreme Gio
      last edited by

      Hi, I need to write some code to draw a chart, datas like:
      var cell00=Math.round(msg.payload.minutely[0].precipitation *600) /10;
      I would to produce automatically:
      var cell01=Math.round(msg.payload.minutely[1].precipitation *600) /10;
      var cell02=Math.round(msg.payload.minutely[2].precipitation *600) /10;

      So I need a plugin to put a number after a text, it can be smart to use the replace button like:
      replace [var cell] with [text before]+number (how many digit, start from)+[text]
      so I can build the first part, then the second one.
      Thanks

      1 Reply Last reply Reply Quote 0
      • Neil SchipperN
        Neil Schipper
        last edited by Neil Schipper

        You could seed a file with rows like:

        01
        02
        03
        04
        05
        

        and then cursor to left of 01 and record a macro that inserts text before it and after it, and ends by setting cursor to left of 02. Then run the macro as many times as needed.

        But a better solution might have nothing to do with editor tricks and everything to do with programming approach. Most modern languages support a structure similar to:

        var CellsArray[64];
        var i;
        for i = 0 to 63:
            CellsArray[i]=Math.round(msg.payload.minutely[i].precipitation *600) /10;
        

        Does yours?

        1 Reply Last reply Reply Quote 1
        • Extreme GioE
          Extreme Gio
          last edited by

          yes it does :) but sometime we need the old method! So there are no plugins, I’ll try to use macro ) Thank you!

          Neil SchipperN 1 Reply Last reply Reply Quote 0
          • Neil SchipperN
            Neil Schipper @Extreme Gio
            last edited by

            @Extreme-Gio Something about your reply (maybe the words “old method”) reminded me of something I put together a while back which was very easy to repurpose to meet your need (completely outside of Notepad++):

            @echo OFF
            
            rem -- Cellvars.cmd -- Ref: https://community.notepad-plus-plus.org/topic/21946/there-is-a-plugin-for-inster-sequence-numbers
            
            rem x is start index, gets incremented; 
            set x=0
            rem xp is the leading padding string used in the var name; stays constant; it's length should be the number of 0's needed while x is a single digit
            set xp=0
            REM set tot num of vars needed
            set count=17
            
            DEL /P out1.txt
            
            :LOOPN9
            	set x2=%xp%%x%
            	REM the number after the ~- should be (length of xp) + 1; example: for 500 vars, need xp=00, and use :~3 in next command
            	echo var cell%x2:~-2%=Math.round(msg.payload.minutely[%x%].precipitation *600) /10; >>out1.txt
            	set /a x=%x%+1
            if %x% LSS %count% GOTO LOOPN9
            

            Save it to new file Cellvars.cmd and execute it at command prompt. Output goes to a file called out1.txt so make sure there’s no local file with that name that you need to keep.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors