一些源程序 - 获得文件大小和字符串处理
程序员文章站
2022-09-04 16:30:25
formats passed string based on length. perfect for emails and text files.--------------------------...
formats passed string based on length. perfect for emails and text files.
---------------------------------------------------------------------------------------
<%
company: sabra inc
author: dave hoffenberg
date: 10/5/00
function: formats passed string based on length. perfect for emails and text files.
freeware
function padding(value, length)
if the length of the value is less than the variable length
if len(value) < length then
charcount = length - len(value)
for i = 1 to (charcount - 1)
padding = padding & " "
next
mystring = value & padding
if the length of the value is greater than the variable length
elseif len(value) > length then
mystring = left(value,length)
else
set mystring = value
end if
padding = mystring
end function
set fso = createobject("scripting.filesystemobject")
set myfile = fso.createtextfile(server.mappath("test.txt"), true)
myfile.writeline padding("this is a test", 25) & "end of line."
set fso = nothing
set myfile = nothing
response.write "done"
%>
retrieves file size(k) of any file passed to it.
---------------------------------------------------------------------------
<%
company: sabra inc
author: dave hoffenberg
function: retrieves file size(k) of any file name passed to it.
freeware
function showfilesize(filespec)
file = server.mappath(filespec)
set fso = createobject("scripting.filesystemobject")
if fso.fileexists(file) then
set f = fso.getfile(file)
intsizeb = f.size
intsizek = int((intsizeb/1024) + .5)
if intsizek = 0 then intsizek = 1
showfilesize = intsizek & "k"
else
showfilesize = "file doesnt exist"
end if
set fso = nothing
end function
response.write showfilesize("test.txt")
%>
---------------------------------------------------------------------------------------
<%
company: sabra inc
author: dave hoffenberg
date: 10/5/00
function: formats passed string based on length. perfect for emails and text files.
freeware
function padding(value, length)
if the length of the value is less than the variable length
if len(value) < length then
charcount = length - len(value)
for i = 1 to (charcount - 1)
padding = padding & " "
next
mystring = value & padding
if the length of the value is greater than the variable length
elseif len(value) > length then
mystring = left(value,length)
else
set mystring = value
end if
padding = mystring
end function
set fso = createobject("scripting.filesystemobject")
set myfile = fso.createtextfile(server.mappath("test.txt"), true)
myfile.writeline padding("this is a test", 25) & "end of line."
set fso = nothing
set myfile = nothing
response.write "done"
%>
retrieves file size(k) of any file passed to it.
---------------------------------------------------------------------------
<%
company: sabra inc
author: dave hoffenberg
function: retrieves file size(k) of any file name passed to it.
freeware
function showfilesize(filespec)
file = server.mappath(filespec)
set fso = createobject("scripting.filesystemobject")
if fso.fileexists(file) then
set f = fso.getfile(file)
intsizeb = f.size
intsizek = int((intsizeb/1024) + .5)
if intsizek = 0 then intsizek = 1
showfilesize = intsizek & "k"
else
showfilesize = "file doesnt exist"
end if
set fso = nothing
end function
response.write showfilesize("test.txt")
%>
上一篇: Python使用requests提交HTTP表单的方法
下一篇: Docker的网络模式详解