APPLICATION NOTE #147 SEARCHING FOR LINE ENDING CHARACTERS IN IMPORTED FILES Rev. 01 RELATED FILES: FIXCR.EXE Many files imported from other systems use different line ending characters than XyWrite does. Occasionally you may want to search for or change the line ending characters in your imported file to be compatible with XyWrite; for example, to prepare the imported file for printing. This application note provides two useful illustrations: * Searching manually for a line feed character * Writing a program to change line feed characters in an imported file to spaces Although XyWrite carriage returns are reprented on the screen as a single character ({ASC-27}), they are actually stored internally in a set as carriage return and line feed. You may experience problems with files created using other software products, because they use different line ending characters (for example, a line feed character to indicate a soft return (wordwrap) and a carriage return character to indicate a hard return (carriage return)). XyWrite cannot recognize these two characters separately. Therefore, you may need to search for these characters and change them. Line feeds are represented by an ASCII 10 character ({ASC-10}) and carriage returns are represented by an ASCII 13 character ({ASC-13}). You search for or change these special characters by copying the character from the ASCII Help screen into the command string (between the delimiters). The Alt Shift method of entering these characters does not work with Search or Change commands because of the way XyWrite stores them internally. XyWrite's FIXCR program (described in Application Note #119, "Converting Line Endings,") eliminates all isolated line feeds, and converts isolated carriage returns and line feed-carriage return combinations into carriage return-line feed combinations. This application note addresses situations not handled by FIXCR, such as converting files that use the carriage return-line feed combinations to represent hard returns, and isolated line feed characters to represent soft returns. Rather than remove the isolated line feed characters, the procedure described below changes them to spaces. The rest of this application note describes the procedures for searching manually for a line feed character and for writing a program to change a line feed character in an imported file to a space. Before you start either procedure, find out what kind of line ending characters are used in your imported file to indicate hard and soft returns. If necessary, you can modify these procedures to search for other line ending characters. SEARCHING FOR SPECIAL CHARACTERS MANUALLY The following procedure illustrates the way to search manually for the line feed character in your file and assumes you have loaded either LONG.HLP or SHORT.HLP: 1. Type: F5 se / 2. Access Help. Press: Alt-F9 The Help screen menu appears on the screen. 3. Display the ASCII Help screen. Type: a 4. Display the Special ASCII Help screen. Type: s 5. Move the cursor right nine spaces to position it on the ASCII 10 character ({ASC-10}), which represents a line feed. Press: {cursor right} (nine times) 6. Include the ASCII 10 character in the command line. Press: 7. Exit Help. Press: Alt-F9 8. Enter the second separator for the Search command and execute it. Type: / Result: The search begins at the cursor location and searches forward, stopping to the right of the first occurrence of a line feed. You can create a program that performs the procedure described above. Refer to Chapter 5 of the XyWrite Reference Guide for information on creating XyWrite program files. USING A PROGRAM TO CHANGE LINE FEEDS TO SPACES The following procedure illustrates creating a program to change line feed characters to spaces. The program assumes the imported file uses the carriage return-line feed combination to indicate hard returns, but uses the line feed character to indicate a soft return. The program protects the carriage return-line feed combination by changing it to a unique character before changing all the line feeds to spaces. If the program simply changed all line feed characters to spaces, the carriage return-line feed combination would be destroyed internally. After the line feeds are converted to spaces, the program changes the unique characters back to carriage return-line feeds. The program also assumes either LONG.HLP or SHORT.HLP has been loaded. 1. Create a program file. Type: F5nep change Press: Scroll Lock 2. Include a Change Invisible command that changes [ASC-27} to some character or string of characters that does not normally appear in your files. This example program uses CRLF, but you can use any characters unique to your files. Press: F5 Type: ci / Press: Ctrl Type: /crlf/ Press: F9 3. Include another Change Invisible command that changes the line feed characters ({ASC-10}) to spaces. You include in the program the necessary steps to copy the {ASC-10} from the ASCII Special Help screen. Press: F5 Type: ci / Press: Alt-F9 Type: a Type: s Press: {cursor right} (9 times) Press: Press: Alt-F9 Type: / Press: Space Bar once Type: / Press: F9 4. Include another Change Invisible command to change the unique character or string of characters back to {ASC-27}. The example program uses CRLF, but you should use whatever characters you used in step 2. Press: F5 Type: ci /crlf/ Press: Ctrl Type: / Press: F9 5. Turn off the record mode. Press: Scroll Lock The program looks like this: BC ci /{ASC-10}/crlf/XC BC ci /SH asCR CR CR CR CR CR CR CR CR ÿ0DSH / /XC BC ci /crlf/{ASC-10}/XC Result: You have created a program you can run whenever you want to change line feed characters to spaces in an imported file. TIP There are a few other ASCII characters that XyWrite interprets in a special manner, such as the mathematical symbol for square (2). Technical Support can tell you what these other characters are. Remember, always copy the special ASCII character from the Help screen into the command line rather than using the Alt-Shift method.