Using line count in global variable
Posted: Sun Jun 21, 2009 12:08 pm
Ok, I know there's a trick to this, and I just can't find it.
The first I count the line count in a file and save the number to an external text file. Next I read the number in a text file to calculate x percent (5%) of the line count. Third, I use a vbscript to create an array of random numbers with x (5%) elements where each element's value ranges from 1 to total lines. Finally, I use vbscript to add a tag to the random lines.
Right now, I do all four of these steps in two different textpipe scripts. I can't assign the first step's line count to a global variable and use it later in the same script. I think there's a trick to using the T-filter, but I haven't been able to make it work. A similar functionality would be to insert the total line count as a file header. I can get the T-filter to allow me to insert the global variable to the footer, but not to the header (or left / right margins).
Can you point me to a sample filter?
Thanks,
Tom
The first I count the line count in a file and save the number to an external text file. Next I read the number in a text file to calculate x percent (5%) of the line count. Third, I use a vbscript to create an array of random numbers with x (5%) elements where each element's value ranges from 1 to total lines. Finally, I use vbscript to add a tag to the random lines.
Right now, I do all four of these steps in two different textpipe scripts. I can't assign the first step's line count to a global variable and use it later in the same script. I think there's a trick to using the T-filter, but I haven't been able to make it work. A similar functionality would be to insert the total line count as a file header. I can get the T-filter to allow me to insert the global variable to the footer, but not to the header (or left / right margins).
Can you point me to a sample filter?
Thanks,
Tom