EmEditor (text editor) Forum Index Questions and Answers about Macros
needs help on a macro to insert number row | Register To Post |
| Threaded | Newest First | Previous Topic | Next Topic | Bottom |
| Poster | Thread |
|---|---|
| zhouzh2 | Posted on: 3/30/2010 11:18 am |
Just can't stay away ![]() ![]() Joined: 7/27/2008 From: Posts: 90 |
needs help on a macro to insert number row I wrote this for inserting number row. both in this kind:
and: It is supposed to work from number 0 to 99 or 99 to 0. However, this macro will be trapped in a loop under a certain situation, i.e. when 1<i<10 and n>10, or when 10<i<=99 and n<10 (however the latter will not always appear.) But I cannot find out why. Anyone please help me with that |
| zhouzh2 | Posted on: 4/3/2010 3:34 am |
Just can't stay away ![]() ![]() Joined: 7/27/2008 From: Posts: 90 |
Re: needs help on a macro to insert number row no one interested?
|
| ToadLoadin | Posted on: 4/5/2010 9:46 pm |
Just can't stay away ![]() ![]() Joined: 7/4/2008 From: China Posts: 119 |
Re: needs help on a macro to insert number row Hi zhouzh2,
If your "somethinghere" in every line is exactly the same: Quote:
perhaps you could use "Insert Number Sequence" plugin, the Simplified Chinese version is here. |
| zhouzh2 | Posted on: 4/6/2010 8:13 am |
Just can't stay away ![]() ![]() Joined: 7/27/2008 From: Posts: 90 |
Re: needs help on a macro to insert number row Thanks ToadLoadin
I know there is such a plug-in. However, a 32bit plug-in will not work on a 64bit Emeditor. Furthermore, I would prefer a macro if the macro can do what I want, since it saves hardware recourse. "somethinghere" is not what I want to insert. This is just one of the situation when inserting numbers. Under the above two situation a macro should behave accoradingly to insert numbers correctly. To surpass this I temporarily enables the VirtualSpace and restores it when finished. The problem here is when entering a start number greater than 2, the macro will stack in a infinite loop, but I can't find out why...from I point of view, this macro should run correctly |
| ToadLoadin | Posted on: 4/21/2010 4:49 am |
Just can't stay away ![]() ![]() Joined: 7/4/2008 From: China Posts: 119 |
Re: needs help on a macro to insert number row Hi zhouzh2,
I modified your macro to this: And observed an interesting issue, as you noticed: Quote: when 1<i<10 and n>10, or when 10<i<=99 and n<10 The first number inserted will be the biggest one, I guess that's why your macro fall into a infinite loop, but I can not figure out why this happens, perhaps a bug? |
| zhouzh2 | Posted on: 4/22/2010 6:36 am |
Just can't stay away ![]() ![]() Joined: 7/27/2008 From: Posts: 90 |
Re: needs help on a macro to insert number row Hi ToadLoadin,
Thanks a lot for your help. Your macro is a lot elegant than my silly one Yeah I agree with you that this is strange and might be a bug, not so sure though. Any other JavaScript expert please come to our rescue (Yutaka? ) |
| tonne | Posted on: 4/23/2010 8:58 am |
Just popping in ![]() ![]() Joined: 11/5/2009 From: Posts: 4 |
Re: needs help on a macro to insert number row Try
if (Math.abs(i) < Math.abs(n)) { //ascending |
| ToadLoadin | Posted on: 4/23/2010 5:49 pm |
Just can't stay away ![]() ![]() Joined: 7/4/2008 From: China Posts: 119 |
Re: needs help on a macro to insert number row Quote:
That works!~~ But...why that works? |
| tonne | Posted on: 4/24/2010 12:22 am |
Just popping in ![]() ![]() Joined: 11/5/2009 From: Posts: 4 |
Re: needs help on a macro to insert number row prompt returns a string; is "2" < "10" ?
|
| ToadLoadin | Posted on: 4/24/2010 1:55 am |
Just can't stay away ![]() ![]() Joined: 7/4/2008 From: China Posts: 119 |
Re: needs help on a macro to insert number row Quote:
tonne wrote: OIC, it's a string comparison instead of integer one. Thank you! |
| Threaded | Newest First | Previous Topic | Next Topic | Top |
| Register To Post | |




