Thursday, November 26, 2009

FileMaker Multiple word(part) portal filter


This technique might be known by some, but I'm pretty sure that it isn't know by many.
What we want to create is a multiple word (or wordpart) portal filter.


Many single word FileMaker portal filter demonstrations can be found on the net, but currently I needed one that can filter by multiple words.

Here's how I did it.

First we need a searchfield on the layout. I called this SearchField_Display.
Then we need a custom function that can create the variations of our fields.

I chose AllTextCombination by Peter Gort (it can be seen here, at Brian Dunning's custom function library).

With this function we create an AllVariation field based on our fields:

AllTextCombinations ( FirstName ) &"¶" & AllTextCombinations ( LastName ) & "¶" & AllTextC

ombinations ( City ) & "¶_ALL_"


The "¶_ALL_" at the end will be important later. That's used to show all the records is the searchfield is empty.


If we have this, we need three additional fields, which will help us to create a 3 word search ability. (note: if you want four words, then you'll need four, but I think 3 must be enough).


I call them SearchField1, SearchField2 and SearchField3, and they are unstored text calculations:


SearchField1:

Let ( s = Substitute ( SearchField_Display ; "-" ; " " ) ;If ( IsEmpty(s) or IsEmpty(MiddleWords(s;1;1)) ;"_ALL_";MiddleWords(s;1;1) ))


SearchField2:

Let ( s = Substitute ( SearchField_Display ; "-" ; " " ) ;If ( IsEmpty(s) or IsEmpty(MiddleWords(s;2;1)) ;"_ALL_";MiddleWords(s;2;1) ))


SearchField3:

Let ( s = Substitute ( SearchField_Display ; "-" ; " " ) ;If ( IsEmpty(s) or IsEmpty(MiddleWords(s;3;1)) ;"_ALL_";MiddleWords(s;3;1) ))


As you may notice the only difference is the word which we get from them.

I also used a Substitute ("-" to a Space char) as my data contained many "-" chars, and I wanted them as different words).


By these we can create a relation to AllVariation:



As you can see we'll have 3 criterias. (If you want 4 word you'll need 4).


After this, if we use the portal filter we'll be able to search for things like: "we la c", or "an li v" or "Bil bar abi" so basically any part of our fields.

I attached a demo file which you can download from here . (right click- save as).


Note1:The demo uses Brian Dunning's sample data database which I downloaded from here.
Note2: I used many fields in the AllVariation field which makes the index huge. You shouldn't need to do that!

Please also visit our site, http://crm.fm which has our main FileMaker product, and support us by buying it. Thanks!

The material on this document is offered as is. There is no representation or warranty, expressed or implied, nor does any other contributor to this post. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.






FileMaker Snake game - a FM 10 Demonstration



When I first started looking at FM10's new functions (Trigger, timer, etc), I wanted to create a demo, in which I can implement almost all of these new features.

I was currently also looking at my old floppy disks, and found my snake game I wrote in Turbo Pascal when I was a small kid, and thought why not recreate it in FileMaker?

It could demonstrate layout triggers (OnLayoutKeyStroke), Timers (speed of the game)
.

Heres is what I came up with:



The main layout is a repeating field container (300 repetitions actually), arranged.
The repeating field uses a global variable and conditional formatting to show the snake and the treasure (which is set by a custom function based on it's current repetition number).
Two colors are used, Green and White:


The Snake and Treasure positions are stored in global variables as a list (eg.: 10,12 11,12, etc), and are processed by the script.

The script names of the demo file shows what they do exactly, you could easily figure them out.

The layout has a script trigger, which is to check for keyboard input, so we can move the snake.

This is a FM10 demo, which you can download from here . (right click- save as)

Note1: I did't spend too much time on optimizing this, making it prettier, etc, it's up to you. This is just a demo file, to demonstrate some of FileMaker 10's new features.

Note2: Please also visit our site, http://crm.fm which has our main FileMaker product, and support us by buying it. Thanks!

The material on this document is offered as is. There is no representation or warranty, expressed or implied, nor does any other contributor to this post. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.