<!-- Download Links -->
<!-- Add the rest of your HTML here -->
This trivial program may be of use to some folks. My company, along with a few hundred others, use a POS program for running the retail business. By design, all reports from this program display negative values with a trailing minus sign. Oddly, most of these companies also use Excel, which refuses to recognize this format when importing a CSV text file from the POS program. This simple utility opens a text file, scans it line by line, and builds a new text file with all the trailing minus signs replaced by leading minus signs. The format is otherwise unchanged.
Usage is simple:
Convert.exe srcfile destfile
Where the source and destination files are fully specified paths. If the destfile doesn't exist, it will be created; if it does, it will be overwritten. There is one known flaw - if a number is in the first position of any line, it will not be converted. Since this never occurs in any report from the POS software, I didn't bother to fix it, but it should be a simple matter if you need that capability.
Operation is simple. As each line is read, it is examined character by character. When a minus is found, a second loop starts backtracking within the line to the first non-numeric character before the minus sign. It then deletes the original minus and inserts one after the non-numeric character, then resumes the scan. When the scan is complete, the line is written to the destfile and another line is read. During the backtracking process, a decimal point is counted as a numeric, as most of the values encountered are currency values.
There are no code examples included here, as there is nothing particularly interesting in the program. It may, though, be just the thing for certain applications. A know several companies are now enjoying it...