home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a013 / 1.ddi / SAMPLES.EXE / T_SYSSAV.PRG < prev    next >
Encoding:
Text File  |  1991-01-25  |  4.4 KB  |  131 lines

  1. *****************************************************************
  2. * Test program for SYSSAVE function -  FILE T_SYSSAV.PRG
  3. *****************************************************************
  4.  
  5. * Copyright(c) 1991 -- James Occhiogrosso
  6.  
  7. LOCAL choice := error_flag := file_types := mode := 1
  8. LOCAL clippath := '', filelist := {}
  9.  
  10. INITGLOBAL()
  11. SETCOLOR(colstd)
  12.  
  13. SET MESSAGE TO 24
  14.  
  15. DO WHILE choice > 0 .AND. choice != 7
  16.    CLEAR
  17.    @  3,34 SAY  "  MAIN MENU  "
  18.    @  4,34 SAY  " ▀▀▀▀▀▀▀▀▀▀▀ "
  19.  
  20.    * Menu below is for demonstration purposes only
  21.    * Only option 6 (backup/restore) is functional
  22.  
  23.    @ 1, 10 TO 20, 70 DOUBLE
  24.    @  6,27 PROMPT " 1. File Maintenance       "                 ;
  25.           MESSAGE PADC("Maintenance for all system data files")
  26.    @  7,27 PROMPT " 2. System Reports         "                 ;
  27.           MESSAGE PADC("Menu of system reports")
  28.    @  8,27 PROMPT " 3. Utilities Menu         "                 ;
  29.           MESSAGE PADC("System setup and housekeeping Utilities")
  30.    @  9,27 PROMPT " 4. Daily Report Series    "                 ;
  31.           MESSAGE PADC("Special daily reports and procedures")
  32.    @ 10,27 PROMPT " 5. End of Month Closing   "                 ;
  33.           MESSAGE PADC('Month end posting and report series')
  34.    @ 11,27 PROMPT " 6. Data Backup or Restore "                 ;
  35.           MESSAGE PADC("Data file backup/restore to/from A:")
  36.    @ 14,27 PROMPT " ESC. --  EXIT SYSTEM            "           ;
  37.           MESSAGE PADC("Return to DOS")
  38.  
  39.    * Display instructions and get operator's choice
  40.    SETCOLOR(colwindow)
  41.    @ 17,20 SAY " Select an option by moving the cursor,  "
  42.    @ 18,20 SAY " .. or pressing the appropriate number.  "
  43.    SETCOLOR(colstd)
  44.  
  45.    MENU TO choice
  46.  
  47.    DO CASE
  48.  
  49.    // CASE  choice = ??     
  50.    //      Other choices here
  51.  
  52.       CASE choice = 6
  53.  
  54.            * Set Clipper's path same as DOS path in case FORMAT 
  55.            * is needed. Assume that FORMAT.COM is on DOS path.
  56.            
  57.            clippath = GETE("PATH")
  58.            SET PATH TO &clippath
  59.  
  60.            * Display available options
  61.  
  62.            @ 22, 16 SAY 'Select Operation:  '
  63.            @ 22, 36 PROMPT ' Backup files  '
  64.            @ 22, 52 PROMPT ' Restore files '
  65.  
  66.            mode = 1
  67.            MENU TO mode
  68.  
  69.            IF mode = 1
  70.                * More options for backup only
  71.                @ 22, 16 SAY 'Select file group: '
  72.                @ 22, 36 PROMPT ' Current files '
  73.                @ 22, 52 PROMPT ' History files '
  74.                file_types = 1
  75.                MENU TO file_types
  76.  
  77.                * Create array of files for backup. Any file type
  78.                * can be placed in the array, including compressed
  79.                * or archived files. The TEMPn.TXT files below are 
  80.                * samples only. In this example, file names are
  81.                * hard coded in the array. You can also load the 
  82.                * array with the Clipper DIRECTORY function.
  83.  
  84.                IF file_types = 1
  85.                    ASIZE(filelist, 6)
  86.                    filelist[1] = "TEMP1.TXT"
  87.                    filelist[2] = "TEMP2.TXT"
  88.                    filelist[3] = "TEMP3.TXT"
  89.                    filelist[4] = "TEMP4.TXT"
  90.                    filelist[5] = "TEMP5.TXT"
  91.                    filelist[6] = "TEMP6.TXT"
  92.                ELSEIF file_types = 2
  93.                    ASIZE(filelist, 2)
  94.                    filelist[1] = "TEMP7.TXT"
  95.                    filelist[2] = "TEMP8.TXT"
  96.                ELSE
  97.                    LOOP
  98.                ENDIF
  99.            ELSEIF mode = 0
  100.                LOOP
  101.            ENDIF
  102.  
  103.            * Call SYSSAVE to perform selected operation.
  104.            * For this example, we are using single-line mode,
  105.            * and we have hard-coded the backup drive as A.
  106.  
  107.            error_flag = SYSSAVE(mode + 2, "A", filelist)
  108.  
  109.            IF error_flag !=  0
  110.                * Error occurred, display its number
  111.                ?? CHR(7)
  112.                CENTERON(24, IF(mode = 1, 'Backup', 'Restore') + ;
  113.                         ' operation failed with error number '+ ;
  114.                           LTRIM(STR(error_flag)) )
  115.  
  116.                INKEY(0)
  117.            ENDIF
  118.  
  119.     OTHERWISE
  120.            IF choice != 0 .AND. choice != 7
  121.                ERRORBEEP()
  122.                CENTERON(24, 'Option not installed. ' + hitanykey)
  123.                INKEY(0)
  124.            ENDIF
  125.     ENDCASE
  126. ENDDO
  127.  
  128. CLEAR
  129. RETURN
  130.  
  131.