Thread: need to edit text from within my application.

  1. #1
    Registered User
    Join Date
    Dec 2006

    need to edit text from within my application.

    OK, I'm writing a little app that will edit a configuration file for the end user. I've written the GUI, as well as most of the other outlying code.

    The problem is the core of my application -- the ability to either copy text to a buffer, edit certain parts of it, and write it to a new file -- or copy each line of text to a separate variable, then edit each variable separately (if at all), and then write all the variables, in order, back to a new file.

    Memory is not an issue here -- if your running the application which uses the config file, you have enough memory (application in question is a game which uses a lot of RAM).

    anyway -- I can copy the text file to a string, thats no problem. But once it gets there, I need to edit specific parts of it.

    for example:
    on line 12 it says: option1 = 0;
    I need it to be changed to: option1 = 1;
    and I need to change it without changing lines 1-11 or 12+

    I've thought about using Python or LUA to do this for me, but the problem is that someone who is primarily a gamer using the Windows XP OS (my target user) probably won't have an interpreter on hand.

    If this is a more viable route, and there is an easy way to include an interpreter or DLL to run the script within my installation package, I can also go this route (although, even though I have the development tools for python and LUA, I dont kow any code for those languages -- Id have to learn)

    if any more info is needed, please ask.
    thanks in advance.

  2. #2
    Registered User
    Join Date
    Dec 2006
    Scranton, Pa
       string option_old = "option1 = 0";
       string option_new = "option1 = 1";
      //option_new could be input by user 
     //string option_new;
     //std::cin>> option_new;
       int search = datafile.find( option_old );
       if ( search != 0 )
       datafile.replace(search, option_new.size(), option_new);
    Then again, you may be talking something completely different here....

  3. #3
    Registered User
    Join Date
    Mar 2006
    Uhm... put each line into its own string or data structure and edit it seperately?
    #include <stdio.h>
    void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){
    /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i]
    ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][
    t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. edit control text buffer
    By scurvydog in forum Windows Programming
    Replies: 4
    Last Post: 12-11-2008, 10:13 AM
  2. Struggling to read text from Edit Control (box)
    By csonx_p in forum Windows Programming
    Replies: 6
    Last Post: 05-13-2008, 04:55 AM
  3. find if text in edit box has been changed
    By willc0de4food in forum Windows Programming
    Replies: 13
    Last Post: 09-10-2005, 10:47 PM
  4. Ok, Structs, I need help I am not familiar with them
    By incognito in forum C++ Programming
    Replies: 7
    Last Post: 06-29-2002, 09:45 PM
  5. Outputting String arrays in windows
    By Xterria in forum Game Programming
    Replies: 11
    Last Post: 11-13-2001, 07:35 PM