Home | Advertising Info83 USERS CURRENTLY ONLINE   
PowerASP

try aspprotect !!
the premier asp based user management system !!

   Site Search Contact Us Thursday, May 17, 2012  
 
 







DISCUSSION ARCHIVES
DISCUSSION ARCHIVES 2
DISCUSSION ARCHIVES 3
BLOG

 
Try a free httpZip trial now and compress for less!


We didn't realize
the site was so popular.

Other Stuff
 
 


TLsplit Function




This function was designed by my Co-worker Tim Lasek after I asked him to make it because of things that I didn't like about the built in vbscript function called "split". I primarily use it to take arrays passed from the HTTP HEADER and put them back together, but Tim decided to enhance it by letting you specify the delimiter and by having the array dynamically declare itself so that it is always the exact size it needs to be. This makes this function very versatile. This also handle null values better than split does and overall I like it better..

Function
TLsplit(StrToSplit, Delim)

Usage:  TestArray = TLsplit("This,is,a,dynamic,split,function", ",")

Result:
TestArray(0) = 6
TestArray(1) = This
TestArray(2) = is
TestArray(3) = a
TestArray(4) = dynamic
TestArray(5) = split
TestArray(6) = function

No need to Dim() the array before calling the function.
Array(0) = Number of elements in the array.
If StrToSplit = NULL Then Array(0) = 0.
Checks for Delim not found.
Don't use " for Delim.

Below is the Function Source Code and Example Usage Code

<%
Function TLsplit(StrToSplit,Delim)
Dim StrArray()
If StrToSplit = "" Then
  ReDim StrArray(1)
  StrArray(0) = 0
  StrArray(1) = ""
  TLsplit = StrArray
Else
  dcount = 0
  For TLsI = 1 To Len(StrToSplit)
   If Mid(StrToSplit,TLsI,1) = Delim Then dCount = dCount + 1
  Next
  If dCount = 0 Then
   ReDim StrArray(1)
   StrArray(0) = 1
   StrArray(1) = StrToSplit
   TLsplit = StrArray
  Else
   ReDim StrArray(dCount + 1)
   StrArray(0) = dCount + 1
   TempArray = Split(StrToSplit,Delim)
   For TLsI = 1 To dCount + 1
    StrArray(TLsI) = Trim(TempArray(TLsI - 1))
TLsplit = StrArray
   Next
  End If
End If
End Function
%>

<% RandomVariable = "This,is,a,dynamic,split,function" %>

<%
TestArray = TLsplit(RandomVariable, ",")
For I = 1 To TestArray(0)
Response.Write("TestArray(" & I & ") = " & TestArray(I) & "<br>")
Next
%>

 

   Active Server Pages Rule The World
Contact Us  
All artwork, design & content contained in this site are Copyright © 1998 - 2012 PowerASP.com and Christopher J. Williams
Banner ads ,other site logos, etc are copyright of their respective companies.
STATS Unless otherwise noted - All Rights Reserved.

Active Server Pages ASP a directory of ASP tutorials applications scripts components and articles for the novice to professional developer. CJWSoft ASPProtect ASPBanner ASPClassifieds www.aspclassifieds.com, www.powerasp.com,www.cjwsoft.com,www.aspphotogallery.com,www.codewanker.com,www.aspprotect.com,www.aspbanner.com