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

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

Recommended Posts

Posted

This is a snippet of a script which works fine when running from the Applescript script editor. It just creates/opens a small text file on the startup disk, writes some text to it, and then closes the file.

However, when you try to put this applescript into Filemaker Scriptmaker in a Perform Applescript statement it comes up with the error "Expected end of line but found identifer" and highlights "thetext" where it says "write thetext to fileref" when you try to compile it.

Any reasons why it wont compile within Filemaker and any way to get around this?

thanks.

set thetext to "Hello this is a test"

set startpath to (path to startup disk) as string

set filepath to (startpath & "thetextfile.txt")

set fileref to open for access file filepath with write permission

try

write thetext to fileref

close access fileref

on error

close access fileref

end try

Posted

Ok i have solved this, by encasing the whole statement between

TELL APP "SYSTEM EVENTS"

.........

END TELL

On a few other web sites i have however come across people saying that you can also enter RAW SCRIPT language, as filemaker doesn't recognise the WRITE statement, for example replacing WRITE with "+event rdwrwrit;", but i found that this also did not compile in filemaker.

write theText to file theDocument --> error

+event rdwrwrit; theText to file theDocument --> ok

Posted

More!!!

TELL APP "SYSTEM EVENTS" actually didn't work in the end as no data was being written - it created the file but did not write to it.

Replacing with TELL APP "FINDER" worked fine

Posted

Alternatively, use shell commands. They are great!

get data cell "ExportMe" of current record

set exportStuff to result

get data cell "Filename" of current record

set exportFileName to result

do shell script "echo " & quoted form of exportStuff & " > ~/desktop/" & exportFileName

  • 4 months later...
Posted

Hi there,

Just came across this post and was wondering how to use the 'shell' commands from within Filemaker. Are these actually for use in Mac OSX or are they Windows only specific?

Any help with this would be greatly appreciated.

Regards,

Mark Bowen

Posted

Mark:

BruceR used the shell commands via AppleScript's "do shell script" command. It's usually the easiest way to mix AppleScript and shell commands. AppleScripts can be run from FileMaker via the Perform AppleScript step.

There is also a more direct way to run shell commands, using a free FileMaker plug-in:

http://www.abstrakt.com/index.html

It is available for both platforms, but the commands would be different on Windows.

mikeytt:

The problem you had was that inside FileMaker you have to put the "open" and "write" commands inside a tell "Finder" block. The following works. But the shell method is better. For one thing, the straight AppleScript method writes any returns inside your text field as what they are, the internal FileMaker ASCII 11, whereas the shell command translates them to the UNIX standard line ending, ASCII 10. I don't know exactly why (perhaps BruceR does), but it's a heck of lot easier. Anyway, the straight AppleScript:

set thetext to cell "theText" of current record as string

set startpath to (path to desktop) as string

set filepath to (startpath & "thetextfile.txt")

tell application "Finder"

set fileref to open for access file filepath with write permission

try

write thetext to fileref

close access fileref

on error

close access fileref

end try

end tell

  • 1 month later...
Posted

Hi All,

I think we can resolve the "write" command issue by doing this....

Solution 1

Step 1: Write code in applescript and compile apple script to develop an application say "myApp"

Step 2: In file Maker:

- Create a script say "myScript", use "Send Event" and attach the compiled applescript application. (with open Application option, select "myApp" file)

-call this script i.e. Perform "myScript".

Solution 2

Create new script file say WriteFileProcedure.scpt

in which, code the applescript that has the "write" command used.

Step 1: Perform Applescript()

step 2: Native Applescript... paste your code here

Both strategies worked very well...

Regards,

MetaSys Software Pvt. Ltd.

  • 2 months later...
  • Newbies
Posted

This is a FileMaker quirk. If you just wrap the read/write commands inside a Finder tell block it will all work without a problem.

set output_path to ((path to startup disk) & "Documents:log.txt") as string

tell application "Finder"

	set thetext to "Hello this is a test"

	set f_ref to open for access file output_path with write permission

	try

		write thetext to f_ref

	on error

		close access f_ref

	end try

	close access f_ref

end tell

This topic is 6927 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.