xcal Posted September 11, 2006 Share Posted September 11, 2006 What I want to do is open a text file (I don't mean fileopen, I mean actually open it) at a specific line, when a button is pushed. Right now I'm doing it with a really ugly... Send('{Down ' & $list_file[4] - 1 & '}') ($list_file[4] - 1 is the file line returned from another function.) ...when the editor gets focus. Does anyone know a better, more reliable, way? Also, two things to consider, I won't know the end user's default text editor, and what if the button gets pushed while the file is already opened. TIA How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 11, 2006 Moderators Share Posted September 11, 2006 What I want to do is open a text file (I don't mean fileopen, I mean actually open it) at a specific line, when a button is pushed. Right now I'm doing it with a really ugly... Send('{Down ' & $list_file[4] - 1 & '}') ($list_file[4] - 1 is the file line returned from another function.) ...when the editor gets focus. Does anyone know a better, more reliable, way? Also, two things to consider, I won't know the end user's default text editor, and what if the button gets pushed while the file is already opened. TIAYou're question/request is a bit confusing... could you possibly elaborate a tad more? I'm understanding it like this. 1. I have a GUI 2. The user selects some text 3. I search the txt file for the text 4. I want to open the file to show that text specifically and nothing else That's just how I'm reading your post. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
xcal Posted September 11, 2006 Author Share Posted September 11, 2006 That's exactly it! To clarify your #4, I want to open the actual text file in which the line exists, and scroll to the specific line that contains the selected text (from my gui). Getting the line to scroll to is no problem at all. I just can't think of a reliable way to actually scroll to it, unless I know in advance what someone's default text editor is. How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 11, 2006 Moderators Share Posted September 11, 2006 #4 is easy using Run(@Comspec) it's the rest I'm still confused about... I'd like to sincerely see the code you're referring to though. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
xcal Posted September 11, 2006 Author Share Posted September 11, 2006 (edited) Well, this is the part in question. The user will have a row selected in a listview.Func openfile() $list_file = StringSplit(GUICtrlRead(GUICtrlRead($list)), '|') If $list_file[0] > 1 Then Run(@ComSpec & ' /c start "Opening..." "' & $list_file[3] & '"', '', @SW_HIDE) EndFunc ;==>openfile$list_file[3] is the file path and file (c:\path\some.txt)$list_file[4] of the array is the line number.Opening the file in someone's default editor is a snap... it's making it go to the line the selected text is on ($list_file[4]) which is the real problem. I can live without being able to do it, but it sure would be a nice touch to my app if it wasn't too hard to do. edits: being tired = sloppy Edited September 11, 2006 by xcal How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 11, 2006 Moderators Share Posted September 11, 2006 I'm tired as well, and Gary has just started to give me my daily thrashings. How about just figuring out where the line is in the txt file and show from that point on (ie... write to another file from that line down) and show that line down in the open? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now