# Stacked Find

**URL:** <https://the.fmsoup.org/t/stacked-find/3688>\
**Category:** Floating Topics\
**Created:** [September 9, 2023, 4:53pm UTC](https://the.fmsoup.org/t/stacked-find/3688 "2023-09-09T16:53:49Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonywhitelive](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/tonywhitelive/32/208_2.png) [@tonywhitelive](https://the.fmsoup.org/u/tonywhitelive)\
**Post date:** [September 9, 2023, 4:53pm UTC](https://the.fmsoup.org/t/stacked-find/3688/1 "2023-09-09T16:53:49Z")

</div>

Here is one implementation of a "Stacked Find". Feedback and/or alternate views welcome.

```auto
# Stacked Find DRAFT
Set Variable [$list ; Value: "A¶B"] 
// Set Variable [$list ; Value: "A¶B¶"] 
// Set Variable [$list ; Value: "¶A¶B"] 
// Set Variable [$list ; Value: "A¶¶¶B"] 
// Set Variable [$list ; Value: "¶¶¶"] 
# 
# Validate that the list is NOT empty.
Set Variable [$list.as_string ; Value: Substitute ( $list ; ¶ ; "" )] 
If [IsEmpty ( $list.as_string )] 
	Show Custom Dialog ["List is empty"] 
	# 1 = OK
	Halt Script
End If
# 
# Stacked Find
Set Variable [$count ; Value: ValueCount ( $list )] 
Set Variable [$i ; Value: 1] 
Set Variable [$enterFindMode ; Value: 1] 

```

```auto
Loop
	Exit Loop If [$i > $count] 
	Set Variable [$value ; Value: GetValue ( $list ; $i )] 
	If [Length ( $value )] 
		If [$enterFindMode] 
			Enter Find Mode [Pause: Off] 
			Set Variable [$enterFindMode ; Value: 0] 
		Else
			New Record/Request
		End If
		Set Field [ListTag::Tag ; "==" & $value] 
	End If
	# 
	Set Variable [$i ; Value: $i + 1] 
End Loop
# 
Set Error Capture [On]
Perform Find [] 
Set Error Capture [Off]
# 

```

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/fmsoup/original/2X/7/73b3aa7f8eb94a4b89311bf5b9431893d946ec56.png)

---

<div class="post-metadata">

**Author:** ![jwilling](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/jwilling/32/256_2.png) [@jwilling](https://the.fmsoup.org/u/jwilling)\
**Post date:** [September 9, 2023, 7:35pm UTC](https://the.fmsoup.org/t/stacked-find/3688/2 "2023-09-09T19:35:09Z")

</div>

I might be tempted to shrink it down to this since empty find request seem to be no-ops anyway:

```auto
# Stacked Find
Set Variable [$count ; Value: ValueCount ( $list )] 
Set Variable [$i ; Value: 0] 

Enter Find Mode [Pause: Off] 
Loop
	Exit Loop If [Let ( $i = $i + 1 ; $i > $count )] 
	New Record/Request
	Set Field [ListTag::Tag ; "==" & GetValue ( $list ; $i )] 
End Loop

Perform Find []

```

_EDIT: I noticed one potential problem with my implementation. Since you're doing a == find and you want to ignore empty list values, you would need to check if $value is empty before populating the query field._

---

<div class="post-metadata">

**Author:** ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)\
**Post date:** [September 9, 2023, 8:57pm UTC](https://the.fmsoup.org/t/stacked-find/3688/3 "2023-09-09T20:57:33Z")

</div>

I agree with Josh. Putting a little extra into the Exit Loop If statement makes the entire loop simpler. I'd rearrange the steps to avoid having an unused request.

```auto
# Stacked Find
Set Variable [$count ; Value: ValueCount ( $list )] 
Set Variable [$i ; Value: 1] 

Enter Find Mode [Pause: Off] 
Loop
	Set Field [ListTag::Tag ; "==" & GetValue ( $list ; $i )] 
	Exit Loop If [Let ( $i = $i + 1 ; $i > $count )] 
	New Record/Request
End Loop

Perform Find []

```

---

<div class="post-metadata">

**Author:** ![steve\_ssh](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/steve_ssh/32/160_2.png) [@steve\_ssh](https://the.fmsoup.org/u/steve_ssh)\
**Post date:** [September 10, 2023, 4:09am UTC](https://the.fmsoup.org/t/stacked-find/3688/4 "2023-09-10T04:09:06Z")

</div>

The simpler it gets, the more I appreciate it. One thing I am on the fence about, however, is that there's no escaping of reserved/special find chars done by this scripting. That's certainly not wrong, and, in fact, allows for more versatility, as it allows the consuming code to make use of FMP's special find chars. That said, part of me thinks I'd personally find it the most useful if it did do escaping, and I knew that I could hand it an arbitrary newline-delimited list of values and it would match any of them.

---

<div class="post-metadata">

**Author:** ![tonywhitelive](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/tonywhitelive/32/208_2.png) [@tonywhitelive](https://the.fmsoup.org/u/tonywhitelive)\
**Post date:** [September 10, 2023, 1:25pm UTC](https://the.fmsoup.org/t/stacked-find/3688/5 "2023-09-10T13:25:27Z")

</div>

> [@jwilling](#):
>
> empty find request seem to be no-ops

no-ops? Interesting. Thanks.

---

<div class="post-metadata">

**Author:** ![tonywhitelive](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/tonywhitelive/32/208_2.png) [@tonywhitelive](https://the.fmsoup.org/u/tonywhitelive)\
**Post date:** [September 10, 2023, 2:19pm UTC](https://the.fmsoup.org/t/stacked-find/3688/6 "2023-09-10T14:19:37Z")

</div>

Good point re escaping. This is a start...

# @escapeTextForFind\_v2 updated to v3

> **[Brian Dunning's FileMaker Custom Functions](https://www.briandunning.com/filemaker-custom-functions/account.php)**

This is what should show on the Web site:

```auto
// @escapeTextForFind_v3
// param: text
// Char 92 AKA \ is used to escape chars including itself
Substitute ( text ;
[Char ( 92 ); Char ( 92 ) & Char ( 92 )] ;
["!" ; "\!"] ;
["\"" ; Char ( 92 ) & "\""] ;
["#" ; "\#"] ;
["*" ; "\*"] ;
["<" ; "\<"] ;
["=" ; "\="] ;
[">" ; "\>"] ;
["?" ; "\?"] ;
["@" ; "\@"] ;
["~" ; "\~"] ;
["¶" ; "\¶"] ;
["…" ; "\…"] ;
["≤" ; "\≤"] ;
["≥" ; "\≥"]
)

```

Seems to work

1/2 // testing script

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/fmsoup/original/2X/3/37eb3cafdbb8479c622db6b3b75f14b75cf6e5b5.png)

2/2 // Modify Last Find  
 ![image](https://canada1.discourse-cdn.com/flex030/uploads/fmsoup/original/2X/e/e9ef826c1b4a3a43843c48cdad61bfe94c75ceaa.png)

---

<div class="post-metadata">

**Author:** ![FabriceN](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/fabricen/32/2506_2.png) [@FabriceN](https://the.fmsoup.org/u/FabriceN)\
**Post date:** [September 11, 2023, 12:17pm UTC](https://the.fmsoup.org/t/stacked-find/3688/7 "2023-09-11T12:17:24Z")

</div>

Using my function FOR.list (sorry, [fmfunctions.com](http://fmfunctions.com) is down again, I'll have to copy the code here).  
It gets that simple.

```auto
Enter Find Mode [pause: Off]
Loop
   Exit loop if [ FOR.list ( "i" ; $list )
   Set field [table::field ; "==" & $i.value]
   New Record
End Loop
Perform Find []

```

* * *

Function: FOR.list ( \_iterator ; \_list )

```auto
FOR.list ( _iterator ; _list )
Fabrice Nordmann, @1morethingTweet
www.1-more-thing.com

v1. Dec 2017

Use in an ExitLoop script step to process each value of a ¶ delimited list.

A script like:

Loop
	Exit Loop [FOR.list ( "item" ; list ( "apple" ; "banana" ; "cherry" ))]
	Show Custom Dialog [$item.value]
End Loop

Will display 3 dialog boxes ("apple", "banana" and "cherry") and stop.

*/

Let ( _iterations = ValueCount ( _list ) ;

Case ( _iterations and not IsEmpty ( _iterator );
	Evaluate ( "Let ( $" & _iterator & "= $" & _iterator & "+1 ; \"\" )") &
	Evaluate ( "Let ( $" & _iterator & ".value = " & Quote ( GetValue ( _list ; Evaluate ( "$" & _iterator ))) & "; \"\")" ) &
	Case (
		Evaluate ( "$" & _iterator ) <= _iterations ; 0 ;
		Evaluate ( "Let ([$" & _iterator & "= \"\" ; $" & _iterator & ".value = \"\"] ; 1 )" )
	 );
	True // no iterations -> exit
)
)

```

---

<div class="post-metadata">

**Author:** ![jwilling](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/jwilling/32/256_2.png) [@jwilling](https://the.fmsoup.org/u/jwilling)\
**Post date:** [September 12, 2023, 4:00am UTC](https://the.fmsoup.org/t/stacked-find/3688/8 "2023-09-12T04:00:54Z")

</div>

WHaaaa, how have I never thought to create a CF to handle for loop boilerplate!? Great idea

---

<div class="post-metadata">

**Author:** ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)\
**Post date:** [September 12, 2023, 5:27am UTC](https://the.fmsoup.org/t/stacked-find/3688/9 "2023-09-12T05:27:53Z")

</div>

Even though I use a clipping library for cutting/pasting code from the FileMaker clipboard, I'm thinking the same thing.

I have a [Filemaker Object Archive](https://github.com/fyodorovich/FileMakerObjectArchive) that converts FMP clipboard data into UTF-8 text and stores it for analysis or for re-use. It's based on [Dan Shockley's FmClipTools](https://github.com/DanShockley/FmClipTools). I just logged into GitHub to grab the links for Dan's Clip Tools repo, and GitHub pointed me to his latest effort, which is an AppleScript wrapper around @jwilling's [FM Rainbow Log](https://github.com/jwillinghalpern/fm_rainbow_log).

> **[GitHub - jwillinghalpern/fm\_rainbow\_log](https://github.com/jwillinghalpern/fm_rainbow_log)**
>
> Contribute to jwillinghalpern/fm\_rainbow\_log development by creating an account on GitHub.

Even though I'm using [iTerm](http://iterm2.com/) and it allows me to store regex based colourising rules in my profile (so my logs get colourised magically), I'm thinking I need to install Rust.

* * *

**Question: If I spend all of next weekend watching Rust tutorials, who should I blame?**

_Poll ([view on site](https://the.fmsoup.org/t/stacked-find/3688/9))_

---

<div class="post-metadata">

**Author:** ![FabriceN](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/fabricen/32/2506_2.png) [@FabriceN](https://the.fmsoup.org/u/FabriceN)\
**Post date:** [September 12, 2023, 7:03am UTC](https://the.fmsoup.org/t/stacked-find/3688/10 "2023-09-12T07:03:11Z")

</div>

I have a few 🙂  
FOR  
FOR.list  
WHILE (must rename this one)

---

<div class="post-metadata">

**Author:** ![DanShockley](https://avatars.discourse-cdn.com/v4/letter/d/9f8e36/32.png) [@DanShockley](https://the.fmsoup.org/u/DanShockley)\
**Post date:** [October 6, 2023, 5:25pm UTC](https://the.fmsoup.org/t/stacked-find/3688/11 "2023-10-06T17:25:03Z")

</div>

I'm checking out your Archive and Recover scripts - I was hoping to do something similar in the FmClipTools project, but want to be careful to avoid making it too complicated.  
@Malcolm - feel free to jump into the discussion linked below: you might have some insight. I haven't gotten around to actually _doing_ the things discussed there yet:

> <https://github.com/DanShockley/FmClipTools/pull/14>
>
> Added two AppleScripts which allow for managing a library of Snippets within a d…edicated Snippets folder. One script opens the folder for management within the OS and the other simply presents a file chooser and copies the contents to the clipboard and converts to FM Objects.
> 
> If the changes to using notification center over dialogs is undesirable you can revert those. Or, I can make a new patch.

EDIT: In the past, I've had a FileMaker based interface for storing/retrieving snippets of code, including with merge fields. That had the advantage of being able to name the merge fields in an interface, instead of inside an AppleScript code file. And, it meant that the text swapped in for the merge fields could be a FileMaker calculation result, too. But, the downside was having an interface built IN FileMaker when you might be developing inside a modal FileMaker window like Manage Database. Too bad it is no longer trivial to have a runtime app that is still officially supported.

---

<div class="post-metadata">

**Author:** ![mipiano](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/mipiano/32/1074_2.png) [@mipiano](https://the.fmsoup.org/u/mipiano)\
**Post date:** [October 6, 2023, 9:44pm UTC](https://the.fmsoup.org/t/stacked-find/3688/12 "2023-10-06T21:44:21Z")

</div>

@DanShockley  
I duplicated my installed FileMaker app into an Application folder in my user folder. I am able to run FileMaker two times in parallel. So I can have open the Manage Database window in one FM and another file in the other FM.

That works like a charm! I need that nearly daily.

Both FM apps get their own icon with different colors. So in the dock I can distinguish them.  
In the "blue" FM I open my "need also" databases. In the "orange" one the file to work on.

---

<div class="post-metadata">

**Author:** ![FileKraft](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/filekraft/32/1183_2.png) [@FileKraft](https://the.fmsoup.org/u/FileKraft)\
**Post date:** [October 8, 2023, 3:49pm UTC](https://the.fmsoup.org/t/stacked-find/3688/13 "2023-10-08T15:49:49Z")

</div>

no need to move it out of the root application folder - just duplicate it there as many times as you want.  
 ![image](https://canada1.discourse-cdn.com/flex030/uploads/fmsoup/original/2X/d/db2518cda07ca831fb4e56cf0068955c48fb1f2e.png)

---

<div class="post-metadata">

**Author:** ![mipiano](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/mipiano/32/1074_2.png) [@mipiano](https://the.fmsoup.org/u/mipiano)\
**Post date:** [October 8, 2023, 4:07pm UTC](https://the.fmsoup.org/t/stacked-find/3688/14 "2023-10-08T16:07:27Z")

</div>

I just don't like "FileMaker Pro 1". "FileMaker Pro 2", etc. in the Applications folder. This is my peculiar "aesthetic" feeling. That's why I do it the way described. 😊

---

<div class="post-metadata">

**Author:** ![Torsten](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/torsten/32/1574_2.png) [@Torsten](https://the.fmsoup.org/u/Torsten)\
**Post date:** [October 8, 2023, 4:18pm UTC](https://the.fmsoup.org/t/stacked-find/3688/15 "2023-10-08T16:18:09Z")

</div>

Great stuff!
