FILEFLEX API REFERENCE



NAME
DBConvertCRLF -- Convert platform-specific end-of-lines

SYNTAX
DBConvertCRLF(data [, "A" | "M" | "W"])

CATEGORY
Retrieving Information

DESCRIPTION

There is actually only one significant cross platform consideration that you need to worry about other than your own personal religious operating system preferences. That concern is line termination in text and how it differs between operating systems. Briefly, the Macintosh terminates each line with a newline, and under Windows the convention is that each line is terminated with a carriage return and line feed. This doesn't become an issue in data storage in FileFlex except in memo fields which have hard carriage returns.

In fact, this actually isn't a consideration if you are moving data only inside of Director, because Director on both Macintosh and Windows uses the Macintosh format newline end of line character on both environments. As a result, if you write something that you store into a memo field in FileFlex on the Macintosh and you move it over to Windows and you run it in Director under Windows with FileFlex for Windows you will be able to read that memo field with no discernible difference.

The place where there is some concern is bringing in externally created DBF data files. This would happen, for example, if you created a data file in FoxPro under Windows and in the memo field had a number of carriage returns that were hard typed into the memo field. When you read that data in FileFlex and you moved it into Director, Director would have some ugly characters dropped into place, because Director would be looking for Mac formatted text data and FileFlex would have delivered the PC formatted data instead. Obviously, the same is true if you take data that you store in FileFlex that you want to read in FoxPro, FoxPro would get confused because it would have new lines, but not carriage returns.

To get around this problem, FileFlex, both on the Macintosh and in Windows, has a data file function called DBConvertCRLF. The purpose of DBConvertCRLF is to take a chunk of Macintosh text and convert it to a format that external Windows environment tools would expect, or take a chunk that comes from an external Windows format tool, and convert it to a form that would be suitable for use in the Macintosh. This applies to users who aren't even doing cross platform development, but who simply want to read PC data files that have memo fields. Now you can read a PC format data file with the memo field. You can read that data into a variable, you can run it through DBConvertCRLF, and out the other end will come a memo field that you can be comfortable displaying in a field on either a HyperCard stack or a Director project or whatever. Then, you can go the reverse. You can make your changes and you can send it back through DBConvertCRLF and store it back out to a file so that PC users can understand it without needing weird conversions.

The Macintosh terminates each line with a newline, and under Windows the convention is that each line is terminated with a carriage return and line feed. If you use memo fields, you may need to be aware of this.

DBConvertCRLF is important when you're reading DBF files created outside of the "protected" Director environment (see the note below). DBConvertCRLF takes a container (a variable or a field) and converts the end-of-line characters according to the option parameter.

If there is no option parameter (or the option parameter is set to "A" for "Automatic"), DBConvertCRLF converts the data into a form appropriate for the currently executing platform. If the option parameter is set to "M" (for Macintosh), DBConvertCRLF converts the data into newline-terminated lines for use on the Macintosh. If the option parameter is set to "W" (for Windows), DBConvertCRLF converts the data into carriage-return-line-feed-terminated lines for use in Windows.


NOTES
Director on both Macintosh and Windows uses the Macintosh format newline end of line character on both environments. As a result, if you write something that you store into a memo field in FileFlex on the Macintosh and you move it over to Windows and you run it in Director under Windows with FileFlex for Windows you will be able to read that memo field with no discernible difference.

EXAMPLE
put DBConvertCRLF(myMemo, "M") into macMemo

INTERNAL FUNCTION NUMBER
41


Copyright © 1992-1998 by David Gewirtz, under license to Component Enterprises, Inc.
Contact: info@component-net.com

Casa de Bender