Results 1 to 6 of 6

Thread: Editting .txt files?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2001
    Posts
    3

    Question Editting .txt files?

    A few questions here. Let's suppose I have a text file named test.txt. In that text file I have the following:
    -------------
    [Accounts]
    Total = 2

    Test=Test1
    Test2=Test3
    -------------
    I know how to add text to the text files but what I would like to do is each time the user adds some text to the text file, I would like the "Total" to increase by 1. So if they add 2 more to the above text, the Total would increase to 4. Does that make sence? Thank you in advance.

    - Ilya

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    That format is the same as used in INI files, so I suggest you read/write to the file using API's designed for use with ini files (doesn't matter if it's actually a .txt)

    http://www.vb-world.net/tips/tip17.html
    http://www.vb-world.net/demos/ini/

    The total thing you just need to increment when a value is added, and decrement when a value is removed using same APIs

  3. #3
    DaoK
    Guest
    You should use .ini for variable not a .txt

  4. #4
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    Makes no difference

  5. #5
    Banned
    Join Date
    Oct 2001
    Posts
    24
    Technically no, but it's more conventional.

  6. #6
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    Hi
    I think it would be much easier to use a text file rather than an ini file in this case.
    1) Easier to code for
    2) Less maintenance problems if one file is updated or deleted and the other isnt.
    3) The ini file is oft abused and can grow like a weed

    Anyway, if u are using accounts etc I would maybe suggest that you look into Random Access Files and User Defined Types. U may find it much easier to manage than using simple Input and Output files. And i cant give an example becos it is such a wide topic. Have a look around in MSDN Help, here etc for snippets of info.
    Regards
    Stuart
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width