<%
'dll外部调用哦的 ASP小程序 处理动作,如计算数字值,回复聊天内容,基础框架 可扩展简单
Class dllCommand
private FrmName '窗体名称
'初始化
Private Sub Class_Initialize()
End Sub
'析构函数 类终止
Private Sub Class_Terminate()
End Sub
'设置窗体名称
Public Property Let setFrmName(Str)
FrmName=Str
End Property
'获得窗体名称
Public Property Get getFrmName()
getFrmName = FrmName
End Property
'处理Action
function handAction(byval commandStr)
dim action,content
commandStr = phpTrim(commandStr)
content = commandStr
if instr(content," ")>0 then
action=mid(content,1,instr(content," ")-1)
content=mid(content,instr(content," ")+1)
end if
if action="ask" then
if content="35915100" then
handAction = "35915100 仿站与ASP程序维护群"
exit function
end if
elseif right(content,1) = "=" then
content=mid(commandStr,1,len(commandStr)-1)
handAction = commandStr & "" & eval(content)
end if
end function
Function Rw(Str)
Response.Write Str
End Function
'引用函数
Function PHPTrim(Str)
PHPTrim = TrimVbCrlf(Str)
End Function
Function Echo(Word, Str)
Call echoPrompt(Word, Str)
End Function
Function TrimVbCrlf(Str)
TrimVbCrlf = rtrimVBcrlf(ltrimVBcrlf(Str))
End Function
Function echoPrompt(Word, Str)
Response.Write "<font color=Green>" & Word & "</font>:" & Str & "<br>"
End Function
Function rtrimVBcrlf(Str)
Dim Pos, isBlankChar
Pos = Len(Str)
isBlankChar = True
While isBlankChar and Pos >= 2
If Mid(Str, Pos, 1) = " " & Mid(Str, Pos, 1) = vbTab Then'把vbTab也去掉
Pos = Pos - 1
ElseIf Mid(Str, Pos - 1, 2) = vbCrLf Then
Pos = Pos - 2
Else
isBlankChar = False
End If
Wend
rtrimVBcrlf = RTrim(Left(Str, Pos))
End Function
Function ltrimVBcrlf(Str)
Dim Pos, isBlankChar
Pos = 1
isBlankChar = True
While isBlankChar
If Mid(Str, Pos, 1) = " " Or Mid(Str, Pos, 1) = vbTab Then'把vbTab也去掉
Pos = Pos + 1
ElseIf Mid(Str, Pos, 2) = vbCrLf Then
Pos = Pos + 2
Else
isBlankChar = False
End If
Wend
ltrimVBcrlf = Right(Str, Len(Str) - Pos + 1)
End Function
End Class
Dim ddlCD : Set ddlCD = New dllCommand '加载类
'call ddlCD.handAction("1+2*6+2=")
'call ddlCD.rw(ddlCD.handAction("ask 35915100"))
select case request("act")
case "handle" : call ddlCD.rw(ddlCD.handAction(request("command")))
case else:Default()
end select
'默认
sub Default()
%>
<form id="form1" name="form1" method="post" action="?act=handle">
发送内容
<input name="command" type="text" id="command" value="3+3*5=" />
<input type="submit" name="button" id="button" value="提交" />
</form>
<form id="form2" name="form1" method="post" action="?act=handle">
发送内容
<input name="command" type="text" id="command" value="ask 35915100" />
<input type="submit" name="button" id="button" value="提交" />
</form>
<%end sub%>