home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 8 / CDASC08.ISO / VRAC / MAKEZIP.ZIP / MAKEZIP.PRG < prev    next >
Text File  |  1993-08-07  |  6KB  |  158 lines

  1. /*┌──────────────────────────────────────────────────────────────────────┐
  2.  ▌│                                                                      │
  3.  ▌│ Program Name: MAKEZIP.PRG       Copyright: Gallagher Computing Corp. │
  4.  ▌│     Language: Clipper 5.2                                            │
  5.  ▌│       Author: Kevin S Gallagher                                      │
  6.  ▌├──────────────────────────────────────────────────────────────────────┤
  7.  ▌│ Comments:                                                            │
  8.  ▌│ This utility is a remake of one that i created sometime ago. In this │
  9.  ▌│ version I'am playing with TinitFile class (c) RUNsoft, created by    │
  10.  ▌│ Antonio Linares.                                                     │
  11.  ▌│                                                                      │
  12.  ▌│ There may be sections of code that may appear to need more safety    │
  13.  ▌│ features/error checking, but we are all smart enough (i hope) to not │
  14.  ▌│ need them - feel free to add um if so desired..                      │
  15.  ▌├──────────────────────────────────────────────────────────────────────┤
  16.  ▌│ History:                                                             │
  17.  ▌│ 06/93 - recoded for trying out TiniFile Class (c)                    │
  18.  ▌└──────────────────────────────────────────────────────────────────────┘
  19.  ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀           */
  20.  
  21. #include "init.h"
  22.  
  23. static LISTFILE, ZIPFILE
  24. static nHandle, aFiles, Stable := {} 
  25.  
  26. function DoBackups()
  27.     local nAsk, i, cZipName := GET_ZIP_NAME(), nCount:=0, aArr_ := {}
  28.     local NoteFile := GET_COMMENT_FILE()
  29.  
  30.     LISTFILE := GET_LIST_FILE() 
  31.     ZIPFILE  := GET_ZIP_FILE()
  32.     aFiles   := ListAsArray( GET_LOCAL_FILES() )
  33.  
  34.     aArr_ :=  ListAsArray( GET_OBJ_FILE() )
  35.     if ( nCount := len( aArr_) ) <> 0
  36.         aeval( aArr_, { |a| aadd( Stable, a) } )
  37.     endif
  38.  
  39.     aArr_ :=  ListAsArray( GET_LIB_FILE() )
  40.     if ( nCount := len( aArr_) ) <> 0
  41.         aeval( aArr_, { |a| aadd( Stable, a) } )
  42.     endif
  43.     
  44.     if file(ZIPFILE)
  45.         scroll()
  46.         nAsk := alert( ASK_USER_METHOD, {" Update ", " Delete ", " Quit "} )
  47.         do case
  48.             case nAsk == 1
  49.                 @ROW(),0 SAY PADR(" FRESHEN "+ZIPFILE,80)
  50.                 //───── Blinker function to run external program
  51.                 SwpRunCmd( cZipName + " -f "+ZIPFILE, 0, "")
  52.                 QUIT
  53.             case nAsk == 2
  54.                 if alert( ASK_OK_TO_DELETE,{ " No ", " Yes "}) == 2
  55.                     ferase( ZIPFILE )
  56.                 else
  57.                     //───── let um restart utility!
  58.                     alert("ABONDONING DELETE;AND QUITING PROGRAM",{" QUIT "})
  59.                     quit
  60.                 endif
  61.             case nAsk == 3
  62.                 @0,0 SAY PADR(" OPERATION ABORTED",80) color "W+/R"
  63.                 QUIT
  64.         endcase
  65.     endif
  66.  
  67.     nHandle:= fcreate(LISTFILE,FC_NORMAL)
  68.     aeval( aFiles, {|v| aeval( asort( directory("*."+v),,,aBlock),bBlock) } )
  69.     aeval( Stable, {|v| ShowIt(v) } )
  70.     fclose(nHandle)
  71.     nAsk:=alert("Edit list file",{" Yes ", " No "})
  72.     if nAsk = 1
  73.         EditText(LISTFILE, .T.)
  74.     endif
  75.  
  76.     if file( NoteFile )
  77.         nAsk := alert("Edit comments for;"+GET_TITLE(), {" Yes ", " No "} )
  78.         if nAsk = 1
  79.             EditText( NoteFile, .T.)
  80.         endif
  81.     else
  82.         nAsk := alert("Create comments for;"+GET_TITLE(), {" Yes ", " No "} )
  83.         if nAsk = 1
  84.             if ( nHandle:= fcreate(NoteFile,FC_NORMAL)) =-1
  85.                 ALERT("ERROR CREATING "+NoteFile)
  86.                 quit
  87.             endif
  88.             nHandle := fcreate(NoteFile,FC_NORMAL)
  89.             EditText(NoteFile, .T.)
  90.         endif
  91.     endif
  92.  
  93.     dispbox(1,0,MR,MAXCOL(),SPACE(9),"W/N")
  94.     SwpRunCmd( cZipName + " "+ZIPFILE+" @"+LISTFILE, 0, "")
  95.  
  96.     if file(NoteFile)
  97.         nHandle:= fopen(NoteFile,0)
  98.         if ferror() == 0 .AND. fseek(nHandle,0,2) > 3
  99.             fclose(nHandle)
  100.         endif
  101.         SwpRunCmd( cZipName + " " + ZIPFILE + " -z < " + NoteFile,0)
  102.     endif
  103.     //───── erase pkzip list file
  104.     if FERASE(LISTFILE)== -1
  105.         alert(LSTRINT( ferror() ) )
  106.     endif
  107.     //───── you may want to erase the comment file also?
  108.     scroll()
  109. return nil
  110.  
  111. function ShowIt(cFile)
  112.     FWriteLine(nHandle,cFile)
  113. return nil
  114.  
  115. function EditText(cFileName, lEditMode)
  116.    local cContents, lWrite := .F., cClr, nCurs, oldins
  117.    set(_SET_SCOREBOARD,.F.)
  118.    lEditMode :=.T.
  119.    cContents := memoread(cFileName)
  120.    cClr      := setcolor("bg+/b")
  121.    nCurs     := setcursor(1)
  122.    @00,00 say replicate(" ",80)                      color "gr+/bg"
  123.    @MR,00 say padr(" ",80)                           color "bg /bg"
  124.    @00,00 say "Edit: "+ cFileName                    color "w+ /bg"
  125.    @MR,60 say "Line:"                                color "gr+/bg"
  126.    @MR,72 say "Col:"                                 color "gr+/bg"
  127.    @MR,00 say " F2 = Save/Exit   F10 = Abort/Exit"   color "n  /bg"
  128.    oldins:=readinsert(.T.)
  129.    cContents=MEMOEDIT(cContents,1,0,MR-1,79,lEditMode, "MemoUDF", 250)
  130.    if lastkey() = K_F2
  131.       lWrite:=MEMOWRIT( rtrim(cFileName), cContents )
  132.    endif
  133.    readinsert(oldins)
  134.    SETCOLOR(cClr)
  135.    IF lEditMode
  136.       setcursor(nCurs)
  137.    ENDIF
  138. return nil
  139.  
  140. function MemoUDF( nMode, nLin, nCol )
  141.    local nKey, nRval
  142.    nRval := 0
  143.    nKey  := LASTKEY()
  144.    IF nMode == 0
  145.       @MR,66 say nLin picture "9999" color "w+/bg"
  146.       @MR,77 say nCol picture "999"  color "w+/bg"
  147.    ELSEIF nMode == 1 .OR. nMode == 2
  148.       do case
  149.           case nKey == K_F10
  150.               nRval := 27
  151.           case nKey == K_F2
  152.               nRval := 23
  153.       endcase
  154.    ENDIF
  155. return (nRval)
  156.  
  157.  
  158.