 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Puzzled Greatly
Joined: 15 Aug 2009 Posts: 274
|
Posted: Sun Jan 31, 2010 12:22 am Post subject: How to stop sort inserting empty lines? |
|
|
I have the following code:
| Code: | #!down::
clipboard =
Send, ^c
clipwait
sortlist := clipboard
Sort, sortlist
send, %sortlist%
return
I tested this in metapad and notepad++. It sorted a list of words (each word on a different line) but it added in an extra line after each word. What have I done wrong? How can I sort a list of words without adding an extra line of space between each word?
Thanks,
GP |
|
|
| Back to top |
|
 |
q&a Guest
|
Posted: Sun Jan 31, 2010 3:34 am Post subject: |
|
|
Yea thats weird..
This seems to fix the problem.
| Code: | #!down::
clipboard =
Send, ^c
clipwait
sortlist := clipboard
Sort, sortlist
Loop, parse, sortlsist, `n
send % A_Loopfield
| hth |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 3254 Location: Simi Valley, CA
|
Posted: Sun Jan 31, 2010 4:13 am Post subject: |
|
|
| Code: | #!down::
clipboard =
Send, ^c
clipwait
StringReplace, sortlist, clipboard, `r,, A
Sort, sortlist
send, %sortlist%
return |
_________________ Ternary (a ? b : c) guide TSV Table Manipulation Library
Post code inside [code][/code] tags! |
|
| Back to top |
|
 |
Puzzled Greatly
Joined: 15 Aug 2009 Posts: 274
|
Posted: Sun Jan 31, 2010 11:02 am Post subject: |
|
|
Thanks, adding the StringReplace works though I don't get why it should be necessary. Is there any way to make the whole script faster? Right now it's as if each word is pasted individually so an 80 word list takes around 10 seconds to process.
GP |
|
| Back to top |
|
 |
Guest
|
Posted: Sun Jan 31, 2010 11:37 am Post subject: |
|
|
| Puzzled Greatly wrote: | Thanks, adding the StringReplace works though I don't get why it should be necessary. Is there any way to make the whole script faster? Right now it's as if each word is pasted individually so an 80 word list takes around 10 seconds to process.
GP |
Use SendInput instead of Send. Read about the difference in the help file! |
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
Posted: Sun Jan 31, 2010 11:41 am Post subject: |
|
|
| Code: | #!down::
clipboard =
Send, ^c
clipwait
StringReplace, sortlist, clipboard, `r,, A
Sort, sortlist
Clipboard:=sortlist
send, ^v ; paste
return |
_________________ AHK Wiki FAQ
TF : Text files & strings lib, TF Forum |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 3254 Location: Simi Valley, CA
|
Posted: Sun Jan 31, 2010 10:19 pm Post subject: |
|
|
| Code: | #!down::
clipboard =
Send, ^c
clipwait
StringReplace, sortlist, clipboard, `r,, A
Sort, sortlist
StringReplace, Clipboard, sortlist, `n, `r`n, A
send, ^v ; paste
return |
Text in the clipboard may not paste correctly without the full CRLFs. The 'sort' command uses the newline character as the default delimiter, hence the removal of the carriage returns before the sort. _________________ Ternary (a ? b : c) guide TSV Table Manipulation Library
Post code inside [code][/code] tags! |
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
Posted: Sun Jan 31, 2010 11:29 pm Post subject: |
|
|
Why bother? | Quote: | | Dx: Specifies x as the delimiter character, which determines where each item in VarName begins and ends. If this option is not present, x defaults to linefeed (`n), which correctly sorts VarName if its lines end in either LF (`n) or CR+LF (`r`n). | Or am I missing something here? _________________ AHK Wiki FAQ
TF : Text files & strings lib, TF Forum |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 3254 Location: Simi Valley, CA
|
Posted: Mon Feb 01, 2010 2:20 am Post subject: |
|
|
I didn't know that about Sort. I should have said that the issue was with Send, which replaces both CR and LF with an enter stroke, thus producing extra lines.
| Code: | #!down::
clipboard =
Send, ^c
clipwait
Sort, clipboard
send, ^v ; paste
return |  _________________ Ternary (a ? b : c) guide TSV Table Manipulation Library
Post code inside [code][/code] tags! |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|