@Select May not do what you think it will - Use @Subset

Domino Resources - Part 2

Looking for something else?

+ Show More

I had two related list fields in my document,

Item and Weight. My users wanted the total weight field to exclude the wight of Carbon Dioxide (Item Code "CO2"). This seemed simple. Find out the Item element number = "CO2", and subtract the value of the same element in the weight list from the original summed field..... But all was not what it seemed.

CODE:
Here was my initial code to get field TotalWeight:

Item Weight

Item01 10.00
CO2 20.00
Item02 30.00
Item03 40.00

Elem=@Member("CO2";Item);

Elem now contains the position in the array of the text "CO2", 2.

CO2Weight=@Select(Elem;Weight);

CO2Weight should now contain 20.00.

@Sum(Weight)-CO2Weight

The total weight without CO2's weight.

But, Aargghh, CO2Weight returned the entire list of numbers... 10.00 ; 20.00 ; 30.00
; 40.00

Anyway, after a lot of faffing about, doubting my work, checking the manuals,
banging my head against the desk etc I finally searched the lotus knowledge base
and found this at

http://www.support.lotus.com/sims2.nsf/802ee480bdd32d0b852566fa005acf8d/489569fb8e698275862565460072209a?OpenDocument&Highlight=2,%40Select

"The @Select function in Notes 4.x does not provide the ability to return the Nth
item of an arbitrary list. It will work only if you specify your semicolon-separated
list explicitly when you write the formula. How can a given element of a list be
returned using formulas?

Solution:

Nested @Subset calls can achieve this, as follows:

@Subset(@Subset(list;N);-1)

Where N is a number representing which element you would like to select, with the
first element being number 1.

The inner @Subset call selects all elements of a list up to and including the number
you specify (1 through N). The outer @Subset selects just the last element of the
previous list (element N only).

In a similar way, you can access the Nth-to-last element of the list via:

@Subset(@Subset(list;-N);1)

In this case, the inner @Subset returns a list counting backwards from the end of the
list, consisting of N items, and the outer @Subset call returns the first of these (the
last element if N is 1, the second-to-last element if N is 2, etc."

WELL THANKS FOR TELLING US!!!

This was last published in November 2000

Start the conversation

Send me notifications when other members comment.

SearchWindowsServer

• Pester PowerShell unit testing ensures quality code

PowerShell jockeys can turn to the Pester unit testing framework to ensure the code they write is up to snuff.

• Microsoft software-defined networking gets baked into Windows Server

The Microsoft SDN technology that comes in the Windows Server 2016's Datacenter edition features a range of basic to nuanced ...

• Microsoft rings in new year with light January Patch Tuesday

Microsoft starts 2017 with just three bulletins, but administrators who manage Windows Server 2008 and 2008 R2 should pay close ...

Search400

• iSeries tutorials

Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

• V6R1 upgrade planning checklist

When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

• Connecting multiple iSeries systems through DDM

Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

• SUSE Linux jumps on the open private cloud deployment train

SUSE Linux Enterprise planning private cloud deployment with OpenStack weight behind it. NVIDIA works on Linux drivers for ...

• Want one of the many Linux jobs out there? Time to go back to class

Does extended education from the Linux Foundation and others help graduates meet the demands of today’s Linux jobs? Some say yes.

• Ubuntu ARM server AMI for Amazon EC2 offers fast access in the cloud

Canonical’s Ubuntu ARM server AMI for Amazon EC2 provide open source shops with a fast ARM server for the cloud.

SearchDataCenter

• HPE-SimpliVity deal raises support, price and development questions

With HPE's buy of No. 2 SimpliVity -- the first big deal in the HCI space -- IT pros see a more robust offering, but also higher ...

• Converged infrastructure drop-off doesn't mean data center death

Traditional converged infrastructure has been supplanted by hyper-converged infrastructure and cloud computing, but it remains a ...

• New options to evolve your data backup and recovery plan

The server backup market first evolved to protect VMs, but now it's undergoing another transformation. Find out how it's evolved ...

SearchExchange

• Five reasons for an Office 365 hybrid deployment

Not all organizations can go all-in on cloud. There are five reasons why a hybrid Office 365 arrangement makes sense for those ...

• Low-cost Exchange administration tools that won't break your budget

Admins must keep a close eye on Exchange Server to ensure it runs at peak performance. If cost is an issue, there are a number of...

• Avoid disaster with these Exchange 2013 backup options

Exchange Server administrators have a number of ways to keep disaster from sinking a key part of the corporate infrastructure.

SearchContentManagement

• Why SharePoint Framework could benefit business, not just developers

SharePoint Framework heralds a new, mobile-friendly, low-code era for Microsoft, which may give some organizations without .NET ...

• Using Microsoft MyAnalytics to improve workers' time management

Microsoft MyAnalytics has been hailed as the next great thing for analyzing worker productivity. But how can employees be assured...

• Is the Drupal content management system right for your business?

The open source Drupal content management system offers users responsive design and WYSIWYG content and web development tools, as...

Close