Tuesday, November 24, 2009

Filemaker MineSweeper clone


Though about creating a board game in FileMaker to demonstrate the capabilities of FileMaker Pro.
Started it, finished in about 2 hours.


So here it is, actually it's pretty straight forward and fully unlocked so you can check it.

The main fields of the database are the Display, and the Game Repeating field.
The Display shows the board, while the Game contains the yet unrevealed fields, mines.

The Init method initializes the board, sets the random mines, counts the neighbor cells (how many one mine has), etc.
The ClickHandler method takes care of the clicks, by using hidden clickable layout elements behind the repeating fields.
(Actually these clickable elements weren't created by me one by one, setting up different script paramters 300 times, instead I created a script to generate the appropriate XML for me, and then pasted it on the layout using
Clip Manager 3 by MyFmButler. (Maybe I will show this technique in a separate article later if you're interested).

The rest of the methods are a bit harder to understand, but if you check them I'm pretty sure you will see how they're working.

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

Note1: I did't spend too much time on optimizing this. I'm pretty sure scripts could be more optimized, etc. This is just a demo file, to see how much you can do with Filemaker

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.


Filemaker - Using Growl without plugins

In this article I will show you how to create a simple Growl notification in FileMaker without additional plugins.

I have a FileMaker ToDo list, which can be filled by some people.
I wanted some kind of notification of new tasks they fill in it, without having to look at it all the time checking for new entries.

I already had Growl installed, so I thought why not use it as a notification? It has a sticky option which allows notifications to stay on the screen until I click on them. That was exactly what I needed.

That is where the following sample came from.

I didn't want to look for plugins (I am pretty sure there must be one for this), as I like to do things without plugins.
I started looking around for AppleScript samples how to use Growl, and found some on the Growl website. I modified those to run from FileMaker.

The Growl notification is a simple calculated Perform AppleScript command:

----

"tell application \"System Events\"¶

set isRunning to count of (every process whose name is \"GrowlHelperApp\") > 0¶

end tell¶

if isRunning then¶

tell application \"GrowlHelperApp\"¶


register as application \"GrowlSampleApp\" all notifications {"& Quote ("TestNotify") & "} default notifications {"& Quote ("TestNotify") & "} icon of application \"FileMaker Pro" & Case ( PatternCount ( Get ( ApplicationVersion ) ; "Advanced" ) ; " Advanced\"" ; "\"" ) & "¶


notify with name "& Quote ("TestNotify") & " title " & Quote (GrowlSample::Title) & " description " & Quote(GrowlSample::GrowlText) & " application name \"GrowlSampleApp\""& " sticky "& Quote (GrowlSample::Sticky) &"¶


end tell¶

end if¶"


----


The first part checks if Growl is up and running. The second part registers the application, and notifies with the set parameters.

The icon it shows is the Icon of FileMaker, but it can be changed to anything you wish.


We also have to check for Get(LastError) -609 to be sure.


I attached the sample file which you can download from here. (right click- save as!)



UPDATE: A commenter (doug says:) Here is a custom function that does a similar thing:http://www.briandunning.com/cf/1064


Based on ideas and code from Michael Gaslowitz http://www.gaslowitz.net/filemaker/blog/2008/07/video-growl-integration/


Thanks for that!


Note by Adam: However that custom function needs to be modified a little bit, as it doesn't checks for the GrowlHelper app running, be sure to change that!






Please also visit our site, http://crm.fm which has our main FileMaker product. 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.