Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Referring to Items in a list

Posted on 1999-01-15
8
Medium Priority
?
237 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 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

  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…
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

636 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