OpenNTF.org - Like Perl Split
My Links (Not logged in)
Code Bin Search
 
Hosted by Prominic.NET
Rate This Code
5 - brilliant stuff
4 - very nice
3 - average
2 - needs work
1 - bad
   OpenNTF Code Bin
About This Code
Brief Description:
Like Perl Split 
Rating:
Rating: 1 , Number of votes: 1 
Contributor:
DAF 
Category:
Lotusscript 
Type:
String functions 
Notes Version:
R5.x 
Last Modified:
11 Oct 2002 
OpenNTF Disclaimer

All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.

Code / Description
Function BustEm (estring As String, delim As String) As Variant


' like perl split function, splits on the string supplied in delim returns a variant
' with each substring as an array member - WARNING a hard coded limit of 5 items is in this func.

Dim cnt, i, j, k, slen As Integer
Dim pEmails() As String
Dim one_ch As String
Dim pos(5) As Integer

cnt = 0
i = 0
j = 0
k = 0

slen = Len(estring)

For i=1 To slen
one_ch = Mid$(estring,i,1)
If one_ch = delim Then
pos(j) = i
j = j + 1
End If
Next

pos(j) = slen + 1

Redim pEmails(j)

j = 0
k = 1

Forall v In pos
If v <> 0 Then
pEmails(j) = Mid$(estring,k,(v-k))
k = v + 1
j = j + 1
End If
End Forall

BustEm = pEmails()

End Function

Usage / Example
Sub Click(Source As Button)

'-- set up a variable to hold current database
Dim uiws As NotesUIWorkspace
Set uiws = New NotesUIWorkspace

Dim uidoc As NotesUIDocument
Set uidoc = uiws.CurrentDocument

Dim emails As Variant
Dim rep_mail As String
Dim dlm As String

'-- Retrieve the values from the fields on the screen using the FieldGetText method

dlm = "+"
repid = uidoc.FieldGetText("Rep_ID")
rep_mail = uidoc.FieldGetText("Rep_mail")

------->emails = BustEm(rep_mail, dlm)

Forall v In emails
Messagebox "email: " & v, MB_ICONINFORMATION, "split emails"
End Forall

End Sub
 Comments

No documents found

 Add your comment!