Converts text formatted in the internal FileMaker format to text formatted in the format of the current operating system running on this computer. On Windows the High ASCII characters (128-255) are not the same as stored internally in FileMaker.
TrFile_ConvertFromFMText ( switches ; text )
|switches||reserved for future use, leave empty or set to "-Unused"|
|text||the text in internal FileMaker format|
Data type returned
The text in the native format of the operating system of this computer. This will be Windows format on Windows and macOS format on macOS.
Troi File Plug-in 2.0
FileMaker Pro 16 to 19
NOTE Function not recommended, only for compatibility with older plug-in scripts.
Please use the “-Encoding=xxx” switches of TrFile_AppendContents and TrFile_SetContents instead. This function also converts line endings. In the internal FileMaker format (and on Mac) lines end with a single <CR> character. On Windows this function will replace all CR’s to the normal line ending on Windows, the two characters <CR><LF>.
Assume that on Windows we want to create the file “HighText.Doc”, which contains the text “Bjørn, <CR><LF>Münchenstraße 2”. Add this script step:
Set Field [ result ; TrFile_ConvertFromFMText ( "-Unused" ; "Bjørn, ¶Münchenstraße 2" ) ]
The result will look like:
This may look wrong, but when you use for example the TrFile_SetContents function it will appear correct in the file.
We assume that in your FileMaker file the following fields are defined:
contents text gErrorCode Global, number gOutputFile Global, text gContentsConverted Global, text
gOutputFile should contain the path to a non-existing file, for example “D:\Out.txt” (Windows) or “Mac HD:Out.txt” (Mac). In a script add the following script steps:
Set Field [ gContentsConverted ; TrFile_ConvertFromFMText ( "-Unused" ; contents ) ] # now gContentsConverted is in the format of the operating system Set Field [ gErrorCode ; TrFile_CreateFile ( "-Unused" ; gOutputFile ) ] Set Field [ gErrorCode ; TrFile_SetDefaultFileSpec ( "-Unused" ; gOutputFile) ] If [ gErrorCode = 0 ] Set Field [ gErrorCode ; TrFile_SetContents ( "-Unused" ; gContentsConverted ) ] End If
This will get the contents of the contents field into the file. In the first step the high ASCII characters will be converted from the internal FileMaker format. This will work transparent on both macOS and Windows.