[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Referring to Items in a list

Posted on 1999-01-15
8
Medium Priority
?
242 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 150 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
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.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

834 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