Results 1 to 13 of 13

Thread: Keep track of value in txt file

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,591

    Keep track of value in txt file

    In txt file i can have:

    1111
    1111
    2222
    2222
    3333
    3333
    3333
    3333
    ... ecc
    7777
    7777

    I need to check when the value change during a reading of txt file file line by line

    pseudo code:

    loop the file

    Valore="1111"

    until to the new value are <> of valore, if yes stop, for example in line 3 have 2222

    note:
    all value in txt file are already ordered
    Last edited by luca90; Apr 19th, 2024 at 11:49 AM.

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,212

    Re: Kip track of value in txt file

    Well....you are going to need to save the information somewhere before the subsequent readings.
    Sam I am (as well as Confused at times).

  3. #3
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,186

    Re: Kip track of value in txt file

    I think he just wants to know the line where a change occurs. This luca90 account is a bit nuts. He/they have asked much more complex questions than this before. This seems like a incredibly elementary questions. In fact, Sam, I think it's so simple, you thought it was more complex than it is.

    ---------

    I'm tempted to write some incredibly convoluted way of doing it, and posting that as my answer. Maybe create an MDB file with a table that has the fields Value and LineNum. Write it all out to that MDB file, and then use a SQL grouping command to count each of the values, use those counts, to figure out the line numbers of the changes. I'd love to see him turn that in for his assignment.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,591

    Re: Kip track of value in txt file

    Quote Originally Posted by SamOscarBrown View Post
    Well....you are going to need to save the information somewhere before the subsequent readings.
    Dictionary?

  5. #5
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,212

    Re: Keep track of value in txt file

    AH! Yes, I see now! When 'Volare' changes from 1111 to 2222. I thought he wanted to load a file, save the information, and then in subsequent loads see what changed...But now I THINK he wants that SIMPLE solution as to when it (his variable) changes for 1111 to 2222, etc. But WHY? I guess that is the real question. Does he need to know which LINE NUMBER it changes at?????? Geez....I am at a complete loss as to what and why he wants this.
    Sam I am (as well as Confused at times).

  6. #6
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,655

    Re: Keep track of value in txt file

    I get the sense this is actually about filtering out duplicates.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  7. #7
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,514

    Re: Keep track of value in txt file

    Quote Originally Posted by Niya View Post
    I get the sense this is actually about filtering out duplicates.
    If it is, then 2 Options
    1) Dictionary (Needs external Ref to Scripting)
    2) Collection with Error-Trap for duplicate key (No external Ref to anything)
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  8. #8
    Junior Member
    Join Date
    Mar 2024
    Posts
    19

    Re: Keep track of value in txt file

    Set OldValue to 0 or null

    Read Loop:

    [input command], Value

    if Value <> OldValue then [do whatever you want because Value changed]

    AFTER you have done what you want set OldValue = Value !!!!!

    Return to the beginning of the loop -- nothing will happen until Value changes

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,591

    Re: Keep track of value in txt file

    Quote Originally Posted by SwampeastMike View Post
    Set OldValue to 0 or null

    Read Loop:

    [input command], Value

    if Value <> OldValue then [do whatever you want because Value changed]

    AFTER you have done what you want set OldValue = Value !!!!!

    Return to the beginning of the loop -- nothing will happen until Value changes
    ????
    Can you post a Little piece of code?
    Tks

  10. #10
    Junior Member
    Join Date
    Mar 2024
    Posts
    19

    Re: Keep track of value in txt file

    Of course the actual code varies.

    intOldValue = 0
    do
    input#1,intValue
    if intValue <> intOldValue then
    intValue = [whatever you want to do]
    intOldValue = IntValue
    loop while not eof(1)
    -----------------------------------
    This is a dare-I-say "basic" aspect of programming. Not only must you be able to detect and handle repeated identical data entries but you must be on the alert for such to occur unexpectedly.

  11. #11
    Frenzied Member
    Join Date
    Apr 2012
    Posts
    1,263

    Re: Keep track of value in txt file

    Quote Originally Posted by SwampeastMike View Post
    -----------------------------------
    This is a dare-I-say "basic" aspect of programming.
    Bit harsh. Luca has only been coding for 19 years.
    If you don't know where you're going, any road will take you there...

    My VB6 love-children: Vee-Hive and Vee-Launcher

  12. #12
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,200

    Re: Keep track of value in txt file

    Quote Originally Posted by ColinE66 View Post
    Bit harsh. Luca has only been copy-pasta-ing for 19 years.
    Movie idea: 50 First "Hello World's!". Synopsis: A programmer with short term memory loss must re-learn how to write code every day.

  13. #13
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,212

    Re: Keep track of value in txt file

    What a way to start the day! WITH A LAUGH! Thanks OB1!!!

    Movie idea: 50 First "Hello World's!". Synopsis: A programmer with short term memory loss must re-learn how to write code every day.
    Sam I am (as well as Confused at times).

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