Changing Text in Files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vninja
    New Member
    • Oct 2006
    • 40

    Changing Text in Files

    Hi, i'm totally lost.

    Im trying to create a program that reads a file and then changes some text in the file. i've got a couple approaches to this problem but i cannot find the resources nessesary for me to complete any of these. if anyone could help i'd greatly appriciate it.

    So these are the challenges:
    I:
    Read from text file
    search for specific words
    replace (delete then add, etc.)
    close file
    send file to printer.

    II:
    open file
    write the text to file including printer escape codes to bold and change txt
    size and maybe txt font
    close file
    send file to printer

    III:
    open to suggestions on other approaches to this problem.

    I found out how to open, close, write to, and print file but i cannoth find how to replace words.
    the codes that i am finding on how to seek for txt i don't quite understand. if anyone could send an example i'd appriciate the help

    Thx
    V
  • vninja
    New Member
    • Oct 2006
    • 40

    #2
    Ok i figured out one part (which i can't believe my idioticy) for the text formatting. a simple approach of using html instead of txt file and using the html tags to format the txt for me. but now i need to know how to print the file ny1 any suggestions?

    Comment

    • Banfa
      Recognized Expert Expert
      • Feb 2006
      • 9067

      #3
      The problem in part II is that as stated you would need to know what the printer was as not all printers talk the same language.

      Comment

      • vninja
        New Member
        • Oct 2006
        • 40

        #4
        Thanks that just totally sux. but isn't that why there are drivers to convert from comp lang to print lang? just wondering. i realized that its on a network under a static i.p. and its some kind of HP laser if thats not too vague

        Comment

        • Banfa
          Recognized Expert Expert
          • Feb 2006
          • 9067

          #5
          Oh there is (in Windows anyway but I would assume Linux has a way as well).

          You create a printer DC (device context) and draw to that device context, then windows , the HAL and the printer driver sort out the actual printing.

          It is however quite involved.

          So you can just send the file to the printer you have to draw data on the printer device context.

          Alternitively if the file is a text file or some other file with a recognised extension you can cheat and have Notepad do it for you by

          ShellExecute(NU LL, "print", <FileName>, NULL, NULL, 0);

          Comment

          Working...