Understanding Macros, Global Variables and Environment Vari

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

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

Understanding Macros, Global Variables and Environment Vari

Postby alnico » Fri Dec 17, 2010 5:04 am

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

Re: Understanding Macros, Global Variables and Environment

Postby DataMystic Support » Mon Dec 20, 2010 5:10 pm

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

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

Re: Understanding Macros, Global Variables and Environment

Postby alnico » Tue Dec 21, 2010 12:47 am

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

Re: Understanding Macros, Global Variables and Environment

Postby DataMystic Support » Tue Dec 21, 2010 7:24 am

Sure Brent - doing it now!
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: Yahoo [Bot] and 2 guests