Jump to content
Server Maintenance This Week. ×

Converting Carriage Returns


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

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 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

Link to comment
Share on other sites

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