/* This template illustrates all MRBackup ARexx commands. 
 * Beginners can use this template to start their own custom ARexx
 * scripts by editing the appropriate parts of the template.
 * Don't forget to remove the comment delimiters surrounding each
 * example command.
 * 
 * Note that the example commands are presented in the order which
 * they would be typically used rather than in alphabetical order.
 * Certain values are expressed in a meta-notation using angle brackets <>.
 * Substitute appropriate values for these bracketed expressions.
 */

/* Initialize our trap mechanisms. */

signal on ERROR
signal on BREAK_C

/* Enable result returns from MRBackup (required!). */

options results

/* See if MRBackup is running. If not, then exit right away. */
if ~(Show('P', 'MRBackup_#1')) then do
    say "You must run MRBackup first. With a little work, you could"
    say "get this ARexx script to do it for you."
    exit 1
end

/* Make MRBackup's port the active port. */
address "MRBackup_#1"

/* Pop MRBackup's screen/window to the front so we can see the effects
 * of our script while it's executing.
 */

/* poptofront */


/* Several 'get' commands allow you to retrieve certain parameters from
 * MRBackup's current settings. You might use these if you wish to 
 * temporarily alter a parameter, then restore it prior to exiting the
 * script. Each parameter is returned via the "result" parameter which
 * must be copied to another variable if you wish to save it.
 *
 * For the purpose of brevity, the result code, "rc", is not checked
 * after each command. You should add a test similar to the following
 * for instances where error checking is required:
 
        if rc ~= 0 then do
            say "ARexx command error; rc = " rc
            exit 1
        end
 */

/*******************************/
/**  Result Retrieval Command **/
/*******************************/

/** Get the result of the last command executed:
    'getresult'
    lastResult = result
 **/

/*******************************/
/** Option Retrieval Commands **/
/*******************************/

/** Get the backup path: **/
/**
    'getbackpath'
    backpath = result
    say "The current backup path is " backpath
 **/

/** Get the home path: **/
/**
    'gethomepath'
    homepath = result
 **/

/** Get the backup filter path: **/
/**
    'getbfilterpath'
    bfilterpath = result
 **/

/*& Get the compression filter path: **/
/**
    'getcfilterpath'
    cfilterpath = result
 **/

/** Get the decompression filter path: **/
/**
    'getdfilterpath'
    dfilterpath = result
 **/

/** Get the restore filter path: **/
/**
    'getrfilterpath'
    rfilterpath = result
 **/

/** Get the forced copy flag: **/
/**
    'getforcedcopy'
    forcedcopy = result 
 **/

/** Get the current listing path: */
/**
    'getlistpath'
    listpath = result
 **/

/** Get the current log file pathname: */
/**
    'getlogpath'
    logpath = result
 **/


/** Get the buffer size: **/
/**
    'getbufsize'
    bufsize = result
 **/

/** Get the compression factor: **/
/**
    'getcompression'
    compression = result
 **/

/** Get the decompression factor limit. Files compressed with a factor
 ** greater than this threshold will be restored in their compressed
 ** form.
 **/
/**
    'getdecompression'
    decompression = result
 **/

/** Get the disk formatting mode: **/
/**
    'getformatting'
    formatting = result
 **/

/** Get the backup test date: **/
/**
    'gettestdate'
    testdate = result
 **/

/** Get the output mode for writing to existing files: **/
/**
    'getfilemode'
    filemode = result
 **/

/** General-purpose choice requester: **/
/** 
    'getchoice "Please choose one of these..." "A" "B" "C"'
    choice = result
 **/


/*****************************/
/** Option Setting Commands **/
/*****************************/

/** Set the backup mode (select one): **/
/** 'setbackupmode "AmigaDOS"' **/

/** 'setbackupmode "FastDisk"' **/

/** 'setbackupmode "SCSITape"' **/


/** Establish a new backup path: **/
/** 'setbackpath "<backup_path>"' **/

/** Establish the home path: **/
/** 'sethomepath "DH0:"' **/

/** Set the backup filter pathname: **/
/** 'setbfilterpath "MRBackup:Prefs/<yourfiltername>"' **/

/** Set the compression filter pathname: **/
/** 'setcfilterpath "MRBackup:Prefs/<yourfiltername>"' **/

/** Set the decompression filter pathname: **/
/** 'setdfilterpath <MRBackup:Prefs/<yourfiltername>"' **/

/** Set the restore filter pathname. This is required if you wish to
 ** do an automated restore of individual file(s) under ARexx control.
 **/
/** 'setrfilterpath "MRBackup:Prefs/<yourfiltername>"' **/

/** Set the name of the catalog to be used for backup or restore. **/
/** 'setcatalogname "MRBackup:Catalogs/<yourcatalogname>"' **/

/** Set the buffer size as a multiple of K (K= 1024 bytes). 
 ** For example, if you specify 64, 65536 bytes will be used as the
 ** copy buffer size. When using tape, this should be an integral
 ** factor of the tape buffer size specified in the mountlist entry.
 ** Usually, an exact match is desirable.
 **/
/** 'setbufsize "<buffer_size_in_K>"' **/

/** Set the descriptive comment for the next backup: **/
/** 'setcomment "<your_comment_string>"' **/

/** Set the compression factor for a backup (select one): **/
/** 'setcompression "None"' **/
/** 'setcompression "12-Bit"' **/
/** 'setcompression "13-Bit"' **/
/** 'setcompression "14-Bit"' **/
/** 'setcompression "15-Bit"' **/
/** 'setcompression "16-Bit"' **/

/** Set the decompression factor limit for a restore (select one): **/
/** 'setdecompression "None"' **/
/** 'setdecompression "12-Bit"' **/
/** 'setdecompression "13-Bit"' **/
/** 'setdecompression "14-Bit"' **/
/** 'setdecompression "15-Bit"' **/
/** 'setdecompression "16-Bit"' **/

/** Set the mode to use when opening existing log and listing files for
 ** output. This precludes the need for the "File already exists"
 ** requester but must appear _before_ setlistpath or setlogpath.
 **/

/** 'setfilemode "Ask"' **/
/** 'setfilemode "Append"' **/
/** 'setfilemode "Replace"' **/

/** Set the "forced copy" flag to alter MRBackup's Restore behavior.
 ** The selected option determines the action to take when the backup
 ** file is older than the current home file.
 **/

/** 'setforcedcopy "Always"' **/
/** 'setforcedcopy "Never"'  **/
/** 'setforcedcopy "Prompt"' **/

/**
/** Stuff a message in MRBackup's Info gadget: **/
/** 'setinfogadget "<your_message_string>"' */

/** Set the listing file/console/device pathname: **/
/** 'setlistpath "<listing_pathname>"' **/

/** Set the log file/console/device pathname: **/
/** 'setlogpath "<log_pathname>" **/

/** Set the backup test date: */
/** 'settestdate <backup_test_date>' **/

/** Set the disk formatting mode for AmigaDOS backups (select one): **/
/** 'setformatting "None"' **/
/** 'setformatting "Normal"' **/
/** 'setformatting "Quick"' **/

/** Instruct MRBackup to do the next restore without a catalog. **/
/** Though "NO" is a valid option, it has no meaningful use. **/
/** 'ignorecatalog "YES"' **/

/** Instruct MRBackup to backup/restore empty directories: **/
/** 'keepemptydirs "Yes"' **/
/** 'keepemptydirs "No"' **/

/** Set the "Set Archive Bits" option: **/
/** 'setarcbits "YES"' **/
/** 'setarcbits "NO"' **/

/** Set the "Test Archive Bits" option: **/
/** 'testarcbits "YES"' **/
/** 'testarcbits "NO"' **/

/** Set the prefix string used to construct backup volume names: **/
/**
    'setprefix "<backup_prefix_string>"'
 **/

/** Enable/Disable MRBackup's voice option: **/
/** 'setvoice "YES"' **/
/** 'setvoice "NO"' **/

/** Enable/Disable the "Split Big Files" option (AmigaDOS mode only): **/
/** 'splitfiles "YES"' **/
/** 'splitfiles "NO"'  **/

/** Command MRBackup to load backup/restore preferences from a file. 
 ** THIS IS THE PREFERRED METHOD FOR SETTING OPTIONS VIA AREXX:
 **/
/** 'loadprefs "<your_preferences_file>"' **/

/**********************/
/** Utility Commands **/
/**********************/

/** Display a "note alert" via MRBackup: */
/** 'notealert "<your_message_string>"' **/

/** Command MRBackup to speak a message: **/
/** 'speak "<your_message_string>"' **/

/** Command MRBackup to ask the user a "yes-or-no" question. The result
 ** variable will contain either "YES" or "NO" upon return: **/
/** 
    'yesno'
    yesnovalue = result
 **/

/** Invoke MRBackup's file utilities: */
/** 'utilities' **/

/** Take full control of MRBackup. This causes MRBackup to avoid user
 ** interaction in all but the most urgent situations (errors, etc.).
 ** The takecontrol/releasecontrol pair should normally be used for
 ** automated backup/restore activities. 
 **/

/** 'takecontrol' */

/** Command MRBackup to perform a backup using the current options: **/
/** 'backup' **/

/** Command MRBackup to perform a restore using the current options: **/
/** 'restore' **/

/** Release ARexx control of MRBackup: **/
/** 'releasecontrol' **/

/** Tell MRBackup to take the day off. If you issue any ARexx commands to
 ** MRBackup after this one, the best thing that will happen is that your
 ** script will die... In other words, DON'T!
 **/

/** 'quit' **/

exit 0
