# Thread: Keep track of value in txt file

1. ## 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

2. ## Re: Kip track of value in txt file

Well....you are going to need to save the information somewhere before the subsequent readings.

3. ## 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.

4. ## Re: Kip track of value in txt file

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

5. ## 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.

6. ## Re: Keep track of value in txt file

I get the sense this is actually about filtering out duplicates.

7. ## Re: Keep track of value in txt file

Originally Posted by Niya
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)

8. ## Re: Keep track of value in txt file

Set OldValue to 0 or null

[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. ## Re: Keep track of value in txt file

Originally Posted by SwampeastMike
Set OldValue to 0 or null

[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. ## 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. ## Re: Keep track of value in txt file

Originally Posted by SwampeastMike
-----------------------------------
This is a dare-I-say "basic" aspect of programming.
Bit harsh. Luca has only been coding for 19 years.

12. ## Re: Keep track of value in txt file

Originally Posted by ColinE66
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. ## 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.

#### Posting Permissions

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