EmEditor (text editor) Forum Index Questions and Answers about Macros
How to know a doc's return method | Register To Post |
| Threaded | Newest First | Previous Topic | Next Topic | Bottom |
| Poster | Thread |
|---|---|
| chjfth | Posted on: 7/3/2010 4:00 am |
Quite a regular ![]() ![]() Joined: 10/20/2006 From: Posts: 41 |
How to know a doc's return method Hello, Yukata,
I want to know the return method of current active document from macro code in Emeditor. So I tried the following VBS snippet, However, whether I run this macro on a Windows text file(CRLF) or Unix text file(LF), I always get "crlf_style 0". Is there a way to work me out? Tried on EmEditor v8 and v10.0, same result. Thank you. |
| Yutaka | Posted on: 7/3/2010 9:03 am |
Webmaster ![]() ![]() Joined: 9/28/2006 From: Redmond Posts: 2397 |
Re: How to know a doc's return method Hello chjfth,
If you just want to know the Return method of the current document, you can display that information on the Status Bar. Please go to Customize on the Tools menu, and select the "Status" tab, and check "Return Method". Please let me know if you have further questions. Thank you for using EmEditor!
|
| chjfth | Posted on: 7/3/2010 10:27 pm |
Quite a regular ![]() ![]() Joined: 10/20/2006 From: Posts: 41 |
Re: How to know a doc's return method Oh, yes, I do have a further question.
I'm writing a slash-cvt.vbee macro. If the selection is partial line, or, multiple lines of a Unix text file, it works well. However, if the selection is multiple lines of a CRLF text file, there is something wrong: <code>ds.CharLeft True, slen</code> will move(select) visually more characters than I expect, --because, at end of a line, <code>ds.CharLeft True, 1</code> will actually step 2 characters(CR and LF). So, If I can know whether a text file is CRLF-ed, I can replace all CRLF to LF before I count slen=Len(ds.Text) , so that the finally selection length will be correct. I hope you can add this property in future version. On the other hand, is there another way to achieve the same goal(implement the slash-cvt.vbee macro)? |
| Yutaka | Posted on: 7/4/2010 12:27 pm |
Webmaster ![]() ![]() Joined: 9/28/2006 From: Redmond Posts: 2397 |
Re: How to know a doc's return method Hi,
GetLine method (Document object) allows you to add new line character(s) (CR, LF, or CR+LF) at the end of the line. Then you can correctly count the line length. I hope this helps.
|
| chjfth | Posted on: 7/4/2010 5:24 pm |
Quite a regular ![]() ![]() Joined: 10/20/2006 From: Posts: 41 |
Re: How to know a doc's return method Excuse me, I cannot tell how document.GetLine() can help. In order to call GetLine, I have to know the line numbers of the selected text, which seems to stray away from my topic.
This issue is not urgent. I can wait until next EmEditor release when you add a document property to tell current document's return method. Regards. |
| Yutaka | Posted on: 7/4/2010 5:55 pm |
Webmaster ![]() ![]() Joined: 9/28/2006 From: Redmond Posts: 2397 |
Re: How to know a doc's return method dc.FileSave.ReturnMethod usually always returns 0. This means the configuration will not alter the return method of a document. EmEditor supports files that have mixed return methods.
If you want to find the return method of the current document and if you know the return method is the same in the entire document, you can write: str = document.GetLine( 0, eeGetLineWithNewLines ) Then you can find what the return method of the current document is. I hope this helps. If you have further questions, please let me know. Thanks!
|
| chjfth | Posted on: 7/5/2010 4:13 am |
Quite a regular ![]() ![]() Joined: 10/20/2006 From: Posts: 41 |
Re: How to know a doc's return method Many thanks to your final clear reply. Now I know that EmEditor supports mixed EOL mark. And thank you for pointing out
can find out the EOL of line 1. (Yes, I must use 1 as first parameter instead of 0. 0 will cause script error "Invalid procedure call or argument". Now, I realize that I pratically don't have to care if current text file has LF or CRLF as end-of-line marker; I can simply replace all occurence of "\r\n" to "\n" before counting slen, then my goal is fulfilled. So my script becomes: EmEditor is so great with custom script. |
| Threaded | Newest First | Previous Topic | Next Topic | Top |
| Register To Post | |




