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

CRFL write to file

Featured Replies

Hi all,

I have the same problem as a previous post in 2010 (archived since).

"I am using the WriteToFile function in ScriptMaster v3.33 with FM 10 Adv on Windows. I want to create a plain ASCII text file with CR/LF as the end of line characters.

First I put my text field into a local variable $text and replace all CR with CR/LF using:

Substitute( $text; [Char( 11); ""]; [ Char( 13); Char( 13) & Char (10)] )

Then I use WriteToFile to create the file.

I have tried several character encodings when I register the WriteToFile function (ASCII, utf-8) but they replace my CR/LF with LF. I tried to specify MS-DOS but that encoding is not supported.

Does anyone know what character encoding I can use? Or a simple trick to preserve the CR/LF?

Thanks -- Mark

"

It was proposed to register a new groovy function which seemed to work.

RegisterGroovy( "WriteToFileWithCarriageReturns( filePath ; textToWrite )" ; "//This simple version uses utf-8¶

//new File( filePath ).write( textToWrite );¶

//This more advanced version allows you to specify the character encoding¶

OutputStreamWriter writer = new OutputStreamWriter( new FileOutputStream( filePath ), "utf-8" );¶

writer.write( textToWrite.replace("n", "rn") );¶

writer.close();¶

return true;" )

But I have FM12 and Windows 7 - it doesn't accept this function because of

"utf-8" and if I write \"utf-8\" it then says that there is a problem with ("n", "rn")

Can anybody help me please? Thanks

I

You dont need to do that subtitute in FM

In ScriptMaster it should be


textToWrite.replace('n' , 'rn')

You are not replacing n with rn as in orange >> ornange

The "" character is required to escape the new line and carriage return characters.

You could also try 'iso-8859-1' as the encoding

In Groovy (in most cases) you can use ' instead of " as it then means it is easier when it gets into FM to debug as there are not lots of " sitting in the middle of the function

  • Author

Thanks a lot, it works perfectly! :laugh2:

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.