Load a "txt.prg" automaticaly

Started by Alain, August 24, 2009, 11:32:24 PM

Previous topic - Next topic

Alain

Hello
I am looking fro a new editor (Visual Fox Pro) because my old editor (16b) is very obsolete...
and after comparing a lot,  HE is very powerful.

BUT a useful function in my old editor don't exist. I want by a double click (or CTRL+ENTER)
load a program file when the cursor is on a single name (without extension)

EX: On PAD 35 DO thisprogram
When the cursor is on "thisprogram" a double click load the program "thisprogram.prg" localised on the current directory and the automaticaly window is opened.
How make this ?

Have a good day
Alain



alex

Hi Alain,

welcome on forum.

I think in current moment it is not possible with HE. And I would tell that your request is rather specific. HippoEDIT has Open Selected command which opens file under cursor, it checks as current file folder as open project, but it needs fully qualified name (with extension).

Another function is Open Corresponding File which can open file pairs (file with same file name as current but with different extension) but this also does not fit to your needs.

So there are two possible solutions for this:

  • you wait for 1.50 and then use scripting support to add script executed by some shortcut to open a file under cursor. Then you can add any logic you want;
  • I can extend logic for Open Selected to check also for a file with name equal to selected name plus current file extension, if this would help

Best regards,
Alex.
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

Stefan

#2
Hi Alan,
welcome to the community!


I think HE is very powerful and flexible right now already and "Tools" can do what you want.

Quote from: Alain on August 24, 2009, 11:32:24 PMload the program "thisprogram.prg" localised on the current directory

Let's try this.

Please follow this steps:
- open an document with an extension where you want to use this
- open Menu "Tools > Manage Tools..."
- [select the desired syntax if needed, see FAQ section and search for TOOLs to learn more]
- click on "Add..."

Title:        as you like, maybe 'Execute program under cursor'
Command: %FileDir%%CurrentWord%.prg

(Note: this parameter you find by Arguments field, click on the bold arrow on the right
and insert the arguments into the arguments field. The cut and paste them to command field.)

- [OK] close the tools dialog.

- now set mouse cursor on your "thisprogram" in document and execute the tool.
What happens?  ;D



Explanation:
HE parameter %FileDir% is expanded to path of current file.
HE parameter %CurrentWord% is expanded to current word under cursor.
In the tools command i add an ".prg" to complete the command.




Hints:
To be more flexible:
In Tools you can also add
for 'Arguments:'    .%Extension%
to be prompted to enter an extension.
That way you can execute *.prg or *.cmd or *.exe or *....

Therefor enter an . (dot) (if you want this. You can enter the dot later by yourself in the prompted dialog too)
and click on the arrow on the right to insert "Interactive" which insert an parameter %Variable name%
which you can modify to call %Enter the extension% or what else.

-

Instead of %FileDir% you can enter any path you like literally , even relative ones.
Or you can use interactive parameter %Variable name% here too:
Command: %Variable name enter path%%CurrentWord%%Variable name enter extension incl. dot%

Check the other parameters under the bold black arrow.
And take a look at Environment there. (%ProgramFiles% is not listed there but i think this should work too?)

-

You are even able to set an shortcut to execute this tool or put it into the context menu...
...and you can save BTW this or all modified documents before executing the tool.

-
Now imagine what would be possible with HippoEDIT once there is scripting support?!?
HTH?

.

.
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

Alain

Hello Alex

Yes a "Searching File" is a great idea (with a choice extension)
I know HE is a editor!  not a file manager ....
but the Post from Arthur (april 2009)  "Searching for a file" is in the same way

Hello Stephan
It's MAGIC that works !
and a good demo for this powerful tool.
1000 thanks

HE is great.

Have a good day
Alain


alex

Hi All,

to Stefan: thanks a lot for perfect proposal, even I was not able to do this better :)) Also I thought Alain want to open file in the editor not execute. This was my fault.

to Alain: I do not want to build in search for a file not text (generally you can achieve this by using regular expression and search for . and Find Next in some directory and use you file name as file mask), but maybe in 1.5x I would introduce "file crawler" which would help.

Best regards,
Alex.
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

Stefan

Quote from: alex on August 25, 2009, 01:55:20 PM
Also I thought Alain want to open file in the editor not execute. This was my fault.

> open file in the editor
oooh, really? Sorry...

Try:

Interactive and flexible open file under cursor

Title:            as you like, maybe 'Open file under cursor'
Command:   %AppDir%HippoEDIT.exe
Arguments:  %FileDir%%CurrentWord%%Enter an extension%
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

alex

Good :) But here can be some problems to open it in same session ;)
Of course if you have "Allow Multiple instances" off, mostly it would work. But also not always (you can open explicitly new session of HE or with command line switch or using different workspace).
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

Stefan

Quote from: alex on August 25, 2009, 03:30:59 PM
Good :) But here can be some problems to open it in same session ;)
Of course if you have "Allow Multiple instances" off, mostly it would work. But also not always (you can open explicitly new session of HE or with command line switch or using different workspace).

new command line switch: -UseSameInstance  as opposite of -m ?
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

alex

I think, this is rather strange command line switch :)
Just imagine:


cmd.exe
hippoedit.exe -UseSameInstance


what this should do?
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

Stefan

Quote from: alex on August 26, 2009, 01:27:45 PM
I think, this is rather strange command line switch :)
Just imagine:


cmd.exe
hippoedit.exe -UseSameInstance

what this should do?
Just Ignore it:

Func UseSameInstance()
If no HE-instance running THEN
    open new HE-instance
Else
    use existent HE-instance with same ProcID as called HE-app
    open new tab

.

Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

alex

Generally you are right. I have not thought about this...
But even with your suggestion it is not easy:
- Process ID of child process (new Hippoedit) is not the same as parent.
- Find parent process ID is not trivial
- Even with Process ID I do not know how to find main window of the process to send load information to it :/

So, seems to me too complex.
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

Stefan

OH, i see.  Then not. Thanks for looking into it.
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

Alain

Hello

you are right...
With a new session you have another problem : you load all programs before AND the selected
This use cpu power !

Also
may be it's possible to load a new instance but only with the "SelectedWord+.prg"
for example :  Hippedit.exe  /JustOne (or /JustThis)  myprogram.prg

Have a good day
Alain

alex

Hi Alain,

yes you can load He with one file only, just pass viewer workspace as start up workspace, like this:
"HippoEdit.exe" --workspace=viewer myprogram.prg

viewer workspace by default do not store open files between sessions.

Or go to File -> Workspace -> Properties and remove Remember Open Documents.

Best regards,
Alex.
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

Alain

Hello

I complete....

I am using HE with a window (txt.prg)
and in the editor I selected the word "myprogram"

When I use the function to load automatically "myprogram" + ".prg"
HE open a new session WITH in the editor's window "txt.prg" in one tab
and "myprogram.txt" in a second tab.

Also If you have a lot of "txt.prg" load in the first session according configuration when you use this function HE load all "txt.prg" PLUS the selected word (+.prg)

If you can force JustOne file in the function you call a new session with ONLY the selected word program.

Have a good day
Alain