AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem trying to create SciTE .ses files with AHk

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Serenity



Joined: 08 Nov 2004
Posts: 1003

PostPosted: Fri Apr 14, 2006 3:35 pm    Post subject: Problem trying to create SciTE .ses files with AHk Reply with quote

I'm trying to write a script that creates SciTE session files (.ses). These files appear to be simple text files, that look like this in a text editor:

Quote:
<pos=1> x:\hotkeys\main.ahk
<pos=1> x:\hotkeys\editors.ahk
<pos=1> x:\hotkeys\global.ahk


I found SciTE wouldn't open the AHk-created .ses file, so I compared SciTE-created .ses file to one made with AHk in a hex editor and the only difference is that AHk writes 0D0A for the linefeed character (`n) whereas SciTE only writes 0A.

I tried using the Transform function to return the character number of this 0A, and it returns 10, which is the linefeed character. This is strange because writing Chr(10) to another file actually writes 0D0A. Is there a way I can only write 0A?

Code:
; read the char
fileread, this, char.ses ; 0A
msgbox, % Asc(this) ; 10

; write the char
fileappend, % Chr(10), test ; 0D0A

_________________
"Anything worth doing is worth doing slowly." - Mae West
Back to top
View user's profile Send private message Visit poster's website
freakkk



Joined: 29 Jul 2005
Posts: 130

PostPosted: Fri Apr 14, 2006 5:10 pm    Post subject: Reply with quote

Quote:
Is there a way I can only write 0A?

This isn't an answer to your question.. but may be a possible workaround; Could you possibly make a session file like this..
Code:
<pos=1> %TEMP%\main.ahk
<pos=1> %TEMP%\editors.ahk
<pos=1> %TEMP%\global.ahk
...and then on launch have ahk do a 'FileInstall, main.ahk, %TEMP%\main.ahk, 1' type thing. This way it wouldn't be necessary to have ahk edit or create your .ses file.. but would make sure the paths lines up.
_________________
.o0[ corey ]0o.
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Sat Apr 15, 2006 10:32 am    Post subject: Re: Problem trying to create SciTE .ses files with AHk Reply with quote

Serenity wrote:
I found SciTE wouldn't open the AHk-created .ses file, so I compared SciTE-created .ses file to one made with AHk in a hex editor and the only difference is that AHk writes 0D0A for the linefeed character (`n) whereas SciTE only writes 0A.
Strange, I didn't knew it was sensible to line ending. I would file this as a bug of SciTE (but this session thingy isn't much maintened and should change to a .properties like format).
AHK's Manual wrote:
To append in binary mode rather than text mode, prepend an asterisk to the filename. This causes each linefeed character (`n) to be written as as a single linefeed (LF) rather than the Windows standard of CR+LF. For example: *C:\My Unix File.txt
should help you...
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Serenity



Joined: 08 Nov 2004
Posts: 1003

PostPosted: Sat Apr 15, 2006 4:38 pm    Post subject: Re: Problem trying to create SciTE .ses files with AHk Reply with quote

Quote:
To append in binary mode rather than text mode, prepend an asterisk to the filename.


Thanks Philippe, that fixed it. :)
_________________
"Anything worth doing is worth doing slowly." - Mae West
Back to top
View user's profile Send private message Visit poster's website
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Sat Apr 15, 2006 5:03 pm    Post subject: Reply with quote

I just made recently something that allows to open all files listed in a session file, this is a good place to share:
OpenSciTESession
Code:
; Run SciTE with the loadsession option, with path correctly escaped
StringReplace sessionPath, 1, \, \\, All
Run %SciTE_Home%\SciTE.exe "-loadsession:%sessionPath%"
Of course, SciTE_Home must be correctly set, otherwise, just use the regular path.
Then, put the following in the registry:
Code:
Windows Registry Editor Version 5.00

; SciTE specific: open a session.
[HKEY_CLASSES_ROOT\.ses]
@="SciTESessionFile"

[HKEY_CLASSES_ROOT\SciTESessionFile]
; English
@="SciTE Session File"
; French
@="Session SciTE"

[HKEY_CLASSES_ROOT\SciTESessionFile\DefaultIcon]
@="C:\\Program Files\\UText\\SciTE\\SciTE.exe"

[HKEY_CLASSES_ROOT\SciTESessionFile\shell\open\command]
; The following doesn't work because backslashes in path must be escaped
#~ @="\"C:\\Program Files\\UText\\SciTE\\SciTE.exe\" \"-loadsession:%1\""
@="\"C:\Program Files\USys\AutoHotkey\AutoHotkey.exe\" "C:\\Program Files\\UText\\SciTE\\OpenSciTESession.ahk\" \"%1\""
As usual, the paths must be adjusted to yours.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group