Page 1 of 1

Understanding Macros, Global Variables and Environment Vari

Posted: Fri Dec 17, 2010 5:04 am
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

Re: Understanding Macros, Global Variables and Environment

Posted: Mon Dec 20, 2010 5:10 pm
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

Re: Understanding Macros, Global Variables and Environment

Posted: Tue Dec 21, 2010 12:47 am
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

Re: Understanding Macros, Global Variables and Environment

Posted: Tue Dec 21, 2010 7:24 am
by DataMystic Support
Sure Brent - doing it now!