Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Cannot write data to text file

Featured Replies

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

  • Author

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

  • Author

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

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...

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

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...

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

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

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.