num = ubound(a_varname)
if ((num +1) mod 2) <> 0 then
call halt("setvars: for varname array's element not gemination.")
exit sub
else
for i = 0 to num step 2
call setappendvar(a_varname(i), a_varname(i+1))
next
end if
else
call setappendvar(a_varname, "")
end if
end sub
'####
'##
'## @same phplib::template->set_var
'##
public sub set_var(byval a_varname, byval a_value, byval a_append)
'############################################################
if cbool(a_append) = true then
if not isarray(a_varname) then
call setappendvar(a_varname, a_value)
else
call setappendvars(a_varname, a_value)
end if
else
if not isarray(a_varname) then
call setvar(a_varname, a_value)
else
call setvars(a_varname, a_value)
end if
end if
end sub
'####
'## this function fills in all the variables contained within the variable named
'## a_varname. the resulting value is returned as the function result and the
'## original value of the variable varname is not changed. the resulting string
'## is not "finished", that is, the unresolved variable name policy has not been
'## applied yet.
'##
'## returns: the value of the variable $varname with all variables substituted.
'##
'## usage: substring(string a_varname)
'##
'## @param a_varname the name of the variable within which variables are to be substituted
'## @access public
'## @return string
'##
public function substring(byval a_varname)
'############################################################
dim mm_string
if debug = 4 then response.write "<p><b>substring:</b> varname = " & a_varname & "</p>" & vbcrlf
if not loadfile(a_varname) then
call halt("substring: unable to load " & a_varname & ".")
end if
mm_string = getvar(a_varname)
m_oregexp.ignorecase = true
m_oregexp.global = true
m_oregexp.pattern = "(" & begintag & ")([^ \t\r\n" & endtag &"]+)" & endtag
set matches = m_oregexp.execute(mm_string)
for each match in matches
if m_ovarvals.exists(match.submatches(1)) then
m_oregexp.pattern = match.value
mm_string = m_oregexp.replace(mm_string, m_ovarvals.item(match.submatches(1)))
end if
next
substring = mm_string
end function
'####
'##
'## @same phplib::template->subst
'##
public function subst(byval a_varname)
subst = substring(a_varname)
end function
'####
'## this is shorthand for print substring(a_varname). see substring for further
'## details.
'##
'## usage: otemplate.writesubstring string a_varname
'##
'## @param a_varname the name of the variable within which variables are to be substituted
'## @access public
'## @see substring
'##
public sub writesubstring(byval a_varname)
'############################################################
if debug = 4 then response.write "<p><b>writesubstring:</b> varname = " & a_varname & "</p>" & vbcrlf
response.write substring(a_varname)
end sub
'####
'##
'## @same phplib::template->psubst
'##
public sub psubst(byval a_varname)
call writesubstring(a_varname)
end sub
'####
'## the function substitutes the values of all defined variables in the variable