A clever way to increasing productivity

This is a discussion on A clever way to increasing productivity within the Linux Programming forums, part of the Platform Specific Boards category; I need a program that will replace a word, lets call it "joe" with any word I tell it to, ...

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    106

    A clever way to increasing productivity

    I need a program that will replace a word, lets call it "joe" with any word I tell it to, say "mike". The reason is because I've just creative a massive function that I need to have duplicated about 5 times, with very minor changes. I need a program that will scan the file and make theses changes accordingly. Is such a program available? I could justs make this program myself but perhaps it is not worth it (time wise). These functions in question are ~500 lines long.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,333
    > The reason is because I've just creative a massive function that I need to have duplicated about 5 times, with very minor changes.
    That sounds like the change should become a parameter to the function, so you only have ONE copy of it to maintain in future.
    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.

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    I wonder what kind of editor you are using that doesn't have search and replace.

    Anyway, if somehow in your circumstances this turns out to be a good idea to have five functions (I can't imagine what those circumstances could be) and you don't have search and replace (I mean, even vi has search and replace) then I guess you want sed. I guess.

  4. #4
    Registered User
    Join Date
    Jun 2008
    Posts
    106
    one function compares two files for max values, the other compares for minimum values, so the ">" change, also some var names.

    Cool, SciTE has it.

  5. #5
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    you can pass the comparison function to the function as well as the other parameters. Having to copy and paste code is a sign of poor design.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with Dynamically Increasing Array of Integers
    By laserlight in forum C++ Programming
    Replies: 30
    Last Post: 07-04-2008, 07:27 AM
  2. increasing series
    By ronenk in forum C Programming
    Replies: 3
    Last Post: 07-21-2004, 02:45 AM
  3. C# and productivity.
    By incognito in forum C# Programming
    Replies: 4
    Last Post: 06-23-2004, 07:08 AM
  4. increasing chance.
    By davee in forum C++ Programming
    Replies: 5
    Last Post: 10-23-2002, 12:32 AM
  5. Replies: 2
    Last Post: 03-07-2002, 09:14 AM

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