Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.DS_Store
FmObjectTranslator.app
FmObjectTranslator.app
Snippets/*
!Snippets/README.md
24 changes: 6 additions & 18 deletions Scripts/fmClip - Clipboard FM Objects to XML.applescript
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
-- fmClip - Clipboard FM Objects to XML
-- version 4.0.3, Daniel A. Shockley, Erik Shagdar
-- version 4.0.4, Daniel A. Shockley, Erik Shagdar

(*
Converts any FileMaker objects in the clipboard into XML, then ADDS that XML TEXT to the clipboard as an additional object.

HISTORY:
4.0.4 - 2024-01-11 ( danshockley ): Testing added Theme support, renamed clipboardHasFM variable for clarity.
4.0.3 - 2023-03-10 ( dshockley ): Turned off default to prettify XML.
4.0.2 - 2023-03-04 ( dshockley ): Turned off debugMode property of objTrans, since not needed for normal use.
4.0.1 - 2018-04-20 ( dshockley/eshagdar ): if layout objects, no modification. Others default to prettify.
Expand All @@ -25,7 +26,7 @@ on run
set objTrans to fmObjectTranslator_Instantiate({})
*)

set clipboardType to checkClipboardForObjects({}) of objTrans
set clipboardHasFM to checkClipboardForObjects({}) of objTrans


if currentCode of objTrans is "XML2" then
Expand All @@ -39,26 +40,13 @@ on run

--set debugMode of objTrans to true -- ONLY enable this while developing/testing


if clipboardType is false then
if clipboardHasFM is false then
display dialog "The clipboard did not contain any FileMaker objects."
return false
end if

clipboardConvertToXML({}) of objTrans

return true
return result

end run












3 changes: 2 additions & 1 deletion Scripts/fmClip - Clipboard XML to FM Objects.applescript
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ on run
set dialogMsg to dialogMsg & return & "Clipboard starts with: " & clipboardStartsWith
end try
end try
display dialog dialogMsg
display notification dialogMsg with title "FileMaker Clipboard" sound name "Funk"
--display dialog dialogMsg
return false
end if

Expand Down
26 changes: 26 additions & 0 deletions Scripts/fmClip - Snippets Open Folder.applescript
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-- fmClip - Open Snippets Folder
-- version 1.0.0, Matt Petrowsky

(*
Simply opens the Snippets folder for the purpose of managing snippet files.

HISTORY:
1.0 - initial commit
*)


-- Create path to Snippets folder.
set myFolder to ((((path to me as text) & "::") as alias) as string)
set stripLevel to text 1 thru ((length of myFolder) - 1) of myFolder -- strip trailing ":"
set parentFolder to text 1 thru -((offset of ":" in (reverse of characters of stripLevel) as string) + 1) of stripLevel

set snippetsFolder to parentFolder & ":Snippets:" as alias
set snippetsPath to POSIX path of snippetsFolder

set command to "open " & snippetsPath

try
set commandResult to do shell script command
on error errMsg
display dialog "An error occurred: " & errMsg buttons {"OK"} default button "OK" with icon stop
end try
107 changes: 107 additions & 0 deletions Scripts/fmClip - Snippets Select Snippet.applescript
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
-- fmClip - Select from Snippets
-- version 1.0.0, Matt Petrowsky

(*
Presents a list of available snippet files from the dedicated Snippets folder and calls XML to FM Objects.

HISTORY:
1.0 - initial commit
*)
property scriptPath : ""
property scriptName : "fmClip - Clipboard XML to FM Objects.applescript"
property myFolder : alias


-- Create path to Snippets folder.
set myFolder to ((((path to me as text) & "::") as alias) as string)
set stripLevel to text 1 thru ((length of myFolder) - 1) of myFolder -- strip trailing ":"
set parentFolder to text 1 thru -((offset of ":" in (reverse of characters of stripLevel) as string) + 1) of stripLevel

set snippetsFolder to parentFolder & ":Snippets:" as alias
set snippetsPath to POSIX path of snippetsFolder

(*
-- Present a simple list of files in the Snippets folder
set fileList to {}

tell application "System Events"
set fileNames to name of files of folder snippetsPath
repeat with fileName in fileNames
if fileName as string is not equal to ".DS_Store" then
set end of fileList to (snippetsPath & fileName) as string
end if
end repeat
end tell

-- Prompt user for which snippet to put onto the clipboard.
try
tell application "System Events"
set fmAppProc to my getFmAppProc()
tell fmAppProc
set frontmost to true
set chosenFile to choose from list fileList with prompt "Select a snippet file:" without multiple selections allowed
set xmlFile to (item 1 of chosenFile)
set filePath to xmlFile as POSIX file as alias
end tell
end tell
on error
return
end try
*)

-- Or, an easier option of just using a file chooser.

try
set fmAppProc to my getFmAppProc()
tell fmAppProc
set frontmost to true
end tell

tell me to activate
set chosenFile to choose file default location snippetsFolder without multiple selections allowed
fmClipboardObject(chosenFile)

on error errMsg number errNum
if errNum is -128 then return -- user canceled
error errMsg number errNum
end try

-- Read file contents, set to clipboard and call script.
on fmClipboardObject(filePath)
try
tell application "System Events"
set scriptPath to myFolder & scriptName
set fileContents to read filePath as �class utf8�
set the clipboard to fileContents
if run script alias scriptPath then
display notification "Snippet is on the clipboard." with title "FileMaker Clipboard" sound name "Funk"
end if
end tell
set fmAppProc to my getFmAppProc()
tell fmAppProc
set frontmost to true
end tell
on error errMsg
display dialog "File read error: " & errMsg buttons {"OK"} default button "OK" with icon stop
end try
end fmClipboardObject

-- Helper function to target the FileMaker app process.
on getFmAppProc()
-- Gets the frontmost "FileMaker" app (if any), otherwise the 1st one available.
tell application "System Events"
set fmAppProc to first application process whose frontmost is true
if name of fmAppProc does not contain "FileMaker" then
-- frontmost is not FileMaker, so just get the 1st one we can find
-- (if multiple copies running, must make the one you want is frontmost to be sure it is used)
try
set fmAppProc to get first application process whose name contains "FileMaker"
on error errMsg number errNum
if errNum is -1719 then return false
error errMsg number errNum
end try
end if
return fmAppProc
end tell
end getFmAppProc

23 changes: 23 additions & 0 deletions Snippets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# About this folder

The Snippets folder can serve as a personal repository for XML snippets - or - you can link to other collections (repositories) within this folder using [git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules).

# As a local collection

Using the Snippets folder to store your own local collection of scripts can be quite useful. Here is an example listing of possible subfolders.

- Fields
- Functions
- Layouts
- Menus
- Scripts
- Steps
- Tables
- Themes

# Accessing this folder

There are two scripts which interact with this folder.

- **fmClip - Snippets Open Folder** - for opening the Snippets folder within the Finder.
- **fmClip - Snippets Select Snippet.applescript** - for selecting a Snippet from within any AppleScript compatible environment - including osascript on the command line.