Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5289 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

One of the great features of Filemaker Pro Advanced is using the clipboard

to copy and paste field definitions, table definitions, scripts, and script

steps.

Filemaker uses XML to structure the clipboard contents. You can read the

contents of the FileMaker clipboard and convert it to text and place it in a

field. You can also take properly formatted text and put it back on the

clipboard so that it can be pasted into field, script, or table definitions.

The technique described here requires applescript

Here is how to get data from the clipboard and pop it into the field "XML"

-- script start

-- get FileMaker clipboard

-- put as text in field "XML"

set applescript's text item delimiters to ""

tell app "System Events"

set clip_data to {the clipboard as record} as string

set the_start to offset of "" in clip_data

(characters the_start through -1 of clip_data) as string

set x to result

-- convert LF to return

set applescript's text item delimiters to ascii character 10

copy text items of x to x

set applescript's text item delimiters to return

copy x as text to x

end tell

copy x to cell "XML" of current record

-- script end

Below is a simple applescript to convert scripts stored in field "XML" and

put it on Filemker clipboard. This version does scripts only but you can use

the different codes to handle other data formats.

Codes:

XMTB for table definitions

XMSC for script definitions

XMFD for field definitions

XMSS for script steps

-- start script

-- get data from field and put onto clipboard

set xmlsource to get data cell "XML" of current record

set mypath to ((path to temporary items) as text) & "script.txt"

set pxpath to (posix path of (path to temporary items) ) & "script.txt"

tell application "System Events"

do shell script "echo " & quoted form of xmlsource & " > " & pxpath

set x to (read alias mypath as «class XMSC»)

set the clipboard to x

end tell

-- end script

  • 2 years later...
Posted

-- script start

-- get FileMaker clipboard

-- put as text in field "XML"



set applescript's text item delimiters to ""



tell app "System Events"

set clip_data to {the clipboard as record} as string

set the_start to offset of "" in clip_data

(characters the_start through -1 of clip_data) as string

set x to result



-- convert LF to return

set applescript's text item delimiters to ascii character 10

copy text items of x to x

set applescript's text item delimiters to return

copy x as text to x

end tell



copy x to cell "XML" of current record

-- script end

I am trying this code, but it seems it is failing on the conversion of the "clipboard as record" to the string class.

I get the error: "Can't make some data into the expected type".

What I did to test this code:

Opened a FileMaker database, entered the Database Definition, and copied a field. Then ran the code.

System:

Mac OS X 10.5.8

Script Editor: Version 2.2.1 (100.1)

FileMaker Pro 10 Advanced

Can anyone help me on this?

Thanks !

  • 1 month later...
Posted

It is exactly the same here...

Any suggestions would be highly appreciated...

I would love to use this technique!

(already on snow leo 10.6.2 and FM Advanced 10)

((For some reason, the 'show FileMaker Profile' Option didn't work...))

(((found it...)))

  • 2 months later...
Posted

Here's the two basic functions to save/load clipboard data to/from a file.

You may need to replace '«class XMSC»' with an appropriate class description (see the first post of this topic).

It should work on Snow Leopard as well.

on saveToFile()

	-- Read the clipboard data.

	try

		set clipboardData to the clipboard as record

		set xmlData to «class XMSC» of clipboardData

	on error errMsg number errNum

		display dialog (localized string "invalidClipboardData") & return & errNum

		return

	end try

	-- Save the clipboard data as XML text file.

	set destFile to choose file name with prompt (localized string "chooseFileName")

	try

		set destRef to open for access destFile with write permission

		set eof of destRef to 0

		write xmlData to destRef starting at eof

		close access destRef

	on error

		try

			close access destRef

		end try

	end try

end saveToFile



on loadFromFile()

	set xmlFile to choose file with prompt (localized string "chooseFile")

	try

		set srcRef to open for access xmlFile without write permission

		set xmlData to read srcRef as «class XMSC»

		close access srcRef

		set the clipboard to xmlData

	on error errMsg number errNum

		try

			close access srcRef

		end try

		display dialog errMsg & return & errNum

	end try

end loadFromFile

We have released it as a freeware with minimal UI.

http://bit.ly/csd1Wc

..and here's another for those who have Microsoft Excel.

http://bit.ly/bQi9FA

Hope you find them useful.

Cheers!

Iwao

This topic is 5289 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.