mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2003
Posts: 106
L
Vogon poet
OP Offline
Vogon poet
L
Joined: Feb 2003
Posts: 106
I have a list of files with different extensions in a custom window. Using a menu I can grab the filename and use /run to view the file e.g.
Code:
menu @window {
  dclick: {
    %file = $line(@window,$1,1)
    viewfile %file
} 

The viewfile alias could become quite long if I have to accommodate every file extension registered on the computer.
Code:
alias viewfile {
  %extension = $gettok($1,2,46)
  if %extension == txt { run notepad.exe $1 }
  if %extension == jpg { run thumbsplus.exe $1 }
  if %extension == mp3 { run winamp.exe $1 }
  etc
  etc
}
I would like to be able to doubleclick the file and have mirc invoke the correct program for viewing/playing/editing the file.
Any hints?

Regard the code above as pseudocode. I haven't tested it, but I hope you get the picture.

Cheers


-
Just because it never happened doesn't mean it isn't true.
Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
As long as the file type extension is associated - in Windows - with the program you want to use then you can just use /run $1

Joined: Feb 2003
Posts: 106
L
Vogon poet
OP Offline
Vogon poet
L
Joined: Feb 2003
Posts: 106
hmmm .. but I don't want to use /run
Quote:
The viewfile alias could become quite long if I have to accommodate every file extension registered on the computer.

And what if the user of my script has a file association on her computer I know nothing about?


-
Just because it never happened doesn't mean it isn't true.
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Quote:
I would like to be able to doubleclick the file and have mirc invoke the correct program for viewing/playing/editing the file.
To me, the only "correct" program is the app associated with the file extension - /run <file>
Quote:
And what if the user of my script has a file association on her computer I know nothing about?
That is why you should not specify an app for /run, isn't it? Why exactly do you dislike using /run <file>?

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Like Horstl said, you just type /run filename.ext . You don't have to specify the program to open it in. It will automatically open in whatever program the user has set up for that extension. If one person has .txt open in notepad and another has .txt open in wordpad, then /run will open text files in the program that they have selected.

You can just get rid of your alias and use the following:

run $line(@window,$1,1)


Though I would probably recommend using $qt() to handle any potential issues with spaces.

run $qt($line(@window,$1,1))


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard