REXX Tips & Tricks, Version 2.80


Inf-HTML [About][Toc][Index] 0.9b (c) 1995 Peter Childs


Change the WPS archive flag



The WPS archive flag is saved in the file \OS2\BOOT\ARCHBASE.$$$ at the 
offset 0xCF (Use 208 dec. for <CharOut in REXX programs. This is necessary 
because REXX counts beginning with 1). To turn the ARCHIVE feature on, set 
this byte to 0x01; to turn it off set it to 0x00 (tested with OS/2 WARP 
and OS/2 WARP Connect, see example program below). 
The name of the path for the archive is saved as ASCIIZ string in the same 
file at the offset 0x06 (use 7 dec for <CharOut in REXX programs). The 
maximum length for the path is 200. 
(see also Change the OS/2 recovery screen options)   
Source:  Peter Bunney (see EMail Addresses) 
   
 Note:  According to some messages on Usenet, the offset of these bytes is 
        different in various versions of WARP with Fixpacks applied. I 
        can't say if that is true or not -- but don't forget that the 
        format of this file is not documented! 
   

  
 /*                                                                    */
 /* Program Title: swBackup.CMD                                        */
 /*                                                                    */
 /* Program Purpose: get, set or clear the archive bit in the          */
 /*                  desktop settings                                  */
 /*                                                                    */
 /* Author: Peter Bunney 100411.20@compuserve.com                      */
 /*         (see EMail Addresses)                                      */
 /*                                                                    */
 /* History                                                            */
 /*   Date Written: 16 dec 95                                          */
 /*                                                                    */
 /*   Date Updated: 18 dec 95                                          */
 /*    - added parameter /bs                                           */
 /*    - added some error checking /bs                                 */
 /*    - changed the name to the 8.3 convention                        */
 /*                                                                    */
 /* Usage:                                                             */
 /*   swBackup {ON|OFF|STATUS} {bootDrive}                             */
 /*                                                                    */
 /* Where:                                                             */
 /*   ON        = switch archive feature ON                            */
 /*   OFF       = switch archive feature OFF                           */
 /*   STATUS    = get the current status of the archive feature (def.) */
 /*   bootDrive = boot drive (e.g. "C:")                               */
 /*               def.: use environment variable RUNWORKPLACE          */
 /*                                                                    */
 /* Returns:                                                           */
 /*   parameter ON or OFF: 0 if successful                             */
 /*   parameter STATUS: 0 - archive feature is off,                    */
 /*                     1 - archive feature is on                      */
 /*   else                                                             */
 /*     255 - error                                                    */
 /*                                                                    */
 
                         /* init the return code                       */
   retCode = 255
 
                         /* get the parameter                          */
   parse arg action bootdrive .
 
                         /* check the parameter, use defaults if       */
                         /* necessary                                  */
   if bootDrive = "" then
     bootDrive = left( value( "RUNWORKPLACE",, "OS2ENVIRONMENT" ),1 )
   bootDrive = left( bootDrive,1 ) || ":"
 
   if action = "" then
     action = "STATUS"
   action = translate( action )
 
                         /* file used by the WPS to save the current   */
                         /* status                                     */
   Archivefilename = bootDrive || "\os2\boot\archbase.$$$"
 
   if stream( ArchiveFileName, "c", "QUERY EXISTS" ) <> "" then
   do
                         /* change file attributes                     */
     "@attrib -r " ArchiveFilename "2>NUL 1>NUL"
     if rc = 0 then
     do
 
                         /* process the appropriate action             */
       select
 
         when action = "ON" then
         do
                         /* turn the archive feature ON                */
           if stream( ArchiveFileName, "c", "OPEN WRITE" ) = "READY:" then
             if charout( ArchiveFilename, x2c( 01 ), 208 ) = 0 then
               retCode = 0
           call stream ArchiveFileName, "c", "CLOSE"
         end /* when */
 
         when action = "OFF" then
         do
                         /* turn the archive feature OFF               */
           if stream( ArchiveFileName, "c", "OPEN WRITE" ) = "READY:" then
             if charout( ArchiveFilename, x2c( 00 ), 208 ) = 0 then
               retCode = 0
           call stream ArchiveFileName, "c", "CLOSE"
         end /* when */
 
         when action = "STATUS" then
         do
                         /* get the status of the archive feature      */
           if stream( ArchiveFileName, "c", "OPEN READ" ) = "READY:" then
             retCode = c2x( charin( ArchiveFilename,208,1 ) )
           call stream ArchiveFileName, "c", "CLOSE"
         end /* when */
 
         otherwise
         do
           say "Error: Invalid action parameter <" || action "> found!"
           retCode = 255
         end /* otherwise */
 
       end /* select */
 
                           /* reset file attributes                      */
       "@attrib +r " ArchiveFilename "2>NUL 1>NUL"
     end /* if rc = 0 then */
     else
       say "Error changing the attributes of <" || ArchiveFileName || ">!"
 
   end /* if stream( ... */
   else
     say "File <" || ArchiveFileName || "> not found!"
 
 exit retCode
 
 
   

Inf-HTML End Run - Successful