<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[how to use macro to make my code]]></title><description><![CDATA[[[topic:post-is-deleted]]]]></description><link>https://community.notepad-plus-plus.org/topic/22346/how-to-use-macro-to-make-my-code</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Apr 2026 11:45:25 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/22346.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 05 Jan 2022 21:36:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to how to use macro to make my code on Tue, 11 Jan 2022 10:53:50 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a><br />
Congratulations with your ingenious solution. Although it seems to me that an editor - <em>any</em> editor -  is not quite the right tool for this job. It is as if you are explaining how to build a wooden chicken coop with as only tool the heel of a shoe.</p>
<p dir="auto"><img src="/assets/uploads/files/1641898348403-shoeheel.png" alt="shoeheel.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.notepad-plus-plus.org/post/72860</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72860</guid><dc:creator><![CDATA[Paul Wormer]]></dc:creator><pubDate>Tue, 11 Jan 2022 10:53:50 GMT</pubDate></item><item><title><![CDATA[Reply to how to use macro to make my code on Tue, 11 Jan 2022 02:56:38 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/24098">@igor-lerinc</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@peterjones</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/280">@neil-schipper</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/22926">@paul-wormer</a> and All;</p>
<p dir="auto">I found out a <strong>nice</strong> solution with a <strong>minimum</strong> of actions to proceed ! This further method is <strong>rather</strong> difficult to express but is <strong>finally</strong> easy to execute :-))</p>
<p dir="auto">I will expose my method with a <strong>short</strong> list of <strong><code>6</code></strong> countries ( <strong>Andorre</strong>, <strong>United Arab Emirates</strong>, <strong>Afganistan</strong>, <strong>Albania</strong>, <strong>Armenia</strong> and <strong>Angola</strong> ) which, of course, can be extend to your <strong><code>230</code></strong> items and even more !</p>
<p dir="auto">Basically, you have <strong>three</strong> informative zones and <strong>two</strong> <em>pseudo</em>-zones <strong><code>case n;</code></strong> and <strong><code>R.drawable.flag_</code></strong> + the <strong>current</strong> country code, located on the <strong>next</strong> line</p>
<p dir="auto">Let’s place <strong>each</strong> of these <strong><code>5</code></strong> zones in a <strong>different</strong> file, from file <strong><code>A.txt</code></strong> to file <strong><code>E.txt</code></strong>. Presently, the files <strong><code>B</code></strong>, <strong><code>C</code></strong> and <strong><code>E</code></strong> will contain <strong><code>6</code></strong> informative lines and files <strong><code>A</code></strong> and <strong><code>D</code></strong> are <strong>still</strong> empty !</p>
<hr />
<ul>
<li>
<p dir="auto">In the <strong><code>B.txt</code></strong> file :</p>
<ul>
<li>
<p dir="auto">Move to the <strong>very beginning</strong> of file</p>
</li>
<li>
<p dir="auto">Create a <strong>zero-length rectangular</strong> selection onto the <strong><code>6</code></strong> lines</p>
</li>
<li>
<p dir="auto">Open the <strong>Column Editor</strong> ( <strong><code>Alt + C</code></strong> )</p>
</li>
<li>
<p dir="auto">Choose the <strong><code>Number to Insert</code></strong> radio button</p>
</li>
<li>
<p dir="auto"><strong>Initial</strong> number <strong><code>2</code></strong></p>
</li>
<li>
<p dir="auto"><strong>Increase</strong> by <strong><code>5</code></strong></p>
</li>
<li>
<p dir="auto"><strong>Repeat</strong> <strong><code>1</code></strong></p>
</li>
<li>
<p dir="auto">Tick the <strong><code>Leading zeros</code></strong> option</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>OK</code></strong> button</p>
</li>
</ul>
</li>
</ul>
<p dir="auto">=&gt; You should get the numbering : <strong><code>02, 07, 12, 17, 22, 27</code></strong></p>
<ul>
<li>
<p dir="auto">In the <strong><code>C.txt</code></strong> file :</p>
<ul>
<li>
<p dir="auto">Move to the <strong>very beginning</strong> of file</p>
</li>
<li>
<p dir="auto">Create a <strong>zero-length rectangular</strong> selection onto the <strong><code>6</code></strong> lines</p>
</li>
<li>
<p dir="auto">Open the <strong>Column Editor</strong> ( <strong><code>Alt + C</code></strong> )</p>
</li>
<li>
<p dir="auto">Choose the <strong><code>Number to Insert</code></strong> radio button</p>
</li>
<li>
<p dir="auto"><strong>Initial</strong> number <strong><code>3</code></strong></p>
</li>
<li>
<p dir="auto"><strong>Increase</strong> by <strong><code>5</code></strong></p>
</li>
<li>
<p dir="auto"><strong>Repeat</strong> <strong><code>1</code></strong></p>
</li>
<li>
<p dir="auto">Tick the <strong><code>Leading zeros</code></strong> option</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>OK</code></strong> button</p>
</li>
</ul>
</li>
</ul>
<p dir="auto">=&gt; You should get the numbering : <strong><code>03, 08, 13, 18, 23, 28</code></strong></p>
<ul>
<li>
<p dir="auto">In the <strong><code>E.txt</code></strong> file :</p>
<ul>
<li>
<p dir="auto">Move to the <strong>very beginning</strong> of file</p>
</li>
<li>
<p dir="auto">Create a <strong>zero-length rectangular</strong> selection onto the <strong><code>6</code></strong> lines</p>
</li>
<li>
<p dir="auto">Open the <strong>Column Editor</strong> ( <strong><code>Alt + C</code></strong> )</p>
</li>
<li>
<p dir="auto">Choose the <strong><code>Number to Insert</code></strong> radio button</p>
</li>
<li>
<p dir="auto"><strong>Initial</strong> number <strong><code>5</code></strong></p>
</li>
<li>
<p dir="auto"><strong>Increase</strong> by <strong><code>5</code></strong></p>
</li>
<li>
<p dir="auto"><strong>Repeat</strong> <strong><code>1</code></strong></p>
</li>
<li>
<p dir="auto">Tick the <strong><code>Leading zeros</code></strong> option</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>OK</code></strong> button</p>
</li>
</ul>
</li>
</ul>
<p dir="auto">=&gt; You should get the numbering : <strong><code>05, 10, 15, 20, 25, 30</code></strong></p>
<ul>
<li>
<p dir="auto">In the <strong><code>D.txt</code></strong> <strong>empty</strong> file :</p>
<ul>
<li>
<p dir="auto">Hit <strong><code>6</code></strong> times on the <strong><code>Enter</code></strong> key</p>
</li>
<li>
<p dir="auto">Insert a <strong><code>semicolon</code></strong> character on <strong>each</strong> line</p>
</li>
<li>
<p dir="auto">Move to the <strong>very beginning</strong> of file</p>
</li>
<li>
<p dir="auto">Create a <strong>zero-length rectangular</strong> selection onto these <strong><code>6</code></strong> lines</p>
</li>
<li>
<p dir="auto">Open the <strong>Column Editor</strong> ( <strong><code>Alt + C</code></strong> )</p>
</li>
<li>
<p dir="auto">Choose the <strong><code>Number to Insert</code></strong> radio button</p>
</li>
<li>
<p dir="auto"><strong>Initial</strong> number <strong><code>4</code></strong></p>
</li>
<li>
<p dir="auto"><strong>Increase</strong> by <strong><code>5</code></strong></p>
</li>
<li>
<p dir="auto"><strong>Repeat</strong> <strong><code>1</code></strong></p>
</li>
<li>
<p dir="auto">Tick the <strong><code>Leading zeros</code></strong> option</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>OK</code></strong> button</p>
</li>
</ul>
</li>
</ul>
<p dir="auto">=&gt; You should get the numbering : <strong><code>04, 09, 14, 19, 24, 29</code></strong>, followed with a <strong>semicolon</strong></p>
<ul>
<li>
<p dir="auto">Finally, in the <strong><code>A.txt</code></strong> <strong>empty</strong> file :</p>
<ul>
<li>
<p dir="auto">Hit <strong><code>6</code></strong> times on the <strong><code>Enter</code></strong> key</p>
</li>
<li>
<p dir="auto">Move to the <strong>very beginning</strong> of file</p>
</li>
<li>
<p dir="auto">Create a <strong>zero-length rectangular</strong> selection onto these <strong><code>6</code></strong> lines</p>
</li>
<li>
<p dir="auto">Open the <strong>Column Editor</strong> ( <strong><code>Alt + C</code></strong> )</p>
</li>
<li>
<p dir="auto">Choose the <strong><code>Number to Insert</code></strong> radio button</p>
</li>
<li>
<p dir="auto"><strong>Initial</strong> number <strong><code>1</code></strong></p>
</li>
<li>
<p dir="auto"><strong>Increase</strong> by <strong><code>5</code></strong></p>
</li>
<li>
<p dir="auto"><strong>Repeat</strong> <strong><code>1</code></strong></p>
</li>
<li>
<p dir="auto">Tick the <strong><code>Leading zeros</code></strong> option</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>OK</code></strong> button</p>
</li>
</ul>
</li>
</ul>
<p dir="auto">=&gt; You should get the numbering : <strong><code>01, 06, 11, 16, 21, 26</code></strong></p>
<ul>
<li>
<p dir="auto">Secondly :</p>
<ul>
<li>
<p dir="auto">Move the caret at <strong>end</strong> of the <strong>first</strong> line</p>
</li>
<li>
<p dir="auto">Create, again, a <strong>zero-lengh rectangular</strong> selection onto these <strong><code>6</code></strong> lines</p>
</li>
<li>
<p dir="auto">Open the <strong>Column Editor</strong> ( <strong><code>Alt + C</code></strong> )</p>
</li>
<li>
<p dir="auto">Choose the <strong><code>Number to Insert</code></strong> radio button</p>
</li>
<li>
<p dir="auto"><strong>Initial</strong> number <strong><code>1</code></strong></p>
</li>
<li>
<p dir="auto"><strong>Increase</strong> by <strong><code>1</code></strong>, this time</p>
</li>
<li>
<p dir="auto"><strong>Repeat</strong> <strong><code>1</code></strong></p>
</li>
<li>
<p dir="auto"><strong>Untick</strong> the <strong><code>Leading zeros</code></strong> option, this time</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>OK</code></strong> button</p>
</li>
</ul>
</li>
</ul>
<p dir="auto">You should get the <strong>final</strong> numbering : <strong><code>011, 062, 113, 164, 215, 266</code></strong></p>
<hr />
<p dir="auto">Then, let’s <strong>merge</strong> the files, from <strong><code>A.txt</code></strong> to <strong><code>E.txt</code></strong>, in <strong>any</strong> order, in a <strong>new</strong> tab, renamed as <strong><code>Resul.txt</code></strong>, which <strong>possible blank</strong> lines in between. You obtain this text :</p>
<pre><code class="language-diff">011
062
113
164
215
266


02"ad"
07"ae"
12"af"
17"al"
22"am"
27"an"

03"+376"
08"+971"
13"+93"
18"+355"
23"+374"
28"+244"


04;
09;
14;
19;
24;
29;

05"Andorra"
10"United Arab Emirates (UAE)"
15"Afghanistan"
20"Albania"
25"Armenia"
30"Angola"
</code></pre>
<ul>
<li>Perform a <strong>classical</strong> sort with the <strong><code>Edit &gt; Line Operations &gt; Sort Lines Lexicographically Ascending</code></strong> option. After <strong>deleting</strong> the first <strong>possible blank</strong> lines, you’re left with these <strong><code>Result.txt</code></strong> contents :</li>
</ul>
<pre><code class="language-diff">011
02"ad"
03"+376"
04;
05"Andorra"
062
07"ae"
08"+971"
09;
10"United Arab Emirates (UAE)"
113
12"af"
13"+93"
14;
15"Afghanistan"
164
17"al"
18"+355"
19;
20"Albania"
215
22"am"
23"+374"
24;
25"Armenia"
266
27"an"
28"+244"
29;
30"Angola"
</code></pre>
<ul>
<li>
<p dir="auto">Move to the <strong>very beginning</strong> of file</p>
</li>
<li>
<p dir="auto">For the <strong>last</strong> time, do a <strong>zero-length rectangular</strong> selection onto the <strong><code>30</code></strong> lines</p>
</li>
<li>
<p dir="auto">Delete the <strong>first two</strong> digits, hitting <strong>twice</strong> the <strong><code>Delete</code></strong> key</p>
</li>
</ul>
<p dir="auto">The <strong><code>Resul.txt</code></strong> file becomes :</p>
<pre><code class="language-diff">1
"ad"
"+376"
;
"Andorra"
2
"ae"
"+971"
;
"United Arab Emirates (UAE)"
3
"af"
"+93"
;
"Afghanistan"
4
"al"
"+355"
;
"Albania"
5
"am"
"+374"
;
"Armenia"
6
"an"
"+244"
;
"Angola"
</code></pre>
<p dir="auto"><strong>Almost</strong> finished ! Open the <strong><code>Replace</code></strong> dialog and performs this <strong>regex</strong> S/R :</p>
<p dir="auto">SEARCH <strong><code>(?-s)^(\d+)\R(.+)\R(.+)\R(.+)\R"(.+)"(\R)</code></strong></p>
<p dir="auto">REPLACE <strong><code>\tcase \1:\6\t\tcountry=\2\6\t\tcountry_code_number=\3\6\t\tcountry_flag=R\.drawable\.flag_\5;\6\t\tcountry_word="\5"\6\t\tbreak;\6</code></strong></p>
<p dir="auto"><strong>Magically</strong>, the text is changed into :</p>
<pre><code class="language-diff">	case 1:
		country="ad"
		country_code_number="+376"
		country_flag=R.drawable.flag_Andorra;
		country_word="Andorra"
		break;
	case 2:
		country="ae"
		country_code_number="+971"
		country_flag=R.drawable.flag_United Arab Emirates (UAE);
		country_word="United Arab Emirates (UAE)"
		break;
	case 3:
		country="af"
		country_code_number="+93"
		country_flag=R.drawable.flag_Afghanistan;
		country_word="Afghanistan"
		break;
	case 4:
		country="al"
		country_code_number="+355"
		country_flag=R.drawable.flag_Albania;
		country_word="Albania"
		break;
	case 5:
		country="am"
		country_code_number="+374"
		country_flag=R.drawable.flag_Armenia;
		country_word="Armenia"
		break;
	case 6:
		country="an"
		country_code_number="+244"
		country_flag=R.drawable.flag_Angola;
		country_word="Angola"
		break;
</code></pre>
<p dir="auto">To end, run this <strong>second</strong> regex S/R :</p>
<p dir="auto">SEARCH <strong><code>(?s)(?!\r|\n).+</code></strong></p>
<p dir="auto">REPLACE <strong><code>switch (5) {\r\n$0\tdefault:\r\n\tconsole.log\(\x96Nothing here\x96\);\r\n\t}\r\n</code></strong></p>
<p dir="auto">And here is, <strong>Igor</strong>, your <strong>expected</strong> result :</p>
<pre><code class="language-diff">switch 5 {
	case 1:
		country="ad"
		country_code_number="+376"
		country_flag=R.drawable.flag_Andorra;
		country_word="Andorra"
		break;
	case 2:
		country="ae"
		country_code_number="+971"
		country_flag=R.drawable.flag_United Arab Emirates (UAE);
		country_word="United Arab Emirates (UAE)"
		break;
	case 3:
		country="af"
		country_code_number="+93"
		country_flag=R.drawable.flag_Afghanistan;
		country_word="Afghanistan"
		break;
	case 4:
		country="al"
		country_code_number="+355"
		country_flag=R.drawable.flag_Albania;
		country_word="Albania"
		break;
	case 5:
		country="am"
		country_code_number="+374"
		country_flag=R.drawable.flag_Armenia;
		country_word="Armenia"
		break;
	case 6:
		country="an"
		country_code_number="+244"
		country_flag=R.drawable.flag_Angola;
		country_word="Angola"
		break;
	default:
	console.log(`Nothing here`);
	}
</code></pre>
<p dir="auto">Best Regards</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong> :</p>
<ul>
<li>
<p dir="auto">Your <strong><code>Two-letters</code></strong> country, in the <strong><code>B.txt</code></strong> file, represents the <strong><code>ISO 3166-1 alpha-2</code></strong> <strong>standard</strong> for each country</p>
</li>
<li>
<p dir="auto">Your <strong><code>Country_code_number</code></strong>, in the <strong><code>C.txt</code></strong> file, represents the <strong><code>E_164 codes</code></strong> <strong>standard</strong> for each country</p>
</li>
</ul>
<p dir="auto">Refer to this <strong>main</strong> link :</p>
<p dir="auto"><a href="https://en.wikipedia.org/wiki/Country_code" rel="nofollow ugc">https://en.wikipedia.org/wiki/Country_code</a></p>
]]></description><link>https://community.notepad-plus-plus.org/post/72850</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72850</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Tue, 11 Jan 2022 02:56:38 GMT</pubDate></item><item><title><![CDATA[Reply to how to use macro to make my code on Sun, 09 Jan 2022 18:21:50 GMT]]></title><description><![CDATA[<p dir="auto">this was the answer i was looking for:</p>
<p dir="auto"><a href="https://stackoverflow.com/a/70632134/17848947" rel="nofollow ugc">https://stackoverflow.com/a/70632134/17848947</a></p>
<p dir="auto">i just didn’t wanted to continue building on more misunderstandings trying to explain further and waste anyone’s time…</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72817</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72817</guid><dc:creator><![CDATA[Igor Lerinc]]></dc:creator><pubDate>Sun, 09 Jan 2022 18:21:50 GMT</pubDate></item><item><title><![CDATA[Reply to how to use macro to make my code on Fri, 07 Jan 2022 17:43:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@peterjones</a> said in <a href="/post/72765">how to use macro to make my code</a>:</p>
<blockquote>
<p dir="auto">OP deleted their question and it had to be resurrected</p>
</blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/24098">@igor-lerinc</a> A rather anti-social thing to do.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@peterjones</a> said in <a href="/post/72765">how to use macro to make my code</a>:</p>
<blockquote>
<p dir="auto">I doubt there’s much point in our spending any more time on it</p>
</blockquote>
<p dir="auto">I realized this morning an enhancement to the spreadsheet approach I suggested earlier I’d like to briefly describe.</p>
<p dir="auto">Without too much difficulty a column could be added consisting of formulas to calculate the line number in the target file to be assembled.</p>
<p dir="auto">Assuming 6 lines per case (1 for “case” stmnt, 4 vars, and 1 for static “break” stmnt),</p>
<p dir="auto">the first bank, the “case” numbers, would have target line numbers 1,7,13… (1+(92-1)*6)</p>
<p dir="auto">the second bank, the “country” fields would have target line numbers 2,8,14… (2+(92-1)*6)</p>
<p dir="auto">etc.</p>
<p dir="auto">Now the lines could be sorted, either in the spreadsheet or after xfer to text editor.</p>
<p dir="auto">To make it amenable to upkeep and modification, one should define things like NUM_COUNTRIES (92) and LINES_PER_CASE (6 in my example), and use those in the formulas.</p>
<p dir="auto">As before, there are many variations on implementation details, such as, doing C-ification early, in spreadsheet:<br />
CONCAT spaces/tabs + "case " + case num " “:”<br />
CONCAT spaces/tabs + “country=” + country text + “;”<br />
etc<br />
or late, in Npp using fancy regex in a F&amp;R.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72766</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72766</guid><dc:creator><![CDATA[Neil Schipper]]></dc:creator><pubDate>Fri, 07 Jan 2022 17:43:44 GMT</pubDate></item><item><title><![CDATA[Reply to how to use macro to make my code on Fri, 07 Jan 2022 15:53:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a> said in <a href="/post/72763">how to use macro to make my code</a>:</p>
<blockquote>
<p dir="auto">as IMO the OP hasn’t made it very clear</p>
</blockquote>
<p dir="auto">Since the OP deleted their question and it had to be resurrected, I am pretty sure either the OP got the answer they needed, or they left in a huff because they couldn’t figure out how to make us understand what they wanted.  Either way, I doubt the OP is going to come back and clarify, and I doubt there’s much point in our spending any more time on it (unless the OP <em>does</em> come back and clarify).</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72765</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72765</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Fri, 07 Jan 2022 15:53:21 GMT</pubDate></item><item><title><![CDATA[Reply to how to use macro to make my code on Fri, 07 Jan 2022 15:42:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/22926">@paul-wormer</a> said in <a href="/post/72762">how to use macro to make my code</a>:</p>
<blockquote>
<p dir="auto">I am sorry that I don’t understand the mechanics of this particular forum. But my answer about editor.lineDown() was about your comment above.</p>
</blockquote>
<p dir="auto">Ah, apologies.<br />
And you did say earlier:</p>
<blockquote>
<p dir="auto">Here I assume that you have an existing file of 920 lines</p>
</blockquote>
<p dir="auto">So I missed that.<br />
Again, sorry.</p>
<hr />
<p dir="auto">Other thoughts:</p>
<p dir="auto"><code>editor.lineDown()</code> isn’t really a great way to script something like this.  It’s too “macro”-ish, and scripts give you the power to work with more of a data set rather than “careting” around a document as in a macro approach.</p>
<p dir="auto">But…it is hard to say more, because I really don’t have a great grasp on the problem statement, as IMO the OP hasn’t made it very clear (and the longer that state persists, the less interested I am).</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72763</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72763</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 07 Jan 2022 15:42:45 GMT</pubDate></item><item><title><![CDATA[Reply to how to use macro to make my code on Fri, 07 Jan 2022 15:27:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a> said in <a href="/post/72722">how to use macro to make my code</a>:</p>
<blockquote>
<p dir="auto">II gave it a whirl and upon execution I got one really long line generated (12420 characters), that pretty much looks like this, over and over on that one line:</p>
<p dir="auto">country= coutry_word=country_flag=country_code_number=</p>
<p dir="auto">I’m not sure how that gets close to what the OP wants.</p>
</blockquote>
<p dir="auto">I am sorry that I don’t understand the mechanics of this particular forum. But my answer about <code>editor.lineDown()</code> was about your comment above.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72762</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72762</guid><dc:creator><![CDATA[Paul Wormer]]></dc:creator><pubDate>Fri, 07 Jan 2022 15:27:57 GMT</pubDate></item><item><title><![CDATA[Reply to how to use macro to make my code on Fri, 07 Jan 2022 15:10:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/22926">@paul-wormer</a></p>
<p dir="auto">I don’t think you have a handle on how to reply to postings here, evidence:</p>
<p dir="auto"><img src="/assets/uploads/files/1641568102823-d5f376c2-6ee0-4e13-8618-348afb0ee433-image.png" alt="d5f376c2-6ee0-4e13-8618-348afb0ee433-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">So you are telling me that I “should have used an existing file with 920 lines”.  Well, I don’t know what that means, because I haven’t contributed in that way to this thread.</p>
<p dir="auto">Also, you’re replying to yourself; this can be done, but try to do it only if it makes sense.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72760</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72760</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 07 Jan 2022 15:10:56 GMT</pubDate></item><item><title><![CDATA[Reply to how to use macro to make my code on Fri, 07 Jan 2022 14:54:50 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/22926">@paul-wormer</a><br />
My solution was useless anyway now that I saw his BEFORE and AFTER.   I, too, misunderstood his problem.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72759</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72759</guid><dc:creator><![CDATA[Paul Wormer]]></dc:creator><pubDate>Fri, 07 Jan 2022 14:54:50 GMT</pubDate></item><item><title><![CDATA[Reply to how to use macro to make my code on Fri, 07 Jan 2022 14:47:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a><br />
You should have used an existing file with 920 lines.  <code>editor.lineDown()</code> does not add a new line.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72758</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72758</guid><dc:creator><![CDATA[Paul Wormer]]></dc:creator><pubDate>Fri, 07 Jan 2022 14:47:31 GMT</pubDate></item><item><title><![CDATA[Reply to how to use macro to make my code on Fri, 07 Jan 2022 13:50:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/24098">@igor-lerinc</a> ,</p>
<p dir="auto">Please do not delete your topic after there have been replies.  We might not have a way to mark a topic as “answered”, but deleting the topic is <em>not</em> the right way to “end” the question.  Just say, “thanks, that worked” or something to that effect, and the conversation will end naturally.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72751</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72751</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Fri, 07 Jan 2022 13:50:17 GMT</pubDate></item><item><title><![CDATA[Reply to how to use macro to make my code on Thu, 06 Jan 2022 22:11:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/280">@neil-schipper</a></p>
<p dir="auto">First, further to my prior post:</p>
<ol>
<li>your sample <em>AFTER</em> text looks like C code, but some lines have a semicolon and others do not</li>
<li><strong>coutry_word</strong> is probably a typo.</li>
</ol>
<p dir="auto">Now, I composed a macro that, using “Run a macro multiple times…” (and specifying 4 times), turns this:</p>
<pre><code>1
2
3
4

country="ad"
country="ae"
country="af"
country="ag"

country_code_number="+376"
country_code_number="+971"
country_code_number="+93"
country_code_number="+1"

country_flag=R.drawable.flag_andorra;
country_flag=R.drawable.flag_uae;
country_flag=R.drawable.flag_afghanistan;
country_flag=R.drawable.flag_antigua_and_barbuda;

coutry_word="Andorra"
coutry_word="United Arab Emirates (UAE)"
coutry_word="Afghanistan"
coutry_word="Antigua and Barbuda"


</code></pre>
<p dir="auto">into this:</p>
<pre><code>1
2
3
4

country="ad"
country="ae"
country="af"
country="ag"

country_code_number="+376"
country_code_number="+971"
country_code_number="+93"
country_code_number="+1"

country_flag=R.drawable.flag_andorra;
country_flag=R.drawable.flag_uae;
country_flag=R.drawable.flag_afghanistan;
country_flag=R.drawable.flag_antigua_and_barbuda;

coutry_word="Andorra"
coutry_word="United Arab Emirates (UAE)"
coutry_word="Afghanistan"
coutry_word="Antigua and Barbuda"

1
country="ad"
country_code_number="+376"
country_flag=R.drawable.flag_andorra;
coutry_word="Andorra"

2
country="ae"
country_code_number="+971"
country_flag=R.drawable.flag_uae;
coutry_word="United Arab Emirates (UAE)"

3
country="af"
country_code_number="+93"
country_flag=R.drawable.flag_afghanistan;
coutry_word="Afghanistan"

4
country="ag"
country_code_number="+1"
country_flag=R.drawable.flag_antigua_and_barbuda;
coutry_word="Antigua and Barbuda"


</code></pre>
<p dir="auto">Note that the macro:</p>
<ul>
<li>relies on there being exactly 5 groups of exactly 4 lines with exactly one line between groups</li>
<li>appends the new text to the end, and leaves the original text untouched</li>
</ul>
<p dir="auto">It would be trivial to enhance the macro so that output groups also have whatever leading whitespace, <em>case</em>, <em>break</em>, semicolons, etc. are desired.</p>
<p dir="auto">I don’t know if it would meet your needs because I still don’t fully understand your needs.</p>
<p dir="auto">I had trouble finding the actions that got it to work. The Ctl-Shift-down operation did not work as I had hoped (in  macro playback). However, using bookmark actions Ctl-F2 and F2, along with other conventional select, copy, paste actions, I was able to get the result I wanted.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72745</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72745</guid><dc:creator><![CDATA[Neil Schipper]]></dc:creator><pubDate>Thu, 06 Jan 2022 22:11:43 GMT</pubDate></item><item><title><![CDATA[Reply to how to use macro to make my code on Thu, 06 Jan 2022 20:49:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/24098">@igor-lerinc</a> said in <a href="/post/72737">how to use macro to make my code</a>:</p>
<blockquote>
<p dir="auto">there’s nothing to directly compile, as this is supposed to just insert appropriate variables depending on the input n (user inputs number 2 and variables those defined would be loaded and processed in code further)</p>
</blockquote>
<p dir="auto">I know you’re not trying to be cruel, but I am experiencing this as pain. Ouch! Can we try the russian-english translation method?</p>
<p dir="auto">And <em>if</em> you are talking about what the switch statement is being used for in your application, that is not relevant to the text manipulation problem you want help with.</p>
<p dir="auto">Your sample <em>before</em> and <em>after</em> text is helpful.</p>
<p dir="auto">Is it a requirement that the process handle sublists of different sizes as in your sample (10 <em>country</em> but 5 <em>country_flag</em>)?</p>
<p dir="auto">What determines that the process result in 3 fully formed output records even though none of the sublists consist of 3 items?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72742</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72742</guid><dc:creator><![CDATA[Neil Schipper]]></dc:creator><pubDate>Thu, 06 Jan 2022 20:49:18 GMT</pubDate></item><item><title><![CDATA[Reply to how to use macro to make my code on Thu, 06 Jan 2022 20:07:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a> I appreciate the validation (even though sometimes I’m genuinely thick).</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72733</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72733</guid><dc:creator><![CDATA[Neil Schipper]]></dc:creator><pubDate>Thu, 06 Jan 2022 20:07:13 GMT</pubDate></item><item><title><![CDATA[Reply to how to use macro to make my code on Thu, 06 Jan 2022 20:02:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/280">@neil-schipper</a> said in <a href="/post/72729">how to use macro to make my code</a>:</p>
<blockquote>
<p dir="auto">I have trouble understanding your text.</p>
</blockquote>
<p dir="auto">Yep, me too.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72731</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72731</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 06 Jan 2022 20:02:36 GMT</pubDate></item><item><title><![CDATA[Reply to how to use macro to make my code on Thu, 06 Jan 2022 19:52:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/24098">@igor-lerinc</a> said in <a href="/post/72728">how to use macro to make my code</a>:</p>
<blockquote>
<p dir="auto">i still need to put them in syntax of switch case</p>
</blockquote>
<p dir="auto">It would be good if you showed 2 or 3 record sample “before” and “after” text boxes so we can see the exact input - output relationship you want.</p>
<p dir="auto">I have trouble understanding your text. Here’s an easy  experiment: type up your text in your language (try using the simplest and most common words and grammar and sentence structure that you can while still getting your intentions across). Then run that through a translator and provide us with the output.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72729</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72729</guid><dc:creator><![CDATA[Neil Schipper]]></dc:creator><pubDate>Thu, 06 Jan 2022 19:52:26 GMT</pubDate></item><item><title><![CDATA[Reply to how to use macro to make my code on Thu, 06 Jan 2022 19:10:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/22926">@paul-wormer</a> said in <a href="/post/72715">how to use macro to make my code</a>:</p>
<blockquote>
<p dir="auto">you could execute a script that roughly looks like this</p>
</blockquote>
<p dir="auto">I gave it a whirl and upon execution I got one really long line generated (12420 characters), that pretty much looks like this, over and over on that one line:</p>
<p dir="auto"><code>country= coutry_word=country_flag=country_code_number=</code></p>
<p dir="auto">I’m not sure how that gets close to what the OP wants.</p>
<p dir="auto">Of course, I found it difficult to understand what the OP <em>does</em> want, contributing to why I didn’t offer any ideas beyond the possibility of using a scripting plugin…</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72722</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72722</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 06 Jan 2022 19:10:58 GMT</pubDate></item><item><title><![CDATA[Reply to how to use macro to make my code on Thu, 06 Jan 2022 19:10:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/280">@neil-schipper</a> said in <a href="/post/72719">how to use macro to make my code</a>:</p>
<blockquote>
<p dir="auto">you could probably do it all in Npp</p>
</blockquote>
<p dir="auto">But the advantage of using a spreadsheet is that it also provides a convenient way of maintaining (adding/removing countries, modifying specific fields, and so on), and version tracking the source data that is used to create the records.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72721</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72721</guid><dc:creator><![CDATA[Neil Schipper]]></dc:creator><pubDate>Thu, 06 Jan 2022 19:10:47 GMT</pubDate></item><item><title><![CDATA[Reply to how to use macro to make my code on Thu, 06 Jan 2022 19:03:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/24098">@igor-lerinc</a> The suggestion by the other guys to use scripting is probably the best approach especially if you have to rebuild the file (or others like it) at least somewhat often.</p>
<p dir="auto">But if you’re not inclined to learn a scripting language in the short run, and especially if you already have some spreadsheet skill, this task can be achieved using something like OpenOffice Calc or Excel. The process would be along these lines:</p>
<ul>
<li>make a column of ascending numbers (Fill… Down…)</li>
<li>optionally, make columns with your static text (<code>case </code>, <code>country=</code> and the like)</li>
<li>import your 4 x 230 item lists as columns</li>
<li>move the columns around, so you have one row per record with most or all the text that goes into a record</li>
<li>optionally, use functions like CONCATENATE to do some massaging, that is, merge columns, so there’s less work to do in Npp.</li>
<li>save as csv (unless your CONCAT-massaging is so complete you’re down to a single column, in which case, save as txt)</li>
<li>open in Npp</li>
<li>use a Find &amp; Replace to break each row into a multiline record (by substituting in newlines for commas or any other record separator chars you used such as whitespace), including the adding of leading whitespace, empty lines, etc</li>
</ul>
<p dir="auto">And after typing the above, it occurs to me that you could probably do it all in Npp using Npp’s native column copy/paste operations, which you already are good at using. That is, do what you already did, except build it as one line per record, adding static text columns, then, variable data columns, then the next static text column, etc. You may wish to put in anchoring text columns to help manage the final formatting:</p>
<pre><code>case 1  BREAK1 country=af   BREAK2  coutry_word=Afghanistan    BREAK3  country_flag=https://imgur.com/yRbLG3B    BREAK4  country_code_number=+324    BREAK5   break;
</code></pre>
<p dir="auto">Finally, as before, transform each line into multi-line records with the desired whitespace using Find &amp; Replace.</p>
<p dir="auto">You can also automate some of this with macros, since column pastes can be performed within a macro.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72719</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72719</guid><dc:creator><![CDATA[Neil Schipper]]></dc:creator><pubDate>Thu, 06 Jan 2022 19:03:09 GMT</pubDate></item><item><title><![CDATA[Reply to how to use macro to make my code on Thu, 06 Jan 2022 14:35:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/22926">@paul-wormer</a><br />
As first line you need <code>from Npp import *</code>. If some of the country names contain UTF-8 codes you need <code># -*- coding: utf-8 -*-</code> on top of your script as well.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72716</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72716</guid><dc:creator><![CDATA[Paul Wormer]]></dc:creator><pubDate>Thu, 06 Jan 2022 14:35:31 GMT</pubDate></item><item><title><![CDATA[Reply to how to use macro to make my code on Thu, 06 Jan 2022 14:27:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/24098">@igor-lerinc</a><br />
I you don’t mind installing the PythonScript plugin, you could execute a script that roughly looks like this</p>
<pre><code>
textToInsert = ['country= ',  'coutry_word=',  'country_flag=',  'country_code_number='] 
editor.documentStart()
for line in range(0, 920):
    text = textToInsert[line%4]
    pos = editor.getCurrentPos()
    editor.insertText(pos, text )
    editor.lineDown()
</code></pre>
<p dir="auto">Here I assume that you have an existing file of 920 lines (=230*4) which  describe  for each of the 230 countries the same kind of 4 pieces of info.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72715</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72715</guid><dc:creator><![CDATA[Paul Wormer]]></dc:creator><pubDate>Thu, 06 Jan 2022 14:27:47 GMT</pubDate></item><item><title><![CDATA[Reply to how to use macro to make my code on Wed, 05 Jan 2022 21:41:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/24098">@igor-lerinc</a> said in <a href="/post/72710">how to use macro to make my code</a>:</p>
<blockquote>
<p dir="auto">Because i often encounter this much need to do (to clean something so it can fit into code etc…), but in fact it can be automated, i just don’t know how.</p>
</blockquote>
<p dir="auto">Probably one of the scripting plugins would be the thing to use here, but the learning curve is fairly steep.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72711</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72711</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 05 Jan 2022 21:41:16 GMT</pubDate></item></channel></rss>