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

  1. /*┌──────────────────────────────────────────────────────────────────────┐
  2.  ▌│                                                                      │
  3.  ▌│ Program Name: BUILD.PRG         Copyright: Gallagher Computing Corp. │
  4.  ▌│     Language: Clipper 5.2                                            │
  5.  ▌│       Author: Kevin S Gallagher                                      │
  6.  ▌│                                                                      │
  7.  ▌├──────────────────────────────────────────────────────────────────────┤
  8.  ▌│ Comments:                                                            │
  9.  ▌│ This utility is a remake of one that i created sometime ago. In this │
  10.  ▌│ version I'am playing with TinitFile class (c) RUNsoft, created by    │
  11.  ▌│ Antonio Linares.                                                     │
  12.  ▌│                                                                      │
  13.  ▌│ There may be sections of code that may appear to need more safety    │
  14.  ▌│ features/error checking, but we are all smart enough (i hope) to not │
  15.  ▌│ need them - feel free to add um if so desired..                      │
  16.  ▌├──────────────────────────────────────────────────────────────────────┤
  17.  ▌│ History:                                                             │
  18.  ▌│ 06/93 - recoded for trying out TiniFile Class (c)                    │
  19.  ▌└──────────────────────────────────────────────────────────────────────┘
  20.  ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀           */
  21.  
  22. #include "init.h"
  23.  
  24. static oIni, lFlag :=.t., xIniFile := "PINIT.INI"
  25.  
  26. /*
  27. * function: main
  28. *  purpose: decides which operation to carry out
  29. * comments:
  30. */
  31. function main( cParm )
  32.     do case
  33.         case cParm == nil
  34.             if !lFlag
  35.                 if !EditInit()
  36.                     abortProg(1)
  37.                 endif
  38.             endif
  39.             if alert("BACKUP;"+GET_TITLE()+";FILES",{" Yes ", " No "}) == 1
  40.                 DoBackups()
  41.             else
  42.                 abortProg()
  43.             endif
  44.         case upper(cParm) == "/E"
  45.             //───── edit init file
  46.             EditInit()
  47.         case upper(cParm) == "/?" .or. upper(cParm) == "/H"
  48.             //───── show help on utility - tweak if so desired
  49.             cls
  50.             @0,0  say padr(" Using MakeZip",80) color "n/w"
  51.             @2,0  say "Executing MakeZip with no parameters:"
  52.             @3,0  say "* Create a configuration file if one does not exist"
  53.             @4,0  say "* Calls Pkzip to create a zipfile, if zipfile does not exist"
  54.             @5,0  say "* Calls Pkzip to freshen zipfile, if one exist"
  55.             @6,0  say "MakeZip /"
  56.             @6,9  say "E" color "w+/n"
  57.             @6,10 say "dit configuration file or create one if it does not exist"
  58.             @7,0  say "MakeZip /"
  59.             @7,9  say "?" color "w+/n"
  60.             @7,11 say "calls this screen"
  61.             BREAK
  62.     endcase
  63.  
  64.     CLOSE_INIT_FILE()
  65.  
  66. return nil
  67.  
  68. /*
  69. * function: ListAsArray( <cList> [, <cDelimiter>] ) --> array
  70. *  purpose: transforms a string into an array
  71. * comments: by default the string is parsed by searching for commas unless
  72. *         : a delimiter is supplied to override the comma ie., "-/;" etc.
  73. */
  74. function ListAsArray( cList, cDelimiter )
  75.     local nPos, aList := {}
  76.  
  77.     cDelimiter := IfNil(cDelimiter,[,])
  78.     
  79.     while ( nPos := at(cDelimiter, cList) ) != 0
  80.         aadd( aList, substr( cList, 1, nPos - 1) )
  81.         cList := substr( cList, nPos + 1 )
  82.     enddo
  83.     aadd( aList, cList )
  84. return aList
  85.  
  86. /*
  87. * function: BuildInit( <initialized object> )  --> nil
  88. *  purpose: Creates a init file if it does not exit
  89. * comments: Must call tinitfile() prior to calling this function
  90. */
  91. function BuildIni( oIni )
  92.     oIni:Set(  MAIN_TITLE    ,  "Project Undefined" )
  93.     oIni:Set(  LIST_FILE     ,  ""                  )
  94.     oIni:Set(  ZIP_FILE      ,  ""                  )
  95.     oIni:Set(  EXT_LIST      ,  MyLocalList         )
  96.     oIni:Set(  OBJ_LIST      ,  ""                  )
  97.     oIni:Set(  LIB_LIST      ,  ""                  )
  98.     oIni:Set(  ZIP_NAME      ,  "PKZIP"             )
  99.     oIni:Set(  UNZIP_FILE    ,  "PKUNZIP"           )
  100.     oIni:Set(  COMMENT_FILE  ,  "COMMENTS.TXT"      )
  101.  
  102.     WRITE_TO_INIT() 
  103. return nil
  104.  
  105. /*
  106. * function: EditInit
  107. *  purpose: Allows a user to edit init under program control
  108. * comments: This is not really needed unless the user is not be to trusted
  109. *         : at the DOS level to open/edit the init file. Also note that the
  110. *         : gets have thier colors assigned in a for-next loop, this was
  111. *         : done so that all the code is within the 80 columns of my editor.
  112. *         : The dispbegin()/dispend() makes the painting of the gets not to
  113. *         : be shown during the redisplaying process!
  114. *         : Note - I really cheated on the shadow effect also¡
  115. */
  116. static function EditInit
  117.     local SaveFullScreen(),oldcolor :=setcolor("w+/rb"),nCount :=len(aPic_)
  118.     local getlist as arrays
  119.     local i as ints
  120.     local cTitle, cListFile, cZipFile, cExtList, cObjs as chars
  121.     local cLibs, cZip, cUnZip,cComments  as chars
  122.     local aArr_ := ReadInitFile(), lFlag := .t.
  123.  
  124.     cTitle      :=  padr( aArr_[1] ,  60 )
  125.     cListFile   :=  padr( aArr_[2] ,  12 )
  126.     cZipFile    :=  padr( aArr_[3] ,  12 )
  127.     cExtList    :=  padr( aArr_[4] ,  70 )
  128.     cObjs       :=  padr( aArr_[5] , 200 )
  129.     cLibs       :=  padr( aArr_[6] , 200 )
  130.     cZip        :=  padr( aArr_[7] ,  12 )
  131.     cUnZip      :=  padr( aArr_[8] ,  12 )
  132.     cComments   :=  padr( aArr_[9] ,  12 )
  133.  
  134.     DISPBEGIN()
  135.  
  136.     dispbox(0,0,maxrow(),maxcol(),"░░░░░░░░░"  ,"b+/b" )
  137.     dispbox(3,2,15,maxcol()-1,    "░░░░░░░░░"  ,"n+/n" )
  138.     dispbox(2,1,14,maxcol()-3,     B_SINGLE+" ","w+/rb")
  139.  
  140.     @0,0 say padc("Editing initialization file",80) color "n/bg"
  141.  
  142.     @ 3,4 say "  Title for program:"
  143.     @ 4,4 say "        PKlist file:"
  144.     @ 5,4 say "         PKzip file:"
  145.     @ 6,4 say "        Local Files:"
  146.     @ 7,4 say "     Remote objects:"
  147.     @ 8,4 say "   Remote libraries:"
  148.     @ 9,4 say "  Name of Pkzip.exe:"
  149.     @10,4 say "Name of Pkunzip.exe:" 
  150.     @11,4 say "  Comment file name:"
  151.  
  152.     @ 3,26 get  cTitle     picture  aPic_[1]
  153.     @ 4,26 get  cListFile  picture  aPic_[2] valid Parsename(cListFile)
  154.     @ 5,26 get  cZipFile   picture  aPic_[3] valid Parsename(cZipFile)
  155.     @ 6,26 get  cExtList   picture  aPic_[4] valid !empty(cExtList)
  156.     @ 7,26 get  cObjs      picture  aPic_[5]
  157.     @ 8,26 get  cLibs      picture  aPic_[6]
  158.     @ 9,26 get  cZip       picture  aPic_[7] valid !empty(cZip)
  159.     @10,26 get  cUnZip     picture  aPic_[8] valid !empty(cUnZip)
  160.     @11,26 get  cComments  picture  aPic_[9] valid !empty(cComments)
  161.  
  162.     for i := 1 to nCount
  163.         getlist[i]:colorSpec := Get_Colors
  164.         getlist[i]:display()
  165.     next
  166.  
  167.     DISPEND()
  168.  
  169.     if KSGREAD( 2 )
  170.         oIni:Set(  MAIN_TITLE    , alltrim( cTitle    ) )
  171.         oIni:Set(  LIST_FILE     , alltrim( cListFile ) )
  172.         oIni:Set(  ZIP_FILE      , alltrim( cZipFile  ) )
  173.         oIni:Set(  EXT_LIST      , alltrim( cExtList  ) )
  174.         oIni:Set(  OBJ_LIST      , alltrim( cObjs     ) )
  175.         oIni:Set(  LIB_LIST      , alltrim( cLibs     ) )
  176.         oIni:Set(  ZIP_NAME      , alltrim( cZip      ) )
  177.         oIni:Set(  UNZIP_FILE    , alltrim( cUnZip    ) )
  178.         oIni:Set(  COMMENT_FILE  , alltrim( cComments ) )
  179.         WRITE_TO_INIT() 
  180.     else
  181.         alert("ABORTING SAVES")
  182.         lFlag := .f.
  183.     endif
  184.  
  185.     setcolor(oldcolor)
  186.     RestFullScreen()
  187. return lFlag
  188.  
  189. function Parsename( cString )
  190.     local lRetVal := .F., cMsg := ""
  191.     do case
  192.         case empty( cString )
  193.             cMsg := "CAN NOT BE LEFT EMPTY"
  194.         case at(".",cString) == 0
  195.             cMsg := "NO PERIOD ENTERED"
  196.         case at(".",cString) >= 9
  197.             cMsg := "BASE FILENAME GREATER THAN 8 CHARACTERS"
  198.         otherwise
  199.             lRetVal := .T.
  200.     endcase
  201.  
  202.     if !lRetVal
  203.         tone(100,1);tone(70,1);tone(100,1)
  204.         alert( cMsg, { " ERROR " } )
  205.     endif
  206. return lRetVal
  207.  
  208. /*
  209. * function: ReadInitFile() --> 
  210. *  purpose: used to allow program to read in values in the disk init file
  211. * comments: returns aVars_[ nflag ] or entire array
  212. */
  213. function ReadInitFile(nFlag)
  214.     local aVars_ :=               ;
  215.     { oIni:cGet( MAIN_TITLE    ) ,;
  216.       oIni:cGet( LIST_FILE     ) ,;
  217.       oIni:cGet( ZIP_FILE      ) ,;
  218.       oIni:cGet( EXT_LIST      ) ,;
  219.       oIni:cGet( OBJ_LIST      ) ,;
  220.       oIni:cGet( LIB_LIST      ) ,;
  221.       oIni:cGet( ZIP_NAME      ) ,;
  222.       oIni:cGet( UNZIP_FILE    ) ,;
  223.       oIni:cGet( COMMENT_FILE  )  ;
  224.     }
  225.  
  226.     if valtype(nFlag) == "N"
  227.         return aVars_[nFlag]
  228.     endif
  229.  
  230. return aVars_
  231.  
  232. function abortProg( nDelete )
  233.     CLOSE_INIT_FILE()
  234.     if valtype( nDelete ) == "N"
  235.         ferase(xIniFile)
  236.     endif
  237.     quit
  238. return nil
  239.  
  240. /*
  241. * function: IsInitHere
  242. *  purpose: check to see if there is a init file, and creates one if not
  243. * comments: [INIT] function is undocumented, and works in Clipper 5.2/5.1
  244. */
  245. init procedure IsInitHere
  246.     set(_SET_SCOREBOARD,.F.)
  247.  
  248.     OPEN_INIT_FILE()
  249.  
  250.     if !file(xIniFile)
  251.         lFlag := .f.
  252.         BuildIni( oIni )
  253.     endif
  254. return 
  255.  
  256. announce rddsys
  257. init procedure rddinit()
  258.     //───── no rdd please
  259. return
  260.  
  261. exit procedure SoLong
  262.     if errorlevel() <> 0
  263.         inkey(0)
  264.     endif
  265.     setcolor("w/n")
  266.     cls
  267. return
  268.