Formats passed string based on length. Perfect for emails and text files.
---------------------------------------------------------------------------------------
1
2' Company: Sabra Inc
3' Author: Dave Hoffenberg
4' Date: 10/5/00
5' Function: Formats passed string based on length. Perfect for emails and text files.
6' Freeware
7
8Function Padding(Value, Length)
9' If the length of the value is less than the variable 'length'
10If Len(Value) < Length Then
11charcount = Length - len(Value)
12
13for i = 1 to (charcount - 1)
14
15padding = padding & " "
16
17next
18
19mystring = Value & padding
20' If the length of the value is greater than the variable 'length'
21Elseif len(Value) > Length Then
22mystring = Left(Value,Length)
23
24Else
25set mystring = Value
26
27End If
28
29Padding = mystring
30
31End Function
32
33
34Set fso = CreateObject("Scripting.FileSystemObject")
35Set MyFile = fso.CreateTextFile(Server.MapPath("test.txt"), True)
36
37MyFile.WriteLine Padding("this is a test", 25) & "end of line."
38
39Set fso = Nothing
40Set MyFile = Nothing
41
42response.write "done"
Retrieves file size(K) of any file passed to it.
---------------------------------------------------------------------------
1
2' Company: Sabra Inc
3' Author: Dave Hoffenberg
4' Function: Retrieves file size(K) of any file name passed to it.
5' Freeware
6
7Function ShowFileSize(filespec)
8file = Server.MapPath(filespec)
9Set fso = CreateObject("Scripting.FileSystemObject")
10If fso.FileExists(file) Then
11Set f = fso.GetFile(file)
12intSizeB = f.Size
13intSizeK = Int((intSizeB/1024) + .5)
14If intSizeK = 0 Then intSizeK = 1
15ShowFileSize = intSizeK & "k"
16Else
17ShowFileSize = "File Doesn't Exist"
18End If
19Set fso = Nothing
20End Function
21
22response.write ShowFileSize("test.txt")