📄 script.cls
字号:
For t = pc To lc
If Left$(LTrim$(code$(t)), 2) = "if" Then nebo = nebo + 1
If Left$(LTrim$(code$(t)), 5) = "endif" Then nebo = nebo - 1
'Debug.Print nebo
If Left$(LTrim$(code$(t)), 5) = "endif" And nebo = -1 Then pc = t: Exit For
Next t
GoTo WIPEOUT
End If
If cmd$ = "end" Then
scr = False
End If
If cmd$ = "print" Then
ptemp$ = ""
For t = 1 To xc
ptemp$ = ptemp$ & ParseParam(w$(t))
Next t
WXB sck, ptemp$
ptemp$ = ""
GoTo WIPEOUT
End If
If cmd$ = "writehttp" Then
WriteHTTP sck, Val(ParseParam(w$(1))), ParseParam(w$(2))
End If
If cmd$ = "if" Then
'Debug.Print "IF FUNCTION CALLED"
cvalue = 0
pre_op$ = ""
total_if_params = xc
'Debug.Print xc
For if_loop = 1 To xc
c_check$ = w$(if_loop)
'Debug.Print c_check$
If c_check$ = "&&" Then pre_op$ = "&&"
If c_check$ = "||" Then pre_op$ = "||"
If Left$(c_check$, 1) = "(" Then
' If Segment
'(name$(hello) == "PASS$")
c_check$ = Mid$(c_check$, 2, Len(c_check$) - 2)
'name$(hello) == "PASS$"
s1 = Len(c_check$)
Erase p$()
iq = False: cc = 0
For tt = 1 To s1
hl$ = Mid$(c_check$, tt, 1)
If hl$ = "(" And iq = False Then ik = ik + 1
If hl$ = ")" And iq = False Then ik = ik - 1
If hl$ = " " And iq = False And ik = 0 Then cc = cc + 1
If hl$ = "'" Then iq = Not iq
If iq = False And ik = 0 Then p$(cc) = p$(cc) & Trim$(hl$)
If iq = False And ik <> 0 Then p$(cc) = p$(cc) & hl$
If iq = True Then p$(cc) = p$(cc) & hl$
Next tt
c0x$ = p$(0)
c2x$ = p$(2)
p$(0) = ParseParam(p$(0))
p$(2) = ParseParam(p$(2))
kk = 0
If (p$(0) <> "" And p$(2) <> "") And Val(p$(0)) = Val(Str$(Val(p$(0)))) Then
ISTHISINT = 1
Else
ISTHISINT = 0
End If
If IsString(c0x$) = 1 Then ISTHISINT = 0
If IsString(c2x$) = 1 Then ISTHISINT = 0
If IsInteger(c0x$) = 1 Then ISTHISINT = 1
If IsInteger(c2x$) = 1 Then ISTHISINT = 1
Select Case ISTHISINT
Case 0
Select Case p$(1)
Case ">"
If p$(0) > p$(2) Then kk = 1
Case "<"
If p$(0) < p$(2) Then kk = 1
Case "=="
If p$(0) = p$(2) Then kk = 1
Case "!="
If p$(0) <> p$(2) Then kk = 1
Case ">="
If p$(0) >= p$(2) Then kk = 1
Case "<="
If p$(0) <= p$(2) Then kk = 1
End Select
Case 1
p1 = Val(p$(0))
p2 = Val(p$(2))
Select Case p$(1)
Case ">"
If p1 > p2 Then kk = 1
Case "<"
If p1 < p2 Then kk = 1
Case "=="
If p1 = p2 Then kk = 1
Case "!="
If p1 <> p2 Then kk = 1
Case ">="
If p1 >= p2 Then kk = 1
Case "<="
If p1 <= p2 Then kk = 1
End Select
End Select
' Debug.Print p$(0)
' Debug.Print p$(2)
' Debug.Print kk
If kk = 0 Then
If pre_op$ = "||" Or pre_op$ = "OR" Then
If cvalue = 1 Then cvalue = 1
If cvalue = 0 Then cvalue = 0
End If
If pre_op$ = "&&" Or pre_op$ = "AND" Then
If cvalue = 0 Then cvalue = 0
If cvalue = 1 Then cvalue = 0
End If
End If
If kk = 1 Then
If pre_op$ = "||" Or pre_op$ = "OR" Then
If cvalue = 0 Then cvalue = 1
If cvalue = 1 Then cvalue = 1
End If
If pre_op$ = "&&" Or pre_op$ = "AND" Then
If cvalue = 1 Then cvalue = 1
If cvalue = 0 Then cvalue = 0
End If
End If
' Debug.Print kk
If pre_op$ <> "&&" And pre_op$ <> "||" And pre_op$ <> "AND" And pre_op$ <> "OR" Then
cvalue = kk
End If
End If
Next if_loop
it = cvalue
If it = 0 Then
cando = 0
For t = pc + 1 To lc
' THIS NEXT 2 LINES ARE A TEST SECTION
If cando < 1 And Left$(LTrim$(code$(t)), 4) = "else" Then pc = t: Exit For
If cando < 1 And Left$(LTrim$(code$(t)), 5) = "endif" Then pc = t: Exit For
If Left$(LTrim$(code$(t)), 2) = "if" Then cando = cando + 1
If Left$(LTrim$(code$(t)), 5) = "endif" Then cando = cando - 1
'Debug.Print Left$(LTrim$(code$(t)), 5); cando
' If cando < 1 And Left$(LTrim$(code$(t)), 4) = "else" Then pc = t: Exit For
' If cando < 1 And Left$(LTrim$(code$(t)), 5) = "endif" Then pc = t: Exit For
Next t
End If
'WXB sck, "I HAD BEEN CHECKED"
GoTo WIPEOUT
End If
' ** SECURE COMMANDS
If SFA = 1 Then
End If
WIPEOUT:
End If
SkipMe:
pc = pc + 1
If pc > lc Then scr = False
Loop
If sx(sck).Buffer = "" Then sx(sck).Buffer = vbCrLf & vbCrLf
ScriptTidy
Exit Sub
Execute_Error:
Debug.Print "Script Error"
WXB sck, "Error Occured In Script Processing On Line " & Trim$(Str$(pc)) & " ErrCode " & Err.Description
ScriptTidy
sx(sck).Reqok = True
End Sub
Public Function ParseParam(para As String) As String
'Debug.Print "PARA=" & para$
If para$ = "&" Or para$ = "" Or para$ = " &" Then Exit Function
Dim d$(200)
Dim iq As Boolean
If para$ = "lbCrLf" Then ParseParam = vbCrLf: Exit Function
' Is String?
para$ = Trim$(para$)
If IsString(para$) = 1 Then
ParseParam = GetString(para$)
Exit Function
End If
' Is A Number?
If IsNumeric(para$) Then
ParseParam = para$
Exit Function
End If
' Is Bracketed?
'(3 * 10)
If Left$(para$, 1) = "(" And Right$(para$, 1) = ")" Then
' This parameter is bracketed, we need to resolve whatevers inside it
f1$ = Mid$(para$, 2, Len(para$) - 2)
'3 * 10
' Now we parse the whole thing to get the sub params
r = Len(f1$)
jk = 0: wc = 0
Erase d$()
For g = 1 To r
k$ = Mid$(f1$, g, 1)
If k$ = "'" Then iq = Not iq
If k$ = "(" And iq = False Then jk = jk + 1
If k$ = ")" And iq = False Then jk = jk - 1
If k$ = " " And iq = False And jk = 0 Then wc = wc + 1
d$(wc) = d$(wc) & k$
Next g
For g = 0 To wc
welly = 1
d$(g) = Trim$(d$(g))
If d$(g) = "+" Or d$(g) = "-" Or d$(g) = "/" Or d$(g) = "*" Then
xc$ = d$(g): welly = 0
End If
If welly = 1 Then
If xc$ = "+" Then tempo = tempo + Val(ParseParam(d$(g)))
If xc$ = "-" Then tempo = tempo - Val(ParseParam(d$(g)))
If xc$ = "/" Then tempo = tempo / Val(ParseParam(d$(g)))
If xc$ = "*" Then tempo = tempo * Val(ParseParam(d$(g)))
End If
If xc$ = "" Then tempo = Val(ParseParam(d$(g)))
Next g
ParseParam = Trim$(Str$(tempo))
Exit Function
End If
' Is Integer?
If IsInteger(para$) = 1 Then
ParseParam = Trim$(Str$(GetInteger(para$)))
Exit Function
End If
' Is Server Const?
If GetConst(para$) <> "" Then
ParseParam = GetConst(para$)
Exit Function
End If
' Is Normal Text?
dx = Len(para$)
iq = False: jk = 0
For t = 1 To dx
If Mid$(para$, t, 1) = "(" And iq = False Then jk = jk + 1
If Mid$(para$, t, 1) = ")" And iq = False Then jk = jk - 1
If Mid$(para$, t, 1) = "'" Then iq = Not iq
If Mid$(para$, t, 1) = "&" And iq = False And jk = 0 Then MULTI_PARAM = 1: GoTo MULTI
Next t
GoTo NOMULTI
MULTI:
'Debug.Print "this para$=" & para$ & "="
Erase d$()
wc = 0
iq = False: jk = 0
If MULTI_PARAM = 1 Then
'Debug.Print "MULTIPARAM"
' MultiParameter
r = Len(para$)
For g = 1 To r
k$ = Mid$(para$, g, 1)
If k$ = "'" Then iq = Not iq
If k$ = "(" And iq = False Then jk = jk + 1
If k$ = ")" And iq = False Then jk = jk - 1
If k$ = " " And iq = False And jk = 0 Then wc = wc + 1
d$(wc) = d$(wc) & k$
Next g
For g = 0 To wc
d$(g) = Trim$(d$(g))
'Debug.Print "tempo$=" & d$(g) & "="
tempoo$ = tempoo$ & ParseParam(d$(g))
Next g
ParseParam = tempoo$
Exit Function
End If
NOMULTI:
If Left$(para$, 1) = "'" Then
ParseParam = ReplaceStr(Mid$(para$, 2, Len(para$) - 2), "\n", vbCrLf)
Exit Function
End If
dd = Len(para$)
For cc = 1 To dd
f$ = Mid$(para$, cc, 1)
If f$ = "'" Then Exit Function
If f$ <> "(" Then GoTo BAILMEOUT
Next cc
Exit Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -