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.

Converting Carriage Returns

Featured Replies

Hello,

I am trying to use an AppleScript from within FileMaker to copy a shipping address to a program called Endicia, which prints mailing labels and postage. The AppleScript works fine, except the address in Endicia doesn't handle the carriage returns properly (see attachment).

What can I do to convert the carriage returns (which are ASCII 13 I think)? Do I need to convert them to ASCII 10 (LF)?

Regards,

Sean Mills

endicia_line_breaks.jpg

  • Author

Hi Fenton,

Thanks for pointing me in the right direction. I tried your suggestion, but I still got the same result, so after thinking some more, I tried the following:

1) Before calling the AppleScript from within ScriptMaker, I substituted the carriage returns in the shipping address with the text ""

2) In the AppleScript, instead of first setting the delimiters to ASCII character 13, I set them to ""

That worked, although I'm still puzzled why first setting the delimiters to ASCII character 13 didn't work.

Regards,

Sean

I deleted my earlier post. Because you're right, and I should have remembered this. FileMaker's internal "returns" in a text field are actually ASCII 11. The reason my earlier example worked, when you wrote to a file, was because shell scripts translate to Mac returns for you when they write the file, at least when you use "echo." That's why I prefer to use them when writing files from FileMaker text.

AppleScript's write command does NOT translate line endings. You get what you got, which is ASCII 11. I imagine if you're passing the AppleScript text to another app you also get ASCII 11. So we'd need to use that instead of ASCII 13 in our find/replace. Like this (the output path and writing the file is not what you need, but it's so others can see the result).

set outputFile to (((path to desktop) as text) & "UnixText.txt") as file specification



--tell application "FileMaker Pro Advanced"

	set txt to cell "_cAddress" of current record as text

--end tell



tell application "Finder" -- needed inside FileMaker	

	try

		set AppleScript's text item delimiters to {ASCII character 11}

		set textList to text items of txt

		set AppleScript's text item delimiters to {ASCII character 10}

		set newTxt to (textList as text)

	on error errMess number errNum

		set AppleScript's text item delimiters to ""

	end try

	set AppleScript's text item delimiters to ""

	

	open for access outputFile with write permission

	set eof of outputFile to 0

	write newTxt to outputFile starting at eof

	close access outputFile	

end tell

  • Author

FWIW, I tried your updated script, but I still got the same results as seen in the screenshot, so I reverted to my workaround. I'm still puzzled LOL.

All I'm doing is a glorified copy-and-paste. I'm not creating any text files.

  • 3 weeks later...

I use Endicia to print about 30,000 labels a year out of FMP. I guess I'm wondering why the Applescript? Why not export directly to Endicia via XML? No workarounds necessary there. Look up the threads on Endicia here--my questions and those of a few others were met with help galore.

John

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.