Jump to content
Server Maintenance This Week. ×

List manipulation


This topic is 2116 days old. Please don't post here. Open a new topic instead.

Recommended Posts

There's a bit of a thread on the FM Community site about working with lists, to which I wrote an example SM function which I post here for interest....

https://community.filemaker.com/thread/188322

 

// liststest ( list1 ; list2 ; select? ; separator? )
// 18_07_10 JR
// v1.1
// 
//

JOIN = select?select.toInteger():1
LISTA = list1?list1.tokenize('\n'):[]
LISTB = list2?list2.tokenize('\n'):[]

SEP = separator?separator:' - '

switch(JOIN){

case 1: 
	LISTA.addAll(LISTB)
	return LISTA
break
case 2: 
	LISTA.removeAll(LISTB)
	return LISTA
break
case 3: 
	LISTB.removeAll(LISTA)
	return LISTB
break
case 4: 
	LISTA.addAll(LISTB)
	return LISTA.unique()
break
case 5: 
	result = ''
	LISTA.each(){
		def start = it
		LISTB.each(){
			result += start + SEP + it + '\n'
		}
	}
	return result
break
case 6: 
	if(LISTA.size() != LISTB.size()){
		return 'lists not same size'
	} else {
		result = ''
		i = 0
		LISTA.each(){
			result += it + SEP + LISTB.getAt(i) + '\n'
			i++
		}
	}
	return result
break
}

return 'select out of range'

 

Link to comment
Share on other sites

This topic is 2116 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.