Solved

Referring to Items in a list

Posted on 1999-01-15
8
217 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Expert Comment

by:MrGrinch
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:IsleOfView
Comment Utility
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
Comment Utility
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
Comment Utility
OOOPS Screwed that u !!!
Should read

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

0
 

Author Comment

by:IsleOfView
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

728 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now