{"id":33,"date":"2014-09-04T15:52:39","date_gmt":"2014-09-04T15:52:39","guid":{"rendered":"https:\/\/www.tech.shinynewthings.com\/?p=33"},"modified":"2014-09-04T15:52:39","modified_gmt":"2014-09-04T15:52:39","slug":"from-sql-to-filemaker-with-applescript","status":"publish","type":"post","link":"https:\/\/www.tech.shinynewthings.com\/?p=33","title":{"rendered":"From SQL to FileMaker with Applescript"},"content":{"rendered":"<pre style=\"font:inherit;\">\r\n<code>\r\n-- FIELD NAMES WERE EXPORTED FROM SQL INTO FIRST LINE OF CSV\r\n-- DONT ASK WHY WERE GOING FROM SQL TO FMP\r\n-- THEN AGAIN IF YOU NEED IT, HERE IT IS\r\n\r\nset dbName to \"\"\r\nset tableNames to {\"\"}\r\nset fieldNamesList to {\"\"}\r\n\r\nrepeat with i from 1 to the count of tableNames\r\n    set tableName to item i of tableNames as string\r\n    set fieldNames to item i of fieldNamesList as list\r\n    createTable(dbName, tableName, fieldNames)\r\n    set i to i + 1\r\nend repeat\r\n\r\n\r\non createTable(dbName, tableName, fieldNames)\r\n    tell application \"FileMaker Pro\"\r\n        activate\r\n        tell database dbName\r\n            tell table tableName\r\n                tell application \"System Events\"\r\n                    tell process \"FileMaker Pro\"\r\n                        keystroke \"d\" using {command down, shift down}\r\n                        tell window 1\r\n                            --- MAKE TABLE\r\n                            tell tab group 1\r\n                                click radio button 0\r\n                            end tell\r\n                            set the clipboard to tableName as text\r\n                            keystroke \"v\" using command down\r\n                            delay 1\r\n                            keystroke return\r\n                            --- MAKE FIELDS\r\n                            tell tab group 1\r\n                                click radio button 2\r\n                            end tell\r\n                            repeat with i from 1 to the count of fieldNames\r\n                                set fieldName to item i of fieldNames as string\r\n                                set the clipboard to fieldName as text\r\n                                keystroke \"v\" using command down\r\n                                delay 1\r\n                                keystroke return\r\n                                set i to i + 1\r\n                            end repeat\r\n                            click button \"OK\"\r\n                        end tell\r\n                    end tell\r\n                end tell\r\n            end tell\r\n        end tell\r\n    end tell\r\nend createTable\r\n\r\n<\/code>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&#8212; FIELD NAMES WERE EXPORTED FROM SQL INTO FIRST LINE OF CSV &#8212; DONT ASK WHY WERE GOING FROM SQL TO FMP &#8212; THEN AGAIN IF YOU NEED IT, HERE IT IS set dbName to &#8220;&#8221; set tableNames to {&#8220;&#8221;} set fieldNamesList to {&#8220;&#8221;} repeat with i from 1 to the count of tableNames set [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-33","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/posts\/33","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=33"}],"version-history":[{"count":1,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/posts\/33\/revisions"}],"predecessor-version":[{"id":35,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/posts\/33\/revisions\/35"}],"wp:attachment":[{"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=33"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=33"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=33"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}