Monday, August 25, 2014

Quick tip: Detect OS X Yosemite dark mode from FileMaker

How to detect if OS X Yosemite is in "Dark Mode" from FileMaker?

Dark mode is stored in a defaults entry:  AppleInterfaceStyle
It's either "Dark" or no value.

So we just basically check if we get an error if we try to read this value.
If we get a value, we are in "Dark mode", else we're using "Normal mode".

Basic steps:

If [Abs (Get(SystemPlatform)) = 1]   //Running on OS X
    Perform AppleScript["do shell script "defaults read -g AppleInterfaceStyle""]  -  Native
      If [Get(LastError) = 0]
        Show Custom Dialog ["Dark mode!"]
      Else
        Show Custom Dialog["Normal mode!"]
      End if
End if

That's all.
You may use this to switch to a different themed layout, or to change your background color.

Thursday, October 21, 2010

iDeal CRM 6.0 has been released!!

I know, no updates on this site recently...

The main reason for that is that we were very busy finishing our CRM software.
I have already posted many FM techniques that came during the development of this product.
Still there are many left, so there will be new technical articles soon.



Sample videos:

1) Email import

2) Calendar


You can download our iDeal CRM here.



Saturday, August 7, 2010

FileMaker- Quick OS X Address Book importing without plugins

In this article I will show you how to import your OS X Address Book contacts quickly without plugins.

When it comes to Address Book, developers usually choose two methods.
1) AppleScript looping- It's slow for many contacts.
2) Plugins- They are not free.

I'd like to share another method, which is basically 2-3 lines of code.

What you will need:

1, perform applescript command
2, one import command
3, sql knowledge

How?

Address Book stores its data in an sqlite database, which can be found at the $Home/Library/Application Support/Address Book folder.

OS X can access this using the built-in sqlite3 command. (Reference here).

With this sqlite3, we just simply execute an sql command to get the address book data exported to a tab separated file to a temporary path (Perform Applescript- Do shell script)
Then we'll just import is using the Import Records script step.
(See the attached demo file for working scripts)

SQL:
You have to build your own SQL commands to use this technique. There are many GUI SQLite browsers (even Firefox plugins!). Browse through the address book tables, and explore them. That's exactly what I did.
Also you can do a search on "OS X address book sqlite" to find sample sql scripts to experiment with.

I attached a sample file which has two sample scripts.
The first script imports just the first name, last name, middle name, company data.
The second one imports the contact's phone number, mobile and email address as well.



You can download a really simple demonstration from here . (right click- save as).
Feel free to modify the scripts, sql statements!


Note: I didn't spend much time to optimize the code. You should quit Address Book before exporting it's data. If you experiment with this technique, please do a backup of your address book db.

The attached sample may need to be modified if your address book database file is somewhere else.


- Adam


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.

Friday, June 18, 2010

Multilingual FileMaker Layouts

In this article I will show you how to build a multilingual user interface in FileMaker.


Recently I saw a very complicated method floating around the net, so I thought I'd show you a method we use at Idealisator Hungary.

What you will need:

A table (called languages), which will hold the translations of every single layout text, button text, etc that you wish to use. These each will be new fields (eg: Button_OK, Button_Cancel, Message_Error, etc) + here you will have a text field (Language) which will contain the language name.

Get the idea? To create a new language you just need to create a new record in this language table, fill the Language field with the appropriate language name, fill the layout text fields, and there you have a new language.


Then you will need a CurrentLanguage Global field in the table your current layout is based on.
Then you just simply create a relation between this CurrentLanguage field with the Languages::Language text field, and you're pretty much ready.



You just need to add these fields to the layout (via the Language relations), and by changing the CurrentLanguage global field, you can easily change the display language on the layout.


You can download a really simple demonstration from here . (right click- save as).
I included english, german and hungarian languages.

Feel free to contact us if you need further information!

Update: In find mode, you need global fields for each layout text you use on the layout. (copy to those globals the appropriate language fields, or evaluate it.
As a solution should contain one, or maybe two search screens, not every layout searchable, I think it can be handled this way. In the comments you can see more of this. My opinion is that this method I wrote is one of the easiest to implement, while others may need much more work. - Adam


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.

Thursday, May 13, 2010

Simple logical board game in FileMaker

In this article I will show you a simple logical board game I created in FileMaker.

It's actually quite simple to implement, so I think beginners will like to investigate this unlocked solution and create their owns based on it.

The game has 4x4 cells, filled with numbers. There is an empty one which is the "gap".
You can only move the cells that are next to the gap.
(3, 15 and 9 can be moved in the picture above)

The goal is to reorder the numbers, so that they are in order, and the gap is in the lower right corner:
The board itself is a repeating field (16 repetitions), the clicking is done by an OnObjectEnter trigger attached to it (So it needs FM10- but can be modified to be FM8+ compatible by creating hidden buttons behind the repetitions).

After the click, we check if it is legal to move that piece (this is done by the "Move" script, the script parameter is the current repetition number).
If it's legal, we change the empty(gap) repetition with the clicked one, and store the empty cell's repetition number in a global variable ($$emptypiece).

After every legal movement we check if the user won the game (CheckWin script - It is just checking the repetitions with a loop).

Shuffling is done by imitating clicking at a random cell many times (500). This is important, because if we just initialized the repeating field with a random order, you may not be able to solve the game (!).

So shuffling with valid movements make sure the shuffled game can be solved.

The rest of the methods are easy to understand, check it out, you will see what they do exactly.

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

My other FileMaker based games (unlocked) can be found here:


Feel free to contact me if you need further information!

UPDATE:

I really got addicted to this :) So I modified it a little. Now it has colors, with conditional formatting (for the white gap). I also added keyboard navigation + a movement count to track our progress :)


Keyboard navigation is done by a Layout trigger (FM10+ - KeyboardMovement Script), colors are simple formatting (fill, but added a conditional formatting for the gap - white). Movement count is a simple new Number field.

So here it is, second version, you can download from here.


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.

Thursday, March 18, 2010

Save to PDF in Filemaker Runtimes? - Yes

I needed to export a report to PDF in one of our runtime solutions.

As we all know, it's not possible in FileMaker as PDF export script steps won't run in runtime solutions.

But I created a little workaround I'd like to share.

So what you need:

A global container field.

That's all.

1) When you do the report - enter preview mode on the report layout(be sure to set the page setup, etc).
2) Copy script step - Copy script step in preview mode copies the report to the clipboard(screenshot like)
3) Enter browse mode - go to the layout where you have that global field
4) Paste the clipboard to that global container field
5) Export field contents (the global container field).

Hey, there you have the pdf file from the runtime! Cool?

Note: It's basically for one page reports, but you can create a screen shot of every page of the report to a different container field (go to record-next in preview) and export those too.

I attached a sample file, which you can download here. You can create a runtime solution from it using FileMaker Pro Advanced.



Please 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.

Monday, January 11, 2010

Tweet with FileMaker (simple method, Win+Mac, No Curl)

In the following article, I would like to demonstrate how you can update your twitter status with filemaker using a very simple method.

Recently I see a solution floating around which uses CURL to do this, but it's Mac only, and why use curl, if we don't need it?

We'll just use a simple web viewer to do this.

First we need to understand how we can update our status using twitter API. You can check this here.

If we have this, we just need to create a web viewer, with a post html form, and a so called "self-posting" javascript code in it.

This is it:

"data:text/html," &
"<html>
<head>
<script>
function PostMe() {document.getElementById(\"myform\").submit();}
</script>
</head>
<body onload=\"PostMe()\">
<form id=\"myform\" method=\"post\" action=\"http://" & FmPostTwit::UserName_Global & ":" & FmPostTwit::PassWord_Global & "@twitter.com/statuses/update.xml\" enctype=\"application/x-www-form-urlencoded;charset=utf-8\" accept-charset=\"UTF-8\">
<input type=\"hidden\" name=\"status\" value=\"" & FmPostTwit::Status_Global & "\">
</form>
</body>
</html>"



Let's take a look at it.

The "data:text/html," part is to let the web viewer have inner html content(the form).

The next part is the javascript code, which will post the form when it loads.

The last part is the html form, with the needed input (status- hidden).


This will be put into a web viewer(object name vw) by the Set Web Viewer Script step- Go To URL.


So basically the one line code is:


Set Web Viewer[Object Name:vw; URL: here comes the html code from above]


That's all.


I attached a sample file, which you can download here.


Please check it, and use this technique it if you like it.


Please 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.