Solved

Referring to Items in a list

Posted on 1999-01-15
8
219 Views
Last Modified: 2013-12-18
In LotusScript, I have a list variable set up.  I can use a forall loop to return each of the "keys" of the list, but code like this does not seem to work:

Forall element in MyList
    msgbox element & " = " & MyList(element)
End Forall

What am I doing wrong here?
0
Comment
Question by:IsleOfView
8 Comments
 
LVL 12

Expert Comment

by:fulscher
ID: 1117904
Lists appear to contain variants. I never really succedeed to get them to work properly, so I used an array of variable size. You might want to try something like

Forall element in MyList
    msgbox element & " = " & MyList(element)(0)
End Forall

Do you get an error message? Or just an empty response?
0
 
LVL 2

Expert Comment

by:phooey
ID: 1117905
The code you need to use is:

Kount = 0
Forall element in MyList
    msgbox Kount & " = " & MyList(Kount)
    Kount = Kount + 1
End Forall

The reason for this is that the Forall Loop simply does 'something' in the loop for the number of times that there is an element in the list.  Unless you give a delimeter of some kind to say where you are up to in the list )(in this case Kount) you have no way of controlling the list.
0
 

Author Comment

by:IsleOfView
ID: 1117906
Phooey:  That doesn't work.  That code gives this error: "List Item Does Not Exist".  I assume this is because you cannot refer to elements of a list variable by their subscript, as in an array.

The code that I used originally would work if I didn't try to include the value (MyList(element)).

fulscher:  This list variable was declared as a string (Dim MyList List as String).  It is the return value of a function, so the function returns a variant that contains this list variable (you can't make a list variable a return value unless it is in a variant container)

I know that the elements of this list variable are available when they are returned, as I can explicitly return each one (i.e., MyList("FirstName") = Joe).  The problem is that this needs to be generic, where the script doesn't know what kind of input it is going to be receiving.
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

Expert Comment

by:MrGrinch
ID: 1117907
It all depends on what type of object you are returning.
For Example, if you are doing a Forall Loop on a NotesDocumentCollection, you would be returning individual NotesDocuments.  Your MsgBox wants a string, so you could never show a NotesDocument in a MsgBox.  You could, however pull an element from that NotesDocument such as:
Forall x in NotesDocumentCollection
   MsgBox "Form Name: " + x.Form(0)
End Forall
0
 

Author Comment

by:IsleOfView
ID: 1117908
This is a list variable, declared as a string, that is returned in a variant container.  (please take a look at my comments below)
0
 
LVL 2

Accepted Solution

by:
phooey earned 50 total points
ID: 1117909
I *think* see the problem now, it is because you are using a defined list.
Try

Forall element in MyList
    currentTag = ListTag(MyList)
    msgbox element & " = " & MyList(CurrentTag)
End Forall

Note: you might need a (0) at the end of the MsgBox line
0
 
LVL 2

Expert Comment

by:phooey
ID: 1117910
OOOPS Screwed that u !!!
Should read

Forall element in MyList
    currentTag = ListTag(element)
    msgbox element & " = " & MyList(currentTag)
End Forall

0
 

Author Comment

by:IsleOfView
ID: 1117911
Thanks!  The syntax was just a bit off, but it got me on the right track.  Here's what ended up really working:

Forall element In MyList
    currentTag = Listtag(element)
    Msgbox currentTag & " = " & MyList(currentTag)
End Forall
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Lotus Notes, Agent - installation / distrubtion of a agent into mail db 7 231
VBA Lotus notes 2 196
Add a cc field to email code 6 99
Lotus Notes transfer mail box problem 6 101
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question