mIRC Home    About    Download    Register    News    Help

Print Thread
#261433 03/10/17 02:38 PM
Joined: Sep 2015
Posts: 101
klez Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Sep 2015
Posts: 101
Hi!

I suggest to add $file().ext that returns the extension of the file. This will facilitate a lot of scripts to extract the extension from a path/file.

There're many ways using scripts to return the extension of a file, but i think is better to add a prop ext to $file() smile

Joined: Mar 2008
Posts: 93
B
Babel fish
Online
Babel fish
B
Joined: Mar 2008
Posts: 93
Might as well include $file(C:\Program Files\mIRC\mIRC.exe).fn (mIRC.exe), $file(C:\Program Files\mIRC\mIRC.exe).fnnoext (mIRC), $file(C:\Program Files\mIRC\mIRC.exe).shortdir (mIRC) and $file(C:\Program Files\mIRC\mIRC.exe).longdir (C:\Program Files\mIRC) for completeness sake if we decide to add $file(C:\Program Files\mIRC\mIRC.exe).ext (exe).
Courtesy of the .NET Frameworks Path class (also FileInfo, DirectoryInfo etc. for similar useful functions). Names are mostly guesswork to fit with existing identifiers, but I don't mind if it ends up being $file().name for example or whatever...

Or should $file().ext return the extension including the dot, like .NETs Path.GetExtension does? smile

Joined: Sep 2015
Posts: 101
klez Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Sep 2015
Posts: 101
Quote:
$file(C:\Program Files\mIRC\mIRC.exe).fn (mIRC.exe)


already exists, but is $nopath(C:\Program Files\mIRC\mIRC.exe)

Quote:
$file(C:\Program Files\mIRC\mIRC.exe).shortdir and .longdir


already exists, but is $shortfn(C:\Program Files\mIRC\mIRC.exe), respectively $longfn(C:\Program Files\mIRC\mIRC.exe)

Also exists: $nofile(C:\Program Files\mIRC\mIRC.exe) that returns C:\Program Files\mIRC\

Joined: Jan 2005
Posts: 192
Vogon poet
Offline
Vogon poet
Joined: Jan 2005
Posts: 192
$file
$nofile
$shortfn / $file().shortfn
$longfn / $file().longfn
$nopath
$nofile

I suppose for the sake of keeping naming scheme we could call it $fileext
Allthough call it whatever you like for completeness sake it wouldn't hurt to have identifier like that.


echo -a $signature
Joined: Mar 2008
Posts: 93
B
Babel fish
Online
Babel fish
B
Joined: Mar 2008
Posts: 93
Originally Posted By: klez
Quote:
$file(C:\Program Files\mIRC\mIRC.exe).shortdir and .longdir

already exists, but is $shortfn(C:\Program Files\mIRC\mIRC.exe), respectively $longfn(C:\Program Files\mIRC\mIRC.exe)


Close, but not quite; what I meant was the result of $nofile for .longdir (ie. "the full directory path where the file is in").
There doesn't seem to be an equivalent for .shortdir though ("the name of the directory where the file is in, without path"; C:\Users\BhaaL\test.txt -> "BhaaL"). Perhaps using mIRC as example wasn't too bright of an idea (since the folder name is mIRC and the exe name without extension is mIRC)

I don't mind either way (its own identifier vs. property on $file) though; just thought I'd bring them up to have a rather complete set of useful functions.


Link Copied to Clipboard