home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 15 / CD_ASCQ_15_070894.iso / news / 769 / s3meta.prg < prev    next >
Text File  |  1994-04-22  |  9KB  |  339 lines

  1. STATIC lDbfOpen      := .F.
  2. STATIC cDbfName      := ""
  3. STATIC nIndexOrd     := 0
  4. STATIC cDefaultDir   := ""
  5. STATIC aIndexes      := {}
  6.  
  7. memvar getlist
  8.  
  9.  
  10. PROC SUPERSUPER()
  11. local cInScreen := savescreen(0,0,24,79)
  12. local aMenuOpts := array(7)
  13. local aMenuDefs := array(7)
  14. local nSelection,cPopBox
  15. local cNewIndex
  16. local nInSelect := select()
  17. SELECT 0
  18.  
  19. *- initialize superfunctions
  20. SLS_ISCOLOR( PCOUNT()=0 )
  21. slsf_color("S3COLOR")
  22. INITSUP(.F.)
  23.  
  24. cDbfName := ''
  25. CLOSE DATA
  26. aIndexes := {}
  27. lDbfOpen := .F.
  28. sls_query("")
  29. sls_bquery(nil)
  30.  
  31. *- set some sets
  32. SET TALK OFF
  33. SET ECHO OFF
  34. SET CONFIRM OFF
  35. SET BELL OFF
  36. SET SAFETY OFF
  37. SET SCOREBOARD OFF
  38. SET TYPEAHEAD TO 50
  39.  
  40. *- set color
  41. Setcolor(sls_normcol())
  42.  
  43. *- draw the screen
  44. paint_sf()
  45.  
  46.  
  47. *- menu choice definitions
  48. aMenuOpts[1] := "Files:Select:Define:Copy:Append:Field Copy:Export:Mailmerge"
  49. aMenuOpts[2] := "Indexes:Select:Order:New"
  50. aMenuOpts[3] := "Editing:Edit:Global Replace:Tabular Edit"
  51. aMenuOpts[4] := "Reporting:Build Query:Print Lists:Duplicates:Create Labels:Write Form Letters:Sum or Average a Field:DBF Field Frequency Analysis:Time Analysis:REPORT WRITER!:Statistics"
  52. aMenuOpts[5] := "Appearance:Screen Appearance:Predefined Colors"
  53. aMenuOpts[6] := "Utility:List text file:Directory:Todo List:Calendar:"+;
  54.                  "Solar Calculator:Weights&Measures:Appointments"
  55. aMenuOpts[7] := "Quit:Quit"
  56. nSelection = 1.01
  57.  
  58. *- define menu boxes
  59. aMenuDefs[1] := .f.               && draw the top bar box ?
  60. aMenuDefs[2] := sls_normcol()      && top bar color string
  61. aMenuDefs[3] := sls_popmenu()      && drop box color
  62. aMenuDefs[4] := sls_frame()        && drop box frame
  63. aMenuDefs[5] := 3                 && drop box shadow position (1,3,7,9,0)
  64. aMenuDefs[6] := sls_shadatt()      && drop box shadow attribute
  65. aMenuDefs[7] := 1             && row # of menu bar
  66.  
  67. DO WHILE .T.
  68.    sf_show()                   && display dbfs and indexes
  69.    
  70.    *- do the menu
  71.    nSelection := pulldn(nSelection,aMenuOpts,aMenuDefs)
  72.    
  73.    
  74.    *- if 0 returned, selection is QUIT
  75.    IF nSelection = 0
  76.       nSelection := 7.01
  77.    ENDIF
  78.    nSelection := val(trans(nSelection,"9.99"))
  79.    
  80.    *- do the action corresponding to the menu choice
  81.    DO CASE
  82.    CASE nSelection = 1.01     && select a DBF
  83.       
  84.       IF Adir('*.dbf') > 0
  85.          sf_pickdbf(.f.)
  86.       ELSE
  87.          msg("No DBFs detected in this directory")
  88.       ENDIF
  89.       
  90.       
  91.    CASE nSelection = 1.02   && modify structure
  92.       USE
  93.       modify()
  94.       USE
  95.       if lDbfOpen
  96.         sf_pickdbf(.T.)
  97.         openind(aIndexes,getdfp())       && open them
  98.       endif
  99.       
  100.    CASE nSelection < 5  .AND. !lDbfOpen
  101.       msg("Need a DBF open for this option")
  102.       
  103.       
  104.    CASE nSelection = 1.03   && copy records out
  105.  
  106.       copyitout()
  107.       
  108.    CASE nSelection = 1.04   && append records in
  109.       appendit()
  110.  
  111.    CASE nSelection = 1.05   && copy fields
  112.       copyfields()
  113.    CASE nSelection = 1.06   && export
  114.       sexport()
  115.    CASE nSelection = 1.07   && mailmerge
  116.       smailmerge()
  117.       
  118.    CASE nSelection =2.01                && select indexes
  119.       IF Adir('*'+IndexExt()) > 0
  120.          pickndx(aIndexes,getdfp(),.f.)
  121.       else
  122.          msg("No indexes present")
  123.       ENDIF
  124.       
  125.    CASE nSelection = 2.02   .AND. len(aIndexes) > 0
  126.       sf_order()      && change index order
  127.    CASE nSelection = 2.03        && make temp index
  128.       cNewIndex := bldndx(NIL,NIL,NIL,.T.)
  129.       IF !EMPTY(cNewIndex)
  130.          aadd(aIndexes,"")
  131.          Ains(aIndexes,1)    && insert in active index array
  132.          aIndexes[1] := Alltrim(cNewIndex)+Indexext()
  133.          openind(aIndexes,getdfp())       && open them
  134.          nIndexOrd   := 1
  135.       ENDIF
  136.  
  137.    CASE nSelection = 3.01            && vertical edit
  138.       VIEWPORT(.T.)
  139.       
  140.    CASE nSelection = 3.02            && global replace
  141.       globrep()
  142.       
  143.    CASE nSelection = 3.03            && horizontal edit
  144.       editdb(.T.)
  145.       
  146.    CASE nSelection = 4.01            && query
  147.       QUERY()
  148.       
  149.       
  150.    CASE nSelection = 4.02            && print list
  151.       lister()
  152.       
  153.    CASE nSelection = 4.03            && hunt duplicates
  154.       if messyn("Duplicates","Listing only","Delete and/or copy")
  155.         duplook(NIL,aIndexes)
  156.       else
  157.         duphandle(nil,nil,aIndexes)
  158.       endif
  159.       
  160.    CASE nSelection = 4.04            && labels
  161.       clabel()
  162.       
  163.    CASE nSelection = 4.05        && form letter
  164.       formletr()
  165.       
  166.    CASE nSelection = 4.06     && sum/AVERAGE
  167.       IF messyn("Sum or Average?","Sum","Average")
  168.          sum_ave()
  169.       ELSE
  170.          sum_ave("AVE")
  171.       ENDIF
  172.       
  173.       
  174.    CASE nSelection = 4.07    && occurance
  175.       freqanal()
  176.    CASE nSelection = 4.08    && time analysis
  177.       TIMEPER()
  178.    CASE nSelection = 4.09    && report writer
  179.       REPORTER()
  180.    CASE nSelection = 4.10    && stats
  181.       DBSTATS()
  182.       
  183.       
  184.    CASE nSelection = 5.01            && color setting
  185.       setcolors()
  186.       SETCOLOR(sls_normcol())
  187.       paint_sf()            && repaint screen
  188.       
  189.       *- redefine menu box data
  190.       aMenuDefs[1] = .F.
  191.       aMenuDefs[2] = sls_normcol()
  192.       aMenuDefs[3] = sls_popmenu()
  193.       aMenuDefs[4] = sls_frame()
  194.       aMenuDefs[5] = sls_shadpos()
  195.       aMenuDefs[6] = sls_shadatt()
  196.       aMenuDefs[7] = 1
  197.       
  198.    CASE nSelection = 5.02            && predefined colors
  199.       colpik()
  200.       SETCOLOR(sls_normcol())
  201.       paint_sf()            && repaint screen
  202.       
  203.       *- redefine menu box data
  204.       aMenuDefs[1] = .F.
  205.       aMenuDefs[2] = sls_normcol()
  206.       aMenuDefs[3] = sls_popmenu()
  207.       aMenuDefs[4] = sls_frame()
  208.       aMenuDefs[5] = sls_shadpos()
  209.       aMenuDefs[6] = sls_shadatt()
  210.       aMenuDefs[7] = 1
  211.       
  212.       
  213.    CASE nSelection = 6.01    && list text file
  214.       Fileread()
  215.    CASE nSelection = 6.02  && dir picker
  216.          cDefaultDir := ""
  217.          fulldir(.F.,@cDefaultDir)
  218.          IF !EMPTY(cDefaultDir)
  219.            set default to (cDefaultDir)
  220.            CLOSE DATA
  221.            cDbfName := ''
  222.            aIndexes := {}
  223.            lDbfOpen := .F.
  224.            sls_query("")
  225.            sls_bquery(nil)
  226.            paint_sf()
  227.          ENDIF
  228.       
  229.    CASE nSelection = 6.03  && todo list
  230.       todolist()
  231.       
  232.    CASE nSelection = 6.04  && calendar
  233.       getdate()
  234.  
  235.    CASE nSelection = 6.05  && calculator
  236.       getcalc()
  237.    CASE nSelection = 6.06  && weights&measures
  238.       wgt_meas()
  239.    CASE nSelection = 6.07  && appointments
  240.       sappoint()
  241.       
  242.    CASE nSelection = 7.01            && quit
  243.       IF messyn('Are you sure?')
  244.          SET CURSOR ON
  245.          ss_fold(0,0,24,79,cInscreen)
  246.          EXIT
  247.       ENDIF
  248.    ENDCASE
  249. enddo
  250. CLOSE DATA
  251. cDbfName := ''
  252. aIndexes := {}
  253. lDbfOpen := .F.
  254. SELECT (nInSelect)
  255. RETURN
  256.  
  257.  
  258. //-----------------------------------------------------------------
  259. STATIC FUNCTION sf_pickdbf(lByPass)
  260. local cDbfnoext,cDbfPick
  261. if !lBypass
  262.   cDbfpick := popex(getdfp()+'*.dbf')
  263. else
  264.   cDbfpick := cDbfName
  265. endif
  266. IF !EMPTY(cDbfpick)
  267.    cDbfnoext := STRIP_PATH(cDbfpick,.t.)
  268.    IF SNET_USE(cDbfpick,cDbfnoext,.f.,5,.t.,"Network error opening "+cDbfpick+" . Keep trying?")
  269.      IF !used()
  270.         USE
  271.         msg("UNABLE TO OPEN "+cDbfpick+"- POSSIBLY CORRUPT OR .DBT FILE MISSING  ")
  272.      ENDIF
  273.    endif
  274.    *- set globals
  275.    if USED() .AND. !lBypass
  276.       lDbfOpen := .T.
  277.       sls_query("")
  278.       cDbfName := cDbfPick
  279.       aIndexes := {}
  280.    elseif !used()
  281.       lDbfOpen := .F.
  282.       sls_query("")
  283.       cDbfName := ""
  284.       aIndexes := {}
  285.    endif
  286. ENDIF
  287. RETURN ''
  288.  
  289. //----------------------------------------------------------
  290. STATIC FUNCTION sf_order
  291. local nOrder := nIndexOrd
  292. nIndexOrd := mchoice(aIndexes,10,10,20,60,"Select Controlling Index")
  293. IF nIndexOrd = 0
  294.    nIndexOrd = nOrder
  295. ELSE
  296.    SET ORDER TO (nIndexOrd)
  297. ENDIF
  298. RETURN ''
  299.  
  300. //----------------------------------------------------------
  301. STATIC FUNCTION paint_sf
  302.  
  303. Setcolor(sls_normcol())
  304. CLEAR
  305. *- draw center box with C function bxx()
  306. dispbox(0,0,24,79)
  307. dispbox(3,1,17,77,'▒▒▒▒▒▒▒▒▒')
  308. @2,1 to 2,78
  309. @18,1 to 18,78
  310. @20,03 SAY   "Datafile in use   -  "
  311. @21,03 SAY   "Indexes in use    -  "
  312. @22,3  SAY   "Current Directory -  "
  313. RETURN ''
  314.  
  315. //----------------------------------------------------------
  316. STATIC FUNCTION sf_show
  317. local i
  318. local cRecords
  319. *- display the dbfs and indexes
  320. Scroll(20,24,23,78,0)
  321. if !empty(getdfp() )
  322.   @22,24 say getdfp()
  323. else
  324.   @22,24 say Curdir()
  325. endif
  326. IF lDbfOpen
  327.    cRecords := IIF(!EMPTY(cDbfName),' Containing '+Alltrim(STR(RECC()))+;
  328.                 ' RECORDS','')
  329.    @20,24 SAY cDbfName+cRecords
  330.    devpos(21,24)
  331.    for i = 1 to len(aIndexes)
  332.      ??aIndexes[i]+" "
  333.    next
  334. ENDIF
  335. RETURN ''
  336.  
  337.  
  338.  
  339.