This is a simple bit of code that can be used to extract the 3 character extension of a file, filename or document and display a different message or perform a differnt function for each.
Very useful when used with a file upload. Code: ASP 3.0 & VBScript
|poor/buggy code |
Written by Anonymous User (#1398-68) from Md, USA (Tuesday, May 15, 2007)
||Strengths: no comment
Weaknesses: it's wrong
Details: This code snippet is poor, and has a bug, making most of it useless/unnecessary.
str3 = intHowLong - intHowLong + 3
is subtracting intHowLong from itself.
All this does is say :
str3 = 3
It will *always* = 3. Then it uses that value in here.
strExt = Right(strFilename, str3)
You'd might as well just summarize all this down to the one line below.
strExt = Right(strFilename, 3)
The bug basically means that even checking the total length was a waste of code & time.
Better would be to look for the '.' and get the length one one side of it. Remember that not all file extensions are 3 chars long.
Review Based On: using demo only
Works like a charm!
Written by Anonymous User (#1444-127) from Nebraska (Friday, February 06, 2004)
||Strengths: Small, fast code and it works!
Weaknesses: no comment
Details: This bit of code worked perfectly for me. I actually modified it a little bit to append an extension onto the filename. It worked the first time I ran the code.
Review Based On: 1 Day(s) of usage
right code at the right time
Written by Lil Peck from Kansas (Saturday, July 26, 2003)
Writer is with: http://www.nsba.com/net
||Strengths: does exactly what it is supposed to do
Details: I have a script that displays a list of files. I needed to make the image files display with code different from the Flash files. This little script makes that easy.
Review Based On: 1 Hour(s) of usage