$0 is a VERY bad idea, as its value can change when reopening the patch, depending on other patches and abstractions already open. You will end up with text files with meaningless unpredictable names
It is great though for keeping messages private within a patch or an abstraction....
Also a $1 in a message box takes the value of the first atom of an incoming list ($2 the second), and is not the value of an argument of the abstraction. $1, $2 etc. only take the arguments of an abstraction when they are in an object box.
You can use a float, or a symbol as an argument.
Symbols can be easier to "follow" though the patch and the text file names, as they carry more meaning.
Give your abstractions its arguments (or just one if the text file name is all you need... $1) ....... [abstr 1 x y woof]...... [abstr 2 z a howl] etc.....
Then use one of them to name the text file to write....... so writing $4.txt would write woof.txt for the first and howl.txt for the second.
Writing $1.txt would write 1.txt for the first and 2.txt for the second....
Writing $2.txt would write x.txt for the first and z.txt for the second....
Here is an example........ example.zip
[mother] contains two copies of [abstr]........ [abstr 1] and [abstr 2].
You will see that the 1, or the 2, replace the [$1] value which is then sent to the $1 in the write message.
If you want to use a symbol then replace [$1]... the float object...... with [symbol $1]....... as in the [abstr] example.