LotusScript Trivia!

In a profile document, I have a field (type:names) containing a role : [Admin]. This field might contains more than one role, but not for this example.

I have this basic script :

Dim ss As New NotesSession

Dim db As NotesDatabase

Set db = ss.CurrentDatabase

Dim pdoc As NotesDocument

Set pdoc = db.GetProfileDocument(“ProfilBase”)

Dim RolesCollection As Variant

RolesCollection = pdoc.GetItemValue(“prPermissionToDelete”)

Dim strPart1 As String, strPart2 As String, fullString As String

Forall R In RolesCollection

strPart1 = {@IsMember("} 

strPart2 = {"; @UserRoles)}

fullString = strPart1 + R + strPart2

End Forall

Q: Can anyone tell me what ‘fullString’ will look like after the first pass of the Forall?

Subject: LotusScript Trivia!

@IsMember(“[Admin]”; @UserRoles)

Subject: RE: LotusScript Trivia!

I wish! That is exaclty what I try to get with that script… but it is not.

This script returns me :

@IsMember(“”[Admin]“”; @UserRoles)

(note the double quote)

Subject: RE: LotusScript Trivia!

Then the quotes must be in R

Subject: RE: LotusScript Trivia!

No. If I do a len(R), and R contains [Admin], it is returning 7. If the R were containing the quotes, I would have 9.

If I remove the quote from strPart1 and strPart2, like this:

strPart1 = {@IsMember(}

strPart2 = {; @UserRoles)}

fullString = strPart1 + R + strPart2

what I get?

@IsMember([Admin];@UserRoles)

I cannot have a string with

@IsMember(“[Admin]”; @UserRoles)

Subject: RE: LotusScript Trivia!

Strange. On the other hand, when I debug lotusscript code, I often see the double quotes. They don’t seem to matter.

Subject: RE: LotusScript Trivia!

Sebastien,

The code works fine for me and returns

@IsMember(“[Admin]”;@UserRoles)

If you write R to a string variable before the message box and debug, what is the value

Mike

Subject: LotusScript Trivia!

Subject: RE: LotusScript Trivia!

I was doing a MsgBox rather than debugging and it worked fine for me based on the message I was seeing

Thanks for that info Willy. I learn something new everyday. Much appreciated

Subject: LotusScript Trivia!

You guys are totally right!.I learn new stuff everyday!

Many thanks.

Subject: LotusScript Trivia!

And by the way: What are your further plans with this string, once you have build it?

I’ve got a vague idea, but would like to remind you of

roles = notesDatabase.QueryAccessRoles(name$)

number = ArrayGetIndex(roles, “[Admin]”)

just in case. Formula execution using Evaluate is just as fast as everywhere else, but switching between engines imposes some delay.