Community
    • Login

    there is a plugin for inster sequence numbers?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 2 Posters 2.1k Views 2 Watching
    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 Offline
      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 Offline
        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 Offline
          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 Offline
            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

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors