PPWIZARD is a free preprocessor for HTML, REXX, Visual Basic or any text files.
[Bottom][Contents][Search][Prev]: AddTempFileToDependancyList()[Next]: ArrayRemoveDup()
\ -> Rexx -> Inbuilt PPWIZARD Functions -> AddressCmd()

AddressCmd()

This is an inbuilt function function provided by PPWIZARD.

This routine will pass the command that you specify (as the first argument) to the operating system's command processor.

This routine allows you to execute any native operating system commands as well as perl, pascal, rexx or in fact code written using any language. If the commands output is required the output can be redirected and you can tell ppwizard to #include it or you can load it yourself to parse out selected information.

The command will by default be logged when debug is on. This is a major reason why you should use this call (rather than using rexx's native methods).

If your command produces some files as output or you create some by redirection you can specify the names of the files as parameter 2 onwards and these will be dumped when debug is on (the only reason for supplying more than the command line as the first parameter).

Under OS/2 if the command to be executed is a rexx batch file you should preceed the command with "CMD.EXE /c" or the command will fail. If you don't know what the command is you should preceed all commands with that string to play safe.

The /AddressCmdTrace switch can help debug command execution in situations where you get rubish or error output displayed on the screen.

Stupid Example

This example shows a directory commands output going into one file and any error messages into another. If debug is on the contents of both files as well as the return code will be dumped.

#evaluate "" ^call AddressCmd "dir /od >dirlist.out 2>error.out", "dirlist.out", "error.out"^

Bigger Real Example

The following is used to extract "STRFILEINFO" (ProductVersion etc) information from WIN32 executable files:

#DefineRexx ''
   ;--- Lots of stuff ---

   ;--- Now try to extract some STRFILEINFO ---
   #define? EXTRACT_STRFILEINFO_FROM_THESE_EXTENSIONS  /EXE/DLL/OCX/  ;;Can clear to prevent for all!
   @@Extn = translate(FilePart('e', @@FullFile));
   @@StrFileInfo = ""
   if  pos('/' || @@Extn || '/', '<$EXTRACT_STRFILEINFO_FROM_THESE_EXTENSIONS>') <> 0 then
   do
       ;--- Get name of a temporary file ---
       @@TmpFile  = FileGetTmpName('SFI_????.TMP');

       ;--- Execute the command (redirect output to file) ---
       @@Cmd = 'StrFInfo.exe "' || @@FullFile || '" FileDescription FileVersion ProductName ProductVersion CompanyName Maintainer Author';
       @@Rc = AddressCmd(@@Cmd || ' > "' || @@TmpFile || '" 2>&1');

       ;--- Did the command succeed? ---
       if  @@Rc = 0 then
       do
           ;--- Read the info generated by the STRFINFO.EXE program ---
           parse value linein(@@TmpFile) with 'FileDescription='  @@FileDescription;
           parse value linein(@@TmpFile) with 'FileVersion='      @@FileVersion;
           parse value linein(@@TmpFile) with 'ProductName='      @@ProductName;
           parse value linein(@@TmpFile) with 'ProductVersion='   @@ProductVersion;
           parse value linein(@@TmpFile) with 'CompanyName='      @@CompanyName;
           parse value linein(@@TmpFile) with 'Maintainer='       @@Maintainer;
           parse value linein(@@TmpFile) with 'Author='           @@Author;
           call FileClose @@TmpFile, "Y"

           ;--- Tool reports "FAILED" for unavailable info (if STRING FILE INFO available) ---
           if  @@FileDescription = "FAILED" then @@FileDescription = '';
           if  @@FileVersion     = "FAILED" then @@FileVersion     = '';
           if  @@ProductName     = "FAILED" then @@ProductName     = '';
           if  @@ProductVersion  = "FAILED" then @@ProductVersion  = '';
           if  @@CompanyName     = "FAILED" then @@CompanyName     = '';
           if  @@Maintainer      = "FAILED" then @@Maintainer      = '';
           if  @@Author          = "FAILED" then @@Author          = '';

           ;--- Get name and version ---
           if  @@FileDescription <> '' & @@FileVersion <> '' then
           do
               ;--- Have file info, use in in preference to product info ---
               @@StrFileInfo = 'File "' || @@FileDescription || '" version "' || @@FileVersion || '"';
           end;
           else
           do
               ;--- Don't seem to have file info, look for product info ---
               if  @@ProductName <> '' & @@FileVersion <> '' then
               do
                   ;--- Have file info, use in in preference to product info ---
                   @@StrFileInfo = 'From product "' || @@ProductName || '" version "' || @@FileVersion || '"';
               end;
           end;

           ;--- Get "made by" info ---
           select
               /*++++++++++++++++++++++++++*/
               when @@CompanyName <> "" then
               /*++++++++++++++++++++++++++*/
                   @@MadeBy = @@CompanyName
               /*++++++++++++++++++++++++++*/
               when @@Maintainer <> "" then
               /*++++++++++++++++++++++++++*/
                   @@MadeBy = @@Maintainer
               /*++++++++++++++++++++++++++*/
               when @@Author <> "" then
               /*++++++++++++++++++++++++++*/
                   @@MadeBy = @@Author
               /*++++++++++++++++++++++++++*/
               otherwise
               /*++++++++++++++++++++++++++*/
                   @@MadeBy = ''
           end
           if  @@MadeBy <> "" then
           do
               if  @@StrFileInfo <> "" then
                   @@StrFileInfo = @@StrFileInfo || " by "
               else
                   @@StrFileInfo = "By "
               @@StrFileInfo = @@StrFileInfo || @@MadeBy;
           end;
       end;

       ;--- Delete the temporary file ---
       call FileDelete @@TmpFile, 'N';     ;;Ignore errors
   end;
   if  @@StrFileInfo <> "" then
   do
       ;--- Add "tooltip" and make the text bold ---
       @@StrFileInfo = '<div title="Details extracted from &quot;' || @@FullFile || '&quot;."><b>' || @@StrFileInfo || '</b></div>'
       if  @@FileCmt = "" then
           @@FileCmt = @@StrFileInfo;
       else
           @@FileCmt = @@FileCmt || '<hr size=1>' || @@StrFileInfo;
   end;
#DefineRexx


email me  any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Search][Prev]: AddTempFileToDependancyList()[Next]: ArrayRemoveDup()


PPWIZARD Manual
My whole website and this manual itself was developed using PPWIZARD (free preprocessor written by Dennis Bareis)
Saturday May 28 2022 at 2:55pm