Sign in to follow this  
Followers 0
xcal

Is there a better way to open...

6 posts in this topic

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

Share this post


Link to post
Share on other sites



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

You'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.


[center]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.[/center]

Share this post


Link to post
Share on other sites

That's exactly it! :P

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. :)

Share this post


Link to post
Share on other sites

#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.


[center]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.[/center]

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by xcal

Share this post


Link to post
Share on other sites

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?


[center]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.[/center]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0