Is program salvageable?

This is a discussion on Is program salvageable? within the C++ Programming forums, part of the General Programming Boards category; In 1990, I designed a small calculator-like program written for DOS. A friend, who has passed away, coded it in ...

  1. #1
    Registered User
    Join Date
    May 2007
    Posts
    8

    Is program salvageable?

    In 1990, I designed a small calculator-like program written for DOS. A friend, who has passed away, coded it in C++. I have the complete source code for it with these exceptions. Let me add I know absolutely nothing about C++ other than I can spell "compilor" (just kidding). I do know the source code contains only one *.h (header?) file which begins with

    #include <stdio.h>
    #include <cwuser.h>
    #include <cwdos.h>
    #include <cwform.h>
    #include <cwarch.h>

    The five files I do not have. I know the stdio.h file is available but I can find no reference to any of the "cw" files.

    I want to upgrade my program to Windows interface (I hope you understand what I want to do since I don't know the correct terminology) and make some minor "label" like changes and perhaps, rearrange or remove certain modules, such as remove the "Length Calculator module" and the like.

    Am I out of luck without those four files?

    Thank you very very much for your expertise.

  2. #2
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,475
    dos.h is an old header that compilers like turbo C++ would have in their library. I have never seen cw before but can only assume it was included with sperfic compiler the original code was created on. The only way you can do this is move the code into a newer stable editor with a modern compiler and find somway of ironing out the errors you will get from uncreconisable header files. No easy task.

    Im sure sombody here will be able to highlight for you what the cw is, It looks very pre-standard, stdio.h is a C header file.
    I'm just trying to be a better person - My Name Is Earl

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,532
    The first step would be to create a console project in your new compiler (have you got one in mind?), and add the source file(s) to that project.

    Then comment out those 4 'cw' files and see what complains. That will give you some idea as to how much work is involved. You'll just end up with a list of 'undeclared' and 'unresolved' error messages.

    TBH, converting a 15+ year old DOS program into an up to date windows GUI program is going to be hard. Anything dealing with input or output is pretty much scrap code. Whether anything is re-usable depends on how well the original classes were specified and implemented. If the core classes of the calculator are free of any input and output dependency, then you'll have a chance.

    To actually make it look like a windows program, it's probably better to start from your design. The C++ language itself has moved on, so what C++ may be re-usable might not be that 'good' C++.

    Plus if the program uses lots of memory allocation, DOS programs tended to be full of lots of horrid kludges to work around the 64K segment limit. Large memory blocks simply are not an issue for today's platforms.

    > #include <stdio.h>
    This is a C header file, yet you say C++ ?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    May 2007
    Posts
    147
    Maybe.....

    By chance are the initials of the original author cw?

    Not that cw is of any significance in finding or recreating them. Just curious.

    It may be possible to reconstruct the contents of those headers by a bit of deduction. If one commented these includes out of the compilation, the compiler would complain about functions without a declaration, access to member variables without declaration, and it's probably that these could be used to reconstruct these declarations. Part of this depends on how much the author used inline function in those files, or if there are any template classes in those files.

    This would, however, require a fairly knowledgeable C++ programmer - not necessarily an expert, just someone experienced enough to interpret the compiler complains and generate the required declarations.

    You could get a fair headstart, too. Depending on the complexity of the application, it may be workable to skim through the source to identify class names obviously referenced as member functions for which there are no class declarations, and fill that out first. This would go a long ways toward the reconstruction. A compiler pass would then pick up any member variables referenced that are missing, completing the major portion of the work. After that, depending on what complaints remain, various judgment calls to make about possibly missing inline functions.

    This could be obviated, however, by your intent to translate the work into a GUI application. If you could deduce, by reading the code, that important features were implemented as member functions, and are therefore present in the CPP files you have, you could treat that a body of functions to be applied to a new design. Redesign the user interface, interpreted as a GUI interface, and apply these functions to that design - a two for one kind of approach (reconstruction and translation into GUI). This would require a more expert programmer.

  5. #5
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,475
    Just found out

    cw means "child widget tree"

    Used google as I wamted to know!
    Last edited by swgh; 05-21-2007 at 04:30 PM. Reason: Google
    I'm just trying to be a better person - My Name Is Earl

  6. #6
    Registered User
    Join Date
    May 2007
    Posts
    8
    You are all wonderful! Thank you very much. I didn't expect such a quick and thorough reply. It seems most of what was said is way over my head (I did get a grasp of the concepts, though).

    It would seem better that I try another approach. Now, if I had all the *.c files...and a working copy of a relatively small program that's really comprised of about 7 very small routines (modules), would anyone care to speculate what it'd cost to accomplish my goal. I realize that's impossible to really answer so let me ask: Under $1500 (I"m hoping I hear under 1k)?

    The next step, depending on your input, would be to post my request in the "hire" forum.

    Thanks, again.

  7. #7
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,475
    Well you can "rent-a-coder" from the web. Google it and see what you get, They all vary in prices.
    I'm just trying to be a better person - My Name Is Earl

  8. #8
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    If the project isn't that big, it shouldn't take more than a few hundred USD if you want to hire someone to do it.

  9. #9
    Registered User
    Join Date
    May 2007
    Posts
    8
    I was almost afraiid to check back after realizing what a stupid question I asked. MacGyver, your reply was quite encouraging. I've been in contact with an outsourcing company in India and they want to charge $1300 to replicate a single module of the program based on 240 hours of programming. That seemed outrageous, but since I'm not a programmer, I couldn't tell for sure.

    I'm baffled by the missing *.h files I mentioned in the beginning. My friend who coded the program told me he gave me everything I needed, except a compiler, to modify it in the future.

    I gotta check what "child widget" is...

  10. #10
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,805
    Really if you think about it that is only 5.41/hr which is a good deal as far a labor is concered, but regardless of the fact, what is your ultimate goal here. Do you just want to reproduce the program because in that case, just run it and start fresh with what it looks like and does. If you don't want to do that and get the old code working that may be harder without knowing what compiler was used.
    Woop?

  11. #11
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    The header files might have come with the compiler, so that's probably why your friend stated he gave you everything but the compiler.

    My estimate could be quite off the mark. It depends upon how much work is involved, which depends upon how much of the code can be salvaged, etc. etc..

  12. #12
    Registered User
    Join Date
    May 2007
    Posts
    8
    I agree the rate is good. The total hours seem excessive. Salem and swgh mentioned stdio.h is a C header, not C++. Gulp...I thought the program was written in C++ but I don't have a clue. Here's a small piece of a file:


    Code:
    #include <dir.h>
    #include <stdio.h>
    #include "ac.h"
    
    
    //#include <sys$msg.mlh>
    //#include <sys$err.elh>
    
    
    char *buffer;
    
    extern LIBRARY_INFO *library;
    
    
    char *ReadFile(char *fileName)
    {
       FILE *fp;
       int blocksRead;
       char *workBuffer;
       struct ffblk rfile;
    
       if (findfirst(fileName, &rfile, 0xff)) {
          DisplayErrorText(E_MISSING_FILE, WARNING, fileName);
          return(NULL);
       }
    
       fp = fopen(fileName, "r");
       if (fp == NULL) {
          DisplayErrorText(E_BAD_OPEN_READ, WARNING, fileName);
          return(NULL);
       }
    
       if (rfile.ff_fsize >= (long)(MAXBUFFER_SIZE)) {
          DisplayErrorText(E_2BIG2VIEW, WARNING, fileName);
          if (fclose(fp)==EOF) 
             DisplayErrorText(E_FILE_CLOSE, WARNING, fileName);
          return(NULL);
       }
    C or C++??

  13. #13
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    That's C code.

  14. #14
    Registered User
    Join Date
    May 2007
    Posts
    8
    OOPS. Now I know why the two dudes with the Fedoras and trenchcoats just showed up at my front door.

    Aside from me moving this out of this forum, does that change the overall picture of my original objective?

    Thank you for point out my studipity. But, I have an excuse: I was born confused....and it's only gotten worse...

  15. #15
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Not really much has changed. As Salem said, the input and output will probably have to be rewritten anyway for Windows.

    The code snippet looks very well written with regard to today's standards, so you might be able to salvage a lot of it. I would say you might have a slightly easier time than previously thought.

    BTW, if you haven't already, please check your PMs.
    Last edited by MacGyver; 05-21-2007 at 10:47 PM.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 12:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 12:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 09:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21