AutoHotkey Community

It is currently May 27th, 2012, 2:03 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: January 31st, 2010, 1:22 am 
Offline

Joined: August 15th, 2009, 7:20 am
Posts: 308
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   


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 31st, 2010, 4:34 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 31st, 2010, 5:13 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3330
Location: Simi Valley, CA
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 31st, 2010, 12:02 pm 
Offline

Joined: August 15th, 2009, 7:20 am
Posts: 308
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 31st, 2010, 12:37 pm 
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!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 31st, 2010, 12:41 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
Code:
#!down::
   clipboard =
   Send, ^c
   clipwait
   StringReplace, sortlist, clipboard, `r,, A
   Sort, sortlist
   Clipboard:=sortlist
   send, ^v ; paste

return

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 31st, 2010, 11:19 pm 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3330
Location: Simi Valley, CA
Code:
#!down::
   clipboard =
   Send, ^c
   clipwait
   StringReplace, sortlist, clipboard, `r,, A
   Sort, sortlist
   StringReplace, Clipboard, sortlist, `n, `r`n, A
   send, ^v ; paste
return
:oops:
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 1st, 2010, 12:29 am 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
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 FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 1st, 2010, 3:20 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3330
Location: Simi Valley, CA
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!


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, engunneer, Google Feedfetcher, nimda, sjc1000 and 15 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group