Help with sting handling in Lotus Script

Hi there,

I’m new to script, like this is my first attempt!. What I want to do is to read in a subject line from a mail (no problem so far this works)

subj = doc.getitemvalue ( “Subject” )

Messagebox ( subj ( 0 ) )

then I need to split subj into three components. Layout of subject is “Survey for steve.gardner@domain.com (00011117) Ref: This is a short description”

Doing this in formula I would :

tmpName := @Middle(subject; “for “;” (”);

tmpNo := @Middle(subject; “(” ; “)” );

tmpRef := @Right(subject; “:” )

I then want to populate fields with these values I guess by using

Call doc.ReplaceItemValue(“Name”, tmpName)

Its that chopping of the subject line that I can’t get my head around at the moment!

Any help welcomed …

Subject: Help with sting handling in Lotus Script

You would want to use the left, mid, or right LS functions.

Check the designer help db.

mid statement example

Dim string1 As String, string2 As String

string1$ = “ABCDEF”

string2$ = “12345”

’ Replace the characters “BCD” in string1

’ with the characters “123” in string2.

Mid$(string1$, 2, 3) = string2$

Print string1$ ’ Output: A123EF

The replaceitemvalue method looks right to me.

Hope that helps.

Subject: RE: Help with sting handling in Lotus Script

Thanks.Needs to be slightly more complex as the length of name varies but on the right track

tmpName := @Middle(subject; “for “;” (”);

tmpNo := @Middle(subject; “(” ; “)” );

tmpRef := @Right(subject; “:” )

x = position of “(”

y = position of “)”

r = position of “:”

l = Len ( Subject )

tmpname = Mid$ ( subject, 13, x -13)

tmpNo = Mid$ ( subject, x, 9)

tmpRef = Right$ ( Subject, l - r)

That should do it ?

Now all I have to do is code using InStr ?

or am I over complicationg this

Subject: Easiest way is to use Evaluate…

tmpName = Evaluate(|@Middle(subject; “for “;” (”)|, doc)tmpNo = Evaluate(|@Middle(subject; “(” ; “)” )|, doc)

tmpRef = Evaluate(|@Right(subject; “:” )|, doc)

Subject: Help with sting handling in Lotus Script

Steve,

Considering you want to split the string I would suggest you look

at the spilt function. It does everything you want and is easy

to use. Check out the designer help for documentation.

By the way I would not use the Evaluate method when there

are many native LotusScript functions that will do the job

for you.

Example:

'*************************************

Dim strSubject As String

Dim varSubject As Variant

Dim strName As String

Dim strNo As String

Dim strRef As String

strSubject = Cstr(doc.GetFirstItem(“Subject”).Values(0))

varSubject = Split(strSubject, " ", 4, 5)

strName = varSubject(2)

strNo = varSubject(3)

strRef = varSubject(4)

'**************************************

Regards,

Anthony Lee

Subject: Help with sting handling in Lotus Script

look at left, mid, and right in the help file. Lots of examples there