最小修改实现5UCMS IF语句的嵌套
2011-12-14 07:28
260 查看
将 inc\class_template.asp 458行的 Parser_IF 函数整体注释掉,改成下面两个函数
前台模板用法
{if: XXXX}
{-if: XXXX}
{-else}
.....
{-End if}
{else}
.....
{end if}
即在嵌套的IF语句前加“-”,同理两级嵌套加两个,以此类推,层次足够用
Public Function Parser_IF() Dim PreLB PreLB = "" Parser_IF2(PreLB) End Function ' 判断标签 Public Function Parser_IF2(ByVal PreLB) On Error Resume Next Dim Matches, Match,TestIF,TestVal,TestTrue,TestFalse Dim NewPreLB Reg.Pattern = "{" & PreLB & "If:(.+?)}([\s\S]*?){" & PreLB & "End If}" Set Matches = Reg.Execute(Content) For Each Match In Matches TestVal=Match.SubMatches(1) If Instr(LCase(TestVal), "{" & PreLB & "else}")>0 Then TestVal=Replace(TestVal, "{" & PreLB & "else}", "{" & PreLB & "else}",1,-1,1):TestTrue=Split(TestVal, "{" & PreLB & "else}")(0):TestFalse=Split(TestVal, "{" & PreLB & "else}")(1) Else TestTrue=TestVal:TestFalse="" End If Execute ("If " & replace(Match.SubMatches(0),"'","""") & " Then TestIf = True Else TestIf = False") If TestIF Then Content = Replace(Content, Match.Value, TestTrue) Else Content = Replace(Content, Match.Value, TestFalse) If Err Then Response.Write "<font color=red>" & Lang_Parser_IF_Error & "[" & Match.SubMatches(0) & "]" & Err.Description & "</font>": Err.Clear: Response.End Next NewPreLB = PreLB & "-" If RegExists("{" & NewPreLB & "If:(.+?)}([\s\S]*?){ & NewPreLB & "End If}", Content) Then Call Parser_IF2(NewPreLB) ' 多次调用 End Function
前台模板用法
{if: XXXX}
{-if: XXXX}
{-else}
.....
{-End if}
{else}
.....
{end if}
即在嵌套的IF语句前加“-”,同理两级嵌套加两个,以此类推,层次足够用
相关文章推荐
- 实现5UCMS IF语句的嵌套 最小修改方法
- Mybatis 实现不确定修改几个字段的修改方法(动态语句set、if实现),避免修改时其它没被修改的字段变为null
- 用多级嵌套if-else语句实现分制转换
- ThinkPHP实现对数据库中表的修改删除以及两种原生SQL语句的执行
- C++ if语句的嵌套
- 关于excel 中IF 语句的多重嵌套
- shell条件嵌套(if条件语句)
- 现在有100块钱,一只公鸡5块,一只母鸡3块,三个小鸡1块。现在让你用100块钱买到100只鸡(大小不限)运用循环,和if语句实现
- Java基础---Java条件语句之嵌套if(二十)
- 黑马程序员----Java中的if嵌套语句
- C#_基础特性_if语句嵌套释疑
- sql语句实现对表中字段的修改和增加
- shellScript之嵌套if_else语句
- lesson 23 if语句实现分支结构
- 4.11 复杂嵌套的if语句
- 【LabVIEW小技巧】LabVIEW嵌套的if…else…这样实现
- 第一周《C语言及程序设计》实践项目24 if语句的嵌套
- 11_嵌套if语句
- 编程:多分段函数求值---用if~else语句的嵌套
- Lua中if语句嵌套的使用教程