Understanding Macros, Global Variables and Environment Vari

Get help with installation and running here.

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

Post Reply
alnico
Posts: 74
Joined: Fri Oct 12, 2007 11:57 pm

Understanding Macros, Global Variables and Environment Vari

Post by alnico »

I am a little confused about Macros, Global Variables and Environment Variables.

Correct me if I am wrong:

Some Macros are dynamically set at runtime i.e. INPUTFILENAME; while Global Variables are user defined.
Both are accessed using: @VariableName

But what are Environment Variables?
I am assuming they are dynamically set as well.
If so where is the supported list, I have searched help and found nothing?
I understand these are accessed using: %EnvironmentVariable%.
What is the difference between system Macros and Environment Variables?

Now to get to my real problem:
I am trying to name a file by inserting @INPUTFILENAME (global variable) into Single File Output field…obviously this does not work as the Help file says % EnvironmentVariable % is required.

Where and what are the Environment Variables?

Thanks,
TextPipe Pro 8.6.7
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Understanding Macros, Global Variables and Environment

Post by DataMystic Support »

Environment variables are part of Windows (DOS), go to a cmd.exe prompt and type
set
for a list of what you have defined.

Note - you can't set the output filename this way because the output filename is set at the start of processing a file - not at the end.

You can achieve this using a vbscript filter, using code something like this:

Code: Select all

'detect changes - write to new file

dim name
dim oldfield
dim fso
dim TextStream

'Called for every line in the file
'EOL contains the end of line characters (Unix, DOS or Mac) that must be
'appended to each line
function processLine(line, EOL)
  field = mid(line,1,instr(line,",") - 1)

  if oldfield <> field then
    if TextStream <> Null then TextStream.close
    Set TextStream = fso.OpenTextFile( "C:\" & field & ".txt", 8, True)
    TextStream.writeLine( line )
  else
    TextStream.writeLine( line )
  end if
  
  oldfield = field
  processLine = ""
  
end function


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


sub endJob()
  Set fso = Nothing
end sub


function startFile()
  startFile = ""
  oldfield = ""
end function


function endFile()
  if TextStream <> Null then TextStream.close
  endFile = ""
end function
alnico
Posts: 74
Joined: Fri Oct 12, 2007 11:57 pm

Re: Understanding Macros, Global Variables and Environment

Post by alnico »

Thanks Simon,

Can you please incorporate this (or something similar) into the Help page: Macros and Global Variables... "Environment variables are part of Windows (DOS), go to a cmd.exe prompt and type "set" for a list of what is defined."

Also, in the help pages where ever "Environment Variables" is noted link to the: Macros and Global Variables help page.

The more we know the less we have to ask you out of frustration ;-)

Thanks,
Brent
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Understanding Macros, Global Variables and Environment

Post by DataMystic Support »

Sure Brent - doing it now!
Post Reply