mIRC Home    About    Download    Register    News    Help

Print Thread
New prop ext to $file() #261433 03/10/17 02:38 PM
Joined: Sep 2015
Posts: 85
klez Offline OP
Babel fish
OP Offline
Babel fish
Joined: Sep 2015
Posts: 85
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

Re: New prop ext to $file() [Re: klez] #261434 03/10/17 03:40 PM
Joined: Mar 2008
Posts: 87
B
BhaaL Offline
Babel fish
Offline
Babel fish
B
Joined: Mar 2008
Posts: 87
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

Re: New prop ext to $file() [Re: BhaaL] #261435 03/10/17 04:33 PM
Joined: Sep 2015
Posts: 85
klez Offline OP
Babel fish
OP Offline
Babel fish
Joined: Sep 2015
Posts: 85
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\

Re: New prop ext to $file() [Re: klez] #261441 04/10/17 05:25 AM
Joined: Jan 2005
Posts: 187
Brax Offline
Vogon poet
Offline
Vogon poet
Joined: Jan 2005
Posts: 187
$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
Re: New prop ext to $file() [Re: klez] #261443 04/10/17 03:41 PM
Joined: Mar 2008
Posts: 87
B
BhaaL Offline
Babel fish
Offline
Babel fish
B
Joined: Mar 2008
Posts: 87
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.