TrFile_ConvertToFMText |
Converts text formatted in the format of the current operating system running on this computer to text formatted in the internal FileMaker format. On Windows the High ASCII characters (128-255) are not the same as stored internally in FileMaker.
Syntax
TrFile_ConvertToFMText ( switches ; text )
Parameters
switches | reserved for future use, leave empty or set to "-Unused" |
text | 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 |
Returned Result
Data type returned
Text
Result
The text in internal FileMaker format.
Originated in
Troi File Plug-in 2.0
Compatibility
FileMaker Pro 17 to FileMaker Pro 21 (2024)
Considerations
NOTE Function not recommended, only for compatbility with older plug-in scripts.
Use the “-Encoding=xxx” switches of TrFile_AppendContents and TrFile_SetContents instead. This function also converts line endings to the internal format. On Windows lines end with the two ASCII characters <CR><LF>. This is converted to the single character <CR> as used by the internal FileMaker format.
Example
Assume that on Windows we have the file “HighText.Doc”, which contains the text “Bjørn, <CR><LF>Münchenstraße 2”. Add this script step:
Set Field [ result; TrFile_ConvertToFMText ( "-Unused" ;
TrFile_GetContents ( "-Unused" ; "C:\HighText.Doc" ) ) ]
This will store the contents of the “HighText.Doc” in the result field, with the high ASCII characters converted to the internal FileMaker format. In the result field this will look like this:
Bjørn, ¶
Münchenstraße 2
Example 2
We assume that in your FileMaker file the following fields are defined:
contents text
gFileSpec Global, text
gFileSpec should contain the path to an existing file, for example “D:\Readme.txt” (Windows) or “Mac HD:Readme.txt” (Mac). In a script add the following script step:
Set Field [ contents ; TrFile_GetContents ( "-Unused" ; gFileSpec ) ]
# Now the contents field is in the format of the operating system
Set Field [ contents ; TrFile_ConvertToFMText ( "-Unused" ; contents ) ]
This will get the contents of the file into the contents field. In the second step the high ASCII characters will be converted to the internal FileMaker format. This will work transparent on both macOS and Windows.
Related functions
TrFile_ConvertFromFMText |
TrFile_GetContents |
Related topics
Troi File Plug-in online help (overview)