Click here to Skip to main content
15,867,330 members
Articles / Desktop Programming / MFC
Article

Convert.exe

Rate me:
Please Sign up or sign in to vote.
4.79/5 (17 votes)
2 Jan 2002CPOL2 min read 140.2K   2K   11   25
A Utility to converter negative values displayed with trailing minus to a leading minus format

Introduction

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...

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer Retired
United States United States
BS Electrical & Electronics Engineering

Thirteen years experience designing & programming measurement & control instrumentation.

Retired two years ago from the Tribal Utility I was working for, designing power, water, and sewer systems for the reservation, and managing the construction and maintenance of same. Now working as a gun salesman and smith, as well as doing metal machining and welding for fun and too little profit.I recently bought 20 acres of land, and a tractor to help me develop it into a homesite and ranch. I was planning to raise lobsters, but having seen frozen rabbits on Amazon selling for $49 each, I may have to replan.

Programming experience using assembly, FORTRAN, BASIC, HP JCL, Prolog, Ada, Pascal, hpl, ; currently learning VC# and having "fun" with ASP.Net.

Avid darts player, though not a good one... Fair to excellent 12-string guitar player, depending on who you ask. Spare time spent fishing, reading, and playing with the neighbor's cat (see picture). Second degree black belts in Hapkido and Taekwondo.

Past President of the local Kiwanis Club, past Director of the United Way, and no longer a member of either.

Have held licenses as a Real Estate broker and Securities dealer - once ordained as a minister on a whim. My latest certificate was earned without any hands on experience at all - Yamaha Certified 5-Star Technician for motorcycles, ATVs, and watercraft. What next?

Raised in sunny California, before it became the Peoples' Republic of California. Relocated to Arizona to escape being homeless after peace broke out.


Objective: To learn all there is to know. I know I'll be disappointed one day, but I've made a good start, and the eventual disappointment is likely to be brief.


Comments and Discussions

 
Questionbudget allocation and expenses programmed in excel sheet Pin
maheshba797-Jul-10 1:40
maheshba797-Jul-10 1:40 
AnswerRe: budget allocation and expenses programmed in excel sheet Pin
Christian Graus7-Jul-10 15:35
protectorChristian Graus7-Jul-10 15:35 
AnswerRe: budget allocation and expenses programmed in excel sheet Pin
Roger Wright7-Jul-10 17:32
professionalRoger Wright7-Jul-10 17:32 
AnswerRe: budget allocation and expenses programmed in excel sheet Pin
#realJSOP7-Jul-10 23:31
mve#realJSOP7-Jul-10 23:31 
GeneralGOOD ARTICLE Pin
MrGoodly5-Jan-07 8:34
MrGoodly5-Jan-07 8:34 
Generalpasswor protection Pin
27-May-02 2:19
suss27-May-02 2:19 
QuestionHow can you see the difference between two lines? Pin
4-Jan-02 6:45
suss4-Jan-02 6:45 
AnswerRe: How can you see the difference between two lines? Pin
Roger Wright27-May-02 2:30
professionalRoger Wright27-May-02 2:30 
GeneralIt does what it has to do Pin
S van Leent4-Jan-02 3:10
S van Leent4-Jan-02 3:10 
QuestionWhat is the point ???? Pin
Christian Graus3-Jan-02 12:57
protectorChristian Graus3-Jan-02 12:57 
AnswerRe: What is the point ???? Pin
Nish Nishant3-Jan-02 14:34
sitebuilderNish Nishant3-Jan-02 14:34 
GeneralRe: What is the point ???? Pin
Christian Graus3-Jan-02 14:41
protectorChristian Graus3-Jan-02 14:41 
GeneralRe: What is the point ???? Pin
Nish Nishant3-Jan-02 16:04
sitebuilderNish Nishant3-Jan-02 16:04 
AnswerRe: What is the point ???? Pin
Roger Wright (new)3-Jan-02 19:33
Roger Wright (new)3-Jan-02 19:33 
GeneralRe: What is the point ???? Pin
Rick York3-Jan-02 20:17
mveRick York3-Jan-02 20:17 
GeneralRe: What is the point ???? Pin
Nish Nishant3-Jan-02 20:50
sitebuilderNish Nishant3-Jan-02 20:50 
GeneralRe: What is the point ???? Pin
Nish Nishant3-Jan-02 20:51
sitebuilderNish Nishant3-Jan-02 20:51 
GeneralRe: What is the point ???? Pin
Roger Wright (new)4-Jan-02 4:45
Roger Wright (new)4-Jan-02 4:45 
GeneralRe: What is the point ???? Pin
Nish Nishant6-Jan-02 17:54
sitebuilderNish Nishant6-Jan-02 17:54 
GeneralRe: What is the point ???? Pin
Roger Wright (new)6-Jan-02 19:12
Roger Wright (new)6-Jan-02 19:12 
GeneralRe: What is the point ???? Pin
Nish Nishant6-Jan-02 19:23
sitebuilderNish Nishant6-Jan-02 19:23 
AnswerRe: What is the point ???? Pin
3-Jan-02 23:10
suss3-Jan-02 23:10 
AnswerRe: What is the point ???? Pin
4-Jan-02 7:00
suss4-Jan-02 7:00 
GeneralRe: What is the point ???? Pin
David Wulff4-Jan-02 15:58
David Wulff4-Jan-02 15:58 
AnswerRe: What is the point ???? Pin
Bill Leibold5-Jan-02 15:03
Bill Leibold5-Jan-02 15:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.