Problem with adding lines to the header

Get help with installation and running here.

Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators

Post Reply
acefoster
Posts: 2
Joined: Mon May 09, 2011 9:33 am

Problem with adding lines to the header

Post 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
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Problem with adding lines to the header

Post 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.
acefoster
Posts: 2
Joined: Mon May 09, 2011 9:33 am

Re: Problem with adding lines to the header

Post 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 ?
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Problem with adding lines to the header

Post 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
Post Reply