mIRC Homepage
Posted By: klez New prop ext to $file() - 03/10/17 02:38 PM
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
Posted By: BhaaL Re: New prop ext to $file() - 03/10/17 03:40 PM
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
Posted By: klez Re: New prop ext to $file() - 03/10/17 04:33 PM
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\
Posted By: Brax Re: New prop ext to $file() - 04/10/17 05:25 AM
$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.
Posted By: BhaaL Re: New prop ext to $file() - 04/10/17 03:41 PM
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.
© mIRC Discussion Forums