Solved

Referring to Items in a list

Posted on 1999-01-15
8
222 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: 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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

730 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