Basic Counter ALMOST works

Hi there,

I know there are other threads here about counters and I used them as an inspiration to build my own: See below. It almost works but sometimes get's stuck at a number and no matter how often I repeat it, it always says at the same number until I update the counter in the comment of the file, then it continues for a random number and then it get's stuck again.

Can anybody see the reason why this might happen?

I don't see anything obviously wrong. Please post your macro file so we can test. See How to post/upload your script/macro.

I had a look at this, and I had it fail a few times. It looks like the system is erroneously caching the comment, and not noticing the change from the Set Comment when it next runs the Get Comment.

I changed the single Set Comment action to this sequence:

And that seemed to resolve the issue - occasionally the next Get Comment would read one of the other Set Comment values (eg 5.00), but that was fine, it would still evaluate correctly.

I don't have any other suggestions I'm afraid, this looks like a caching issue in the system reading code for the comment.

Is there some reason you are storing the count in the comment?

@Ben1994, or another way of asking this question is:
what is the purpose of frequently storing a count in the file comments?

If you can share your basic workflow where you use this counter, perhaps we can suggest some alternative solutions that would work better.

This works like a charm! Thank you very much :slight_smile:

Storing the counter in the comment of a file was the easiest and fastest way I was able to build a counter.

Just so you know, you can easily build a counter using KM global variable that will persist across macros, and even across Mac restarts.

If you like, you can even dynamically name the KM variable using the file/document name, or parts thereof.

Using KM variables for counters would be a much better method in most cases.

If you'd like more info/help on this, just let us know.