How to use @Left and @right in a name field using Lotus Script

Hi All,

I have a field on a form called Submitted By and that field people type in First Name + Space + Middle Initial(if it has) + space + LastName

I need to extract FirstNAme , MiddleItintial and Lastname using Lotus Script in separate variables.

How can I achieve this using Script

Thanks in advance,

ac ac

Subject: How to use @Left and @right in a name field using Lotus Script

Hi, go to Notes designer help and look for @right and @ left and have a look at Language cross reference section.

Cheers !!

Subject: RE: How to use @Left and @right in a name field using Lotus Script

I tried using the evaluate in Lotus Script but still it doesn’t work …It givee me an error "Error in Evaluate?

Here is the code

Dim str1, str2 As String

Dim Fname, lname, mname as variant

	str1 = doc.SubmittedBy(0)

	Fname =  Evaluate({@Left(SubmittedBy; "")}, doc)

	Lname =  Evaluate({@Right(SubmittedBy; "")}, doc)

	str2 = Lname(0) + " , " + Fname(0)

Please help

Thanks in advance,

ac ac

Subject: RE: How to use @Left and @right in a name field using Lotus Script

hi, try this…do the changes in the code per your requirement.

Dim str1, str2 As String

Dim Fname, lname As String



str1 = "Huzefa Haider"

Fname = Strleft( str1, " ")

Msgbox Fname 

Lname = Strright( str1, " ")

Msgbox Lname

str2 = Lname + " , " + Fname

Msgbox Str2

Cheers!!

Subject: RE: How to use @Left and @right in a name field using Lotus Script

This

Dim str1, str2 As String

Dim Fname, lname As String

will define str1 and Fname as Variant, which will work, of course, but is not intended. For proper typing you have to write:

Dim str1 As String, str2 As String

Dim Fname As String, Lname As String

Subject: RE: How to use @Left and @right in a name field using Lotus Script

hi,tweak your existing code a bit … here’s the eg.

Dim str1 As String , str2 As String

Dim Fname As String , lname As String, mname As String



str1 = "Huzefa A Haider"

Fname = Strleft( str1, " ")

Msgbox Fname 

mname=Strright(Strleft( str1, " ",0,2)," ")

Msgbox mname

Lname = Strright( str1, " ",0,2)

Msgbox Lname

str2 = Lname + " , " + Fname

Msgbox Str2

Cheer!!

Subject: RE: How to use @Left and @right in a name field using Lotus Script

Thanks Huzefa , it worked !!!

Also what if the user has middle initial, like “XYZ M. ABC”

Thanks,

ac ac