RushiShroff
Programmer
Here is the code for generating a string for site SEArch.
Here this is to be included in an ASP page.
My problem is I can not access temp2 variable which is a string outside of search subroutine.
what to do ?
<%
'response.write Keywords
Dim strParse,criteria,searchstring,searchchar,findplus,findspace
Dim plusArray, blankArray, mCategory, mSubCategory, rstPrime_Category
searchchar="+"
searchstring=Keywords
searchstring=Replace(searchstring,"""","#"
If Left(searchstring,1)="#" and Right(searchstring,1)="#" then
searchstring=Replace(searchstring,"#",""
End If
findplus=instr(1,searchstring,searchchar)
if findplus >= 1 then
criteria="AND"
' get every element into array separated by "+"
plusArray=split(searchstring,searchchar)
redim preserve plusArray(Ubound(plusArray)+1)
for i=0 to Ubound(plusArray)-1
'check for " , ,
'1.check for """
searchchar=""""
searchstring=plusArray(i)
findquote=instr(1,searchstring,searchchar)
if findquote >=1 then
plusArray(i)=replace(plusArray(i),""""," "![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
'remove the spaces at both ends
plusArray(i)=rtrim(ltrim(plusArray(i)))
end if
'2.check for ","
searchchar=","
searchstring=plusArray(i)
findcomma=instr(1,searchstring,searchchar)
if findcomma>1 then
plusArray(i)=rtrim(ltrim(replace(plusArray(i),","," "
))
end if
next
'pass all the array values to procedure
call search(plusArray,criteria)
else
'check whether " " present
searchchar=""""
searchstring=Trim(Request.Form("T_searchfor"
)
searchstring=Replace(searchstring,"""","#"
If Left(searchstring,1)="#" and Right(searchstring,1)="#" then
searchstring=Replace(searchstring,"#",""
End If
findquotes=instr(1,searchstring,searchchar)
if findquotes>=1 then
'check whether , present
searchchar=","
findcomma=instr(1,searchstring,searchchar)
if findcomma>=1 then
criteria="OR"
else
criteria="AND"
end if
blankArray=Array(searchstring)
call search(blankArray,criteria)
else
criteria="OR"
'check for spaces
searchchar=" "
findspaces=instr(1,searchstring,searchchar)
if findspaces>=1 then
spacesArray=split(searchstring,searchchar)
'Trim individual array element
for i=0 to UBound(spacesArray)
spacesArray(i)=trim(spacesArray(i))
next
'if any array element is blank or has space removed it
for i=0 to UBound(spacesArray)
if spacesArray(i)=" " then
'track this element
flag=i
for k=flag+1 to UBound(spacesArray)
'backup_spacesArray(i)=spacesArray(i)
spacesArray(k-1)=spacesArray(k)
next
redim preserve spacesArray(Ubound(spacesArray))
else
redim preserve spacesArray(Ubound(spacesArray)+1)
end if
next
call search(spacesArray,criteria)
'pass the array to the search
'input parameters
else
'convert the string to array
blankArray=Array(searchstring)
call search(blankArray,criteria)
end if
end if
end if
response.write temp2'Can not access it here
%>
<%
Sub search(ByVal arr(),criteria)
Dim pad,arr_Size, loop_ctr
arr_Size = Ubound (arr)
for i=0 to arr_size
if arr(i) = "" then
loop_ctr = i
exit for
end if
Next
if Ubound (arr) = 0 then
temp2= "Keywords LIKE '%"
temp2=temp2&arr(0)
temp2=temp2&"%'"
else
For i = 0 to arr_size
If arr(i) = "" then
exit for
end if
temp2= temp2 & "Keywords LIKE '%" & arr(i) & "%'"
'response.write temp2&"<br>"
If i < (loop_ctr-1) then
temp2 = temp2 & " " & criteria & " "
end if
Next
End if
End Sub
%>
Rushi Shroff Rushi@emqube.com
"Life is beautiful."
Here this is to be included in an ASP page.
My problem is I can not access temp2 variable which is a string outside of search subroutine.
what to do ?
<%
'response.write Keywords
Dim strParse,criteria,searchstring,searchchar,findplus,findspace
Dim plusArray, blankArray, mCategory, mSubCategory, rstPrime_Category
searchchar="+"
searchstring=Keywords
searchstring=Replace(searchstring,"""","#"
If Left(searchstring,1)="#" and Right(searchstring,1)="#" then
searchstring=Replace(searchstring,"#",""
End If
findplus=instr(1,searchstring,searchchar)
if findplus >= 1 then
criteria="AND"
' get every element into array separated by "+"
plusArray=split(searchstring,searchchar)
redim preserve plusArray(Ubound(plusArray)+1)
for i=0 to Ubound(plusArray)-1
'check for " , ,
'1.check for """
searchchar=""""
searchstring=plusArray(i)
findquote=instr(1,searchstring,searchchar)
if findquote >=1 then
plusArray(i)=replace(plusArray(i),""""," "
'remove the spaces at both ends
plusArray(i)=rtrim(ltrim(plusArray(i)))
end if
'2.check for ","
searchchar=","
searchstring=plusArray(i)
findcomma=instr(1,searchstring,searchchar)
if findcomma>1 then
plusArray(i)=rtrim(ltrim(replace(plusArray(i),","," "
end if
next
'pass all the array values to procedure
call search(plusArray,criteria)
else
'check whether " " present
searchchar=""""
searchstring=Trim(Request.Form("T_searchfor"
searchstring=Replace(searchstring,"""","#"
If Left(searchstring,1)="#" and Right(searchstring,1)="#" then
searchstring=Replace(searchstring,"#",""
End If
findquotes=instr(1,searchstring,searchchar)
if findquotes>=1 then
'check whether , present
searchchar=","
findcomma=instr(1,searchstring,searchchar)
if findcomma>=1 then
criteria="OR"
else
criteria="AND"
end if
blankArray=Array(searchstring)
call search(blankArray,criteria)
else
criteria="OR"
'check for spaces
searchchar=" "
findspaces=instr(1,searchstring,searchchar)
if findspaces>=1 then
spacesArray=split(searchstring,searchchar)
'Trim individual array element
for i=0 to UBound(spacesArray)
spacesArray(i)=trim(spacesArray(i))
next
'if any array element is blank or has space removed it
for i=0 to UBound(spacesArray)
if spacesArray(i)=" " then
'track this element
flag=i
for k=flag+1 to UBound(spacesArray)
'backup_spacesArray(i)=spacesArray(i)
spacesArray(k-1)=spacesArray(k)
next
redim preserve spacesArray(Ubound(spacesArray))
else
redim preserve spacesArray(Ubound(spacesArray)+1)
end if
next
call search(spacesArray,criteria)
'pass the array to the search
'input parameters
else
'convert the string to array
blankArray=Array(searchstring)
call search(blankArray,criteria)
end if
end if
end if
response.write temp2'Can not access it here
%>
<%
Sub search(ByVal arr(),criteria)
Dim pad,arr_Size, loop_ctr
arr_Size = Ubound (arr)
for i=0 to arr_size
if arr(i) = "" then
loop_ctr = i
exit for
end if
Next
if Ubound (arr) = 0 then
temp2= "Keywords LIKE '%"
temp2=temp2&arr(0)
temp2=temp2&"%'"
else
For i = 0 to arr_size
If arr(i) = "" then
exit for
end if
temp2= temp2 & "Keywords LIKE '%" & arr(i) & "%'"
'response.write temp2&"<br>"
If i < (loop_ctr-1) then
temp2 = temp2 & " " & criteria & " "
end if
Next
End if
End Sub
%>
Rushi Shroff Rushi@emqube.com
"Life is beautiful."