Page 1 of 1

Problem with adding lines to the header

Posted: Mon May 09, 2011 10:05 am
by acefoster
Hello to all,
can't solve problem with adding lines to the header of the file from the another file.
So I have list of files in "Files to process". For each of them required to add Header from the another file. Each line of this "another file" contains couple words. The number of file in "Files to process" and lines in file with the headers are equal.
I suppose that in Textpipe may be have some loop function, but i can find :(
If somebody know how to make Textpipe work that it will be very helpfull for me and other users of this wonderful soft.

Regards,
Ace Foster

Re: Problem with adding lines to the header

Posted: Mon May 09, 2011 11:36 am
by DataMystic Support
Hi Ace,

So every file needs a different header? How many files are we talking about?

You could easily use Filters\Special\Script (VBScript,JScript...) and embed the list of headers as an array, then simply substitute the correct one in each file and increase the array index each time.

Re: Problem with adding lines to the header

Posted: Mon May 09, 2011 7:27 pm
by acefoster
Thanks for the answer Simon,
So every file needs a different header?
Yes, every file need a different header, and this header must not repeat.
How many files are we talking about?
The number of files is about 90-100.
You could easily use Filters\Special\Script (VBScript,JScript...) and embed the list of headers as an array, then simply substitute the correct one in each file and increase the array index each time.
I have some knowledge only in PHP, so writing on VBScript & JScript are the problem. If there some VBScript & JScript samples that could help me ?

Re: Problem with adding lines to the header

Posted: Tue May 10, 2011 9:06 am
by DataMystic Support
Something like this; it assumes the header filename is called *.header:

Code: Select all

Const OpenFileForReading = 1 
Dim fso, TextStream

function processLine(line, EOL)
  processLine = line & EOL
end function


sub startJob()
  Set fso = CreateObject("Scripting.FileSystemObject")
end sub


sub endJob()
  'do nothing
end sub


function startFile()

  Dim fileContents
  Dim filename

  filename = TextPipe.fullInputFilename & ".header"

  'ignore the error if the file is not found
  on error resume next
  fileContents = "** " & filename & " was not found **"

  'read what's in the file
  Set TextStream = fso.OpenTextFile( filename, OpenFileForReading)
  fileContents = TextStream.ReadAll
  TextStream.close

  startFile = fileContents 
end function


function endFile()
  endFile = ""
end function