Home > Domino Tips > Developer > Formula > @Member in reverse
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

FORMULA

@Member in reverse


Joachim Rapp
10.02.2003
Rating: -4.21- (out of 5) Hall of fame tip of the month winner


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


View member feedback to this tip.

@Member finds a value's first position in a text list. This formula finds all positions of a string. It works for lists with up to 99 elements.

Code

_listToSearch := "a":"b":"c":"b":
"b":"a":"c":"b"; 
_searchString := "c"; 
@if(@Elements(_listToSearch)=0;
@return(0);""); 
_digits:="0":"1":"2":"3":"4":"5":"
6":"7":"8":"9"; 
_0_to_99 := _digits *+ _digits; 
_1_to_99 := @Subset(_0_to_99; -99); 
_1_to_numOfElements:=@Subset
(_1_to_99; @Elements(_listToSearch)); 
_list1:= _listToSearch + _1_to_numOfElements; 
_list2 := _searchString + _1_to_numOfElements; 
_list3 := @Replace(_list1;_list2;""); 
_list4 := @Replace(_list1;@Trim(_list3);""); 
_positionsString:=@Replace(@Trim
(_list4);_list2; _1_to_numOfElements); 
_position :=@If(_positionsString="" ; 
       0; 
        @TextToNumber(_positionsString) 
); 
_position

MEMBER FEEDBACK TO THIS TIP

Another way, rather than trying to keep track of all those @Replace calls, is to use @Right:

_listToSearch := "a":"b":"c":"b":"b":"a":"c":"b";
_searchString := "c";
_digits:="0":"1":"2":"3":"4":"5":"6":"7":"8":"9";
_0_to_99 := _digits *+ _digits;
_1_to_99 := @Subset(_0_to_99; -99);
_1_to_numOfElements:=@Subset
(_1_to_99; @Elements(_listToSearch));
_list1:= _listToSearch + _1_to_numOfElements;

REM "<-- New code starts here -->";
_locs := @Trim(@Right(_list1; _searchString));
_position := @If(@Elements(_locs) = 0; 
@Replace(_locs; ""; "Not found");
@Subset(_locs; -1));
_position
-- SearchDomino.com member

**************************************************

I wished I'd had this formula about six months ago! (And why couldn't I come up with it myself!?!) This one is definitely a keeper! Thanks!

-- Jo R.

**************************************************

Using @Right instead of @Replace is not a correct substitution for this task:

If you start with the list
    _listToSearch := "a":"b":"xc":"b":"b":"a":"xc":"b";
you will get the same result as using
    _listToSearch := "a":"b":"c":"b":"b":"a":"c":"b"
-- Lothar F.

**************************************************

If you need to work on lists with more than 99 elements, just replace the list that is hold in var "_1_to_99" ("1":"2":.......:"99") with a list that is long enough for your needs; for example, "_1_to_999" ("1":"2":.......:"999")

This is all you need to change!

-- Joachim Rapp

Do you have comments of your own? Let us know.

This tip was submitted to the SearchDomino.com tip library by member Joachim Rapp. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
Formula
Formula language button manages Deny Access list searches
Retrieve Lotus Notes names from a nested group using @DBLookup
Create a computed Lotus Notes field to list Personal Address Book names
Show multiple Lotus Notes document fields in a single view column
How to send a document as a link in a Lotus Notes email
How to generate formatted sequence numbers with Formula language
A simpler pagination view for Lotus Notes documents on the Web
A bevy of Notes/Domino development tips
Easily implement attachment fields in a Web form using Formula
Programmatically create a shortcut for Lotus Notes

Lotus Notes Domino Formula Language
Stop response documents from showing in a Lotus Notes form
Formula language button manages Deny Access list searches
Add a program doc to compact Lotus Notes databases automatically
Top 10 Lotus Notes Domino programming and development tips of 2007
Retrieve Lotus Notes names from a nested group using @DBLookup
Top 5 @DBLookup tips
Create a computed Lotus Notes field to list Personal Address Book names
Show multiple Lotus Notes document fields in a single view column
Lotus Formula language coding primer
How to send a document as a link in a Lotus Notes email

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.

HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 1999 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts