Problem with adding lines to the header

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

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

Problem with adding lines to the header

Postby acefoster » Mon May 09, 2011 10:05 am

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: 2154
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Problem with adding lines to the header

Postby DataMystic Support » Mon May 09, 2011 11:36 am

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.
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments

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

Re: Problem with adding lines to the header

Postby acefoster » Mon May 09, 2011 7:27 pm

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: 2154
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Problem with adding lines to the header

Postby DataMystic Support » Tue May 10, 2011 9:06 am

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
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments


Return to “TextPipe Tips and Tricks, Questions and Support”

Who is online

Users browsing this forum: No registered users and 9 guests