© Matti Mattila, CPFA, CISA, CIA

TexEdiMac: Add CR to a Text File (lacking it)

Previous item Next item Previous menu
Test Design
Picture 1
- Picture 1 a file (source file) is shown that will be used in demonstrating 'Add CR to a Text File'-functionality (lacking it) of 'TexEdiMac' (later renamed as 'TexEdi') macro. CR, short for Carrige Return, is a character that makes a text line end.
- Expected lines are here one after another. First line should be '001ABC3301225KENG' (only). Six first characters of each line appear in red.
Running the macro
- The easiest way to run the macro is pressing simultaneously Ctrl + Shift + 't'.
Picture 2
Picture 5
Picture 7
- At the beginning of the run the macro shows the user the form in picture 2. Select 'Add CR to Text File (lacking it)' on it.
- You will see information what the macro does (picture 2a: [1]). Read the it, and proceed by clicking 'Yes' in order to proceed.
- You will be asked to select a file, where to remove carrige returns (CRs). Please, click 'Yes' ('Kyllä' = 'Yes' in picture 3).
Picture 3
Picture 4
- We browse in order to find the source file, which is 'test.txt' in this case. The file is located in a folder 'AddCarRet' (picture 4). We select the file.
- The macro suggests a name to the new file: the body of the name of the source file, with a bit different extension ('tx9 in stead on 'txt' in the example).
On the form (picture 5), where the file name was suggested, you can change the extension of the [resulting] new file, if you do not want it to be 'tx9'. You do not need to write anything in the box 'File extension is stead of 'tx9'' when you decide to use extension 'tx9' [2].
- The macro will inform, what will be the path and name of the resulting file (not shown in pictures; it would be: 'D:/AddCarRet/test.tx9').
- The macro asks to build a mask for identification of [the beginning] of a new source text line (picture 6).
Picture 6
- Make a mask using numbers as such (0 .. 9) or generally (N), hyphen (-), space (marked as _), any alphabet (C) [3], or any character (?). You can leave CR in lines shorter than what you specify. Through the mask in picture 6 [00N?CCN][4] lines are identified, when there is in the text "00", followed by any character, followed by two alphabets, and a number.
- In the end of the macro tells the number of lines in the new file [5] .
The new text file
- In picture 7 we can see the file that resulted from then run. The run was successful; the objective was achieved. One long source file line was divided into eight separate lines.

[1] Text (to the left) on "Guidance" worksheet of 'TexEdiMac.xls': what the macro does.
Picture 2a
[2] The macro does not use special characters in an extension.
[3] The macro identifies also special Nordic characters [å; Å; ä; Ä; ö; Ö].
[1] For the purpose of wider validity test in the example we used a mask more complicated than it needs to be; mask '001C' would give right results as well.
[5] Picture 6a