Ph: 800-848-2576
Fax: 360-654-8170
Contact Us
Using System Environment Variables

You can use MPE/iX and UNIX environment variables in AskPlus by prefixing the variable name with the ^ character.  When you reference an environment variable in AskPlus, the value of the variable is interpreted as though it had been entered with quotes.  If this is not what you want, you must prefix the value of the variable with a > character.  This character, which is part of the value, will cause AskPlus to treat the remainder of the value as though it had been entered without quotes.

On MPE systems, the SETVAR command is used to set environment variables. On UNIX, the command is export. UNIX environment variables must be exported before AskPlus is started.

See the following (MPE) example:

:SETVAR YMD (!HPYEAR * 10000 + !HPMONTH * 100 + !HPDATE )
:SETVAR OUTFILE ">FI!YMD"
:SHOWVAR
  YMD = 950308
  OUTFILE = >FI950308

FIND PRIMARY = ORDERS
ORDER-DATE = ^YMD

SAVE OUT = ^OUTFILE, SDASK
D1, ORDER-DATE, TAB1
...
END

ECHO ^YMD
  "950308"

ECHO ^OUTFILE
  FI950308


NOTE: The SETVAR command which defines the value of the output file name (OUTFILE), must include the > character so that the SAVE syntax is valid. This is because AskPlus does not expect the file name to be enclosed in quotes. Remember to use the ^ character, not the ! character, when referencing MPE/iX variables.

Environment variables can also be combined with the AskPlus ability to execute command files when it is initialized.  The following example shows an HP command file that will prompt for the name of an AskPlus XEQ file and a date parameter, it will then run AskPlus and execute the XEQ file.

setvar okay "Y"
while str(ups("!okay"),1,1) = "Y" do
input cmd;prompt="Enter the name of your command file?"
input date;prompt="Enter the Order Date (YYMMDD)?"
echo
run askplus.pubtcp.askplus;info="-xeq:!cmd,quiet"&
;xl="xl.pubtcp.askplus";stdlist=$null
input okay;prompt="Execute another report [!okay]?"
endwhile

This example assumes that the command file being executed uses the environment variable DATE.  It also assumes that the output of the XEQ file is being directed to the printer or a file.  Remove the "STDLIST=$NULL" if you want information displayed to your screen.
Send questions & comments regarding the Vital Soft site to:  webmaster@vital-soft.com
Copyright © 1998-2012, Vital Soft, Inc.