{"id":16,"date":"2010-12-27T14:35:54","date_gmt":"2010-12-27T22:35:54","guid":{"rendered":"http:\/\/sibr.com\/blog\/?p=16"},"modified":"2010-12-27T14:35:54","modified_gmt":"2010-12-27T22:35:54","slug":"new-version-of-bbox-filemaker-plugin","status":"publish","type":"post","link":"http:\/\/sibr.com\/blog\/2010\/12\/27\/new-version-of-bbox-filemaker-plugin\/","title":{"rendered":"New version of bBox FileMaker plugin"},"content":{"rendered":"<p>One of my work\/personal projects has been a FileMaker external plug-in for the Mac OS called bBox. The main push with this recently has was to include access to the Python scripting language. Previously, using bBox&#8217;s existing bBox_Shell function I could&#8217;ve called a Python script this way:<\/p>\n<blockquote><p><strong>Set Variable <\/strong>[ $script; Value:&#8221;xs = &#8216;He&#8217; + &#8216;llo&#8217;; print xs # Complicated way to say hello&#8221; ]<\/p>\n<p><strong>Set Variable <\/strong>[ $res; Value:bBox_Shell( 0; &#8220;python -c \\&#8221;&#8221; &amp; $script &amp; &#8220;\\&#8221;&#8221;) ]<\/p>\n<p><strong>Show Custom Dialog <\/strong>[ Title: &#8220;Python&#8221;; Message: $res; Buttons: \u201cOK\u201d ]<\/p><\/blockquote>\n<p>That&#8217;s definitely do-able. But you&#8217;ll likely have to reformat your scripts, and be careful about quoting or escaping characters. Alternatively, you could first ensure that your script had first been saved out to a file, perhaps by using FileMaker&#8217;s Export Records command.<\/p>\n<p>But instead, I can now write something like the following from a FileMaker script:<\/p>\n<blockquote><p><strong>Set Variable <\/strong>[ $script; Value:&#8221;# Complicated way to say hello. xs = &#8216;He&#8217; + &#8216;llo&#8217;<\/p>\n<p>print xs &#8220;]<\/p>\n<p><strong>Set Variable <\/strong>[ $res; Value:bBox_PythonCompile( 0; $script ) ]<\/p>\n<p><strong>If <\/strong>[ $res = &#8220;&#8221; ]<\/p>\n<p><strong> Set Variable <\/strong>[ $res; Value:bBox_PythonExecute( 0 ) ]<\/p>\n<p><strong> Set Variable <\/strong>[ $ig; Value:bBox_PythonFinalize ]<\/p>\n<p><strong>End If<\/strong><\/p><\/blockquote>\n<p>You may be wondering why it takes three function calls to execute such a simple script. There are three reasons for this. Most obviously, a script can be executed multiple times but only needs to be executed once. A related, but less obvious reason is the need to setup and then teardown the Python environment, which is significant for a short script like this. Finally, it allows the option of setting or retrieving Python variables from FileMaker, which can now be done with the bBox_PythonSetVar and bBox_PythonGetVar functions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of my work\/personal projects has been a FileMaker external plug-in for the Mac OS called bBox. The main push with this recently has was to include access to the Python scripting language. Previously, using bBox&#8217;s existing bBox_Shell function I could&#8217;ve called a Python script this way: Set Variable [ $script; Value:&#8221;xs = &#8216;He&#8217; + &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/sibr.com\/blog\/2010\/12\/27\/new-version-of-bbox-filemaker-plugin\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;New version of bBox FileMaker plugin&#8221;<\/span><\/a><\/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":[7,10],"class_list":["post-16","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-filemaker","tag-python"],"_links":{"self":[{"href":"http:\/\/sibr.com\/blog\/wp-json\/wp\/v2\/posts\/16","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/sibr.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/sibr.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/sibr.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/sibr.com\/blog\/wp-json\/wp\/v2\/comments?post=16"}],"version-history":[{"count":0,"href":"http:\/\/sibr.com\/blog\/wp-json\/wp\/v2\/posts\/16\/revisions"}],"wp:attachment":[{"href":"http:\/\/sibr.com\/blog\/wp-json\/wp\/v2\/media?parent=16"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/sibr.com\/blog\/wp-json\/wp\/v2\/categories?post=16"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/sibr.com\/blog\/wp-json\/wp\/v2\/tags?post=16"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}