home *** CD-ROM | disk | FTP | other *** search
/ DOS Wares / doswares.zip / doswares / DATABASE / DBASE5 / CUA_SAMP.ZIP / OPENFILE.PRG < prev    next >
Encoding:
Text File  |  1994-06-24  |  26.1 KB  |  764 lines

  1. PROCEDURE OpenFile
  2. PARAMETER poReturn
  3. *----------------------------------------------------------------------
  4. * DESCRIPTION
  5. *   Driver program for: OpenFile.DFM
  6. *   
  7. *   Returns an object that contains the file name, and
  8. *   the action to take.
  9. *   poReturn.FileSpec   - To start.
  10. *           .ShowRadio  - Show the radio buttons
  11. *           .ModText    - Start text for Modify radio button
  12. *           .DoText     - Start text for Do It radio button
  13. *           .TypeArray  - Array with file types in it
  14. *           .TypeStart  - Value of type to start
  15. *           .FormTitle  - Title for the form
  16. *           .FileName   - Name of file selected, <blank> if cancelled
  17. *           .FileMod    - Modify radiobutton selected
  18. *           .DoIt       - Do radiobutton selected
  19. *           .NewName    - Set to .T. if file name doesn't exist already
  20. *           .StrtName   - Default filename, only used if TYPE() = "C"
  21. *           .HelpVal    - HelpID to display when help is selected
  22. *
  23. *----------------------------------------------------------------------
  24. #define cSlash  "\"
  25.  
  26.     PRIVATE cStartSpec, cTypeValue, cArray, nLenMod, nLenDo, nWidth, ;
  27.             lVoid, cDirPath, cFileName
  28.             
  29.     #include "TALKOFF.HDB"            
  30.  
  31. #define FN_FULLPATH  0
  32. #define FN_PATH      1
  33. #define FN_FILEROOT  2
  34. #define FN_FILETYPE  3
  35. #define FN_FILENAME  4
  36. #define FN_VALIDFILE 5
  37.  
  38.  
  39.     cStartSpec = poReturn.FileSpec
  40.     cTypeValue = poReturn.TypeStart
  41.  
  42. #include  "OpenFile.DFM"
  43.  
  44.     OpenFile.Text = poReturn.FormTitle
  45.  
  46.     *------------------------------
  47.     *-- Build the file list listbox
  48.     *------------------------------
  49.     DO BldFile WITH poReturn.FileSpec, OpenFile.lbName3
  50.  
  51.     *--------------------------------------
  52.     *-- Set up the items for the File Types
  53.     *--------------------------------------
  54.     cArray = poReturn.TypeArray
  55.     cAName = m->cArray + "[1]"
  56.     IF TYPE( m->cAName ) = "C"
  57.         OpenFile.cbName5.DataSource = "ARRAY " + m->cArray
  58.     ELSE
  59.         OpenFile.cbName5.DataSource = "STRING " + m->cArray
  60.     ENDIF
  61.  
  62.  
  63.     OpenFile.efName2.Value = LEFT( m->cStartSpec + SPACE(80), 80 )
  64.  
  65.     *--------------------------------------------------
  66.     *-- Start the current directory for reset on return
  67.     *--------------------------------------------------
  68.     cDirStash = SET( "DIRECTORY" )
  69.     OpenFile.txName7.Text = m->cDirStash
  70.     OpenFile.txName7.Width = OpenFile.Width - OpenFile.txName7.Left - 2
  71.     OpenFile.txName7.Height = 1
  72.  
  73.     *------------------------------------------------------------
  74.     *-- Make sure the first item in the list matches the wildcard
  75.     *------------------------------------------------------------
  76.     lExact = SET( "EXACT" ) = "ON"
  77.     SET EXACT OFF
  78.     IF TYPE( m->cAName ) = "C"
  79.         nCurSel = ASCAN( &cArray, m->cTypeValue )
  80.         nCurSel = MAX( 1, m->nCurSel )
  81.         OpenFile.cbName5.CurSel  = m->nCurSel
  82.     ENDIF
  83.     OpenFile.ActiveType = m->cTypeValue
  84.  
  85.     IF m->lExact
  86.         SET EXACT ON
  87.     ENDIF
  88.  
  89.     *---------------------------------------
  90.     *-- Make sure current drive item matches
  91.     *---------------------------------------
  92.     nCurSel = 1
  93.     cLastBar = OpenFile.lbDrives.Value
  94.     cCurDrive = LEFT( SET("DIRECTORY"), 2 )
  95.     DO WHILE .T.
  96.         cThisBar = TRIM( OpenFile.lbDrives.Value )
  97.         IF m->cThisBar == m->cCurDrive
  98.             EXIT
  99.         ENDIF
  100.  
  101.         nCurSel = m->nCurSel + 1
  102.         OpenFile.lbDrives.CurSel = m->nCurSel
  103.         IF OpenFile.lbDrives.Value = m->cLastBar
  104.             EXIT
  105.         ENDIF
  106.     ENDDO
  107.  
  108.  
  109.     *---------------------------
  110.     *-- Build the directory list
  111.     *---------------------------
  112.     DO BldDirs WITH OpenFile.lbName8
  113.  
  114.     IF poReturn.ShowRadio
  115.         OpenFile.rbModify.Text      = poReturn.ModText
  116.         OpenFile.rbDoIt.Text        = poReturn.DoText
  117.  
  118.         nLenMod = poReturn.ModText
  119.         nLenMod = LEN( m->nLenMod )
  120.         nLenDo  = poReturn.DoText
  121.         nLenDo  = LEN( m->nLenDo )
  122.         nWidth  = MAX( m->nLenMod, m->nLenDo ) + 6
  123.  
  124.         OpenFile.rbModify.Width     = m->nWidth
  125.         OpenFile.rbDoIt.Width       = m->nWidth
  126.  
  127.         OpenFile.rbModify.Visible   = .T.
  128.         OpenFile.rbDoIt.Visible     = .T.
  129.  
  130.     ELSE
  131.         OpenFile.rbModify.Enabled   = .F.
  132.         OpenFile.rbDoIt.Enabled     = .F.
  133.     ENDIF
  134.  
  135.     IF TYPE("poReturn.StrtName") = "C"
  136.         OpenFile.efName2.Value = poReturn.StrtName + SPACE(80 - LEN(poReturn.StrtName))
  137.     ENDIF
  138.  
  139.     *---------------------------------------------
  140.     *-- Adjust the HelpId value if .HelpVal is set
  141.     *---------------------------------------------
  142.     IF TYPE( "poReturn.HelpVal" ) = "C"
  143.         OpenFile.pbName13.HelpId = poReturn.HelpVal
  144.         OpenFile.HelpId = poReturn.HelpVal
  145.     ENDIF
  146.         
  147.     lVoid = OpenFile.efName2.SetFocus()
  148.     OpenFile.efName2.SelectAll = .T.
  149.     lVoid = OpenFile.ReadModal()
  150.  
  151.     IF OpenFile.Action
  152.         *-------------------------------------------------
  153.         *-- Make sure the file has a full path designation
  154.         *-------------------------------------------------
  155.         cFileName = LTRIM( TRIM( UPPER( OpenFile.efName2.Value ) ) )
  156.         cFileName = FNAME( m->cFileName, FN_FULLPATH )
  157.  
  158.         poReturn.FileName = m->cFileName
  159.         IF FILE( m->cFileName )
  160.             poReturn.NewName = .F.
  161.         ELSE
  162.             poReturn.NewName = .T.
  163.         ENDIF
  164.  
  165.  
  166.         IF poReturn.ShowRadio
  167.  
  168.             poReturn.FileMod    = OpenFile.rbModify.Value
  169.             poReturn.DoIt       = OpenFile.rbDoIt.Value
  170.  
  171.         ENDIF
  172.  
  173.     ELSE
  174.         poReturn.FileName = ""
  175.     ENDIF
  176.  
  177.     RELEASE albName3, acbName5, albName8, acbName10, lb, lb8
  178.  
  179.     SET DIRECTORY TO &cDirStash
  180.  
  181.     lVoid = OpenFile.Release()
  182.     RELEASE OpenFile
  183.  
  184. RETURN
  185. *-- EOP: OpenFile.prg
  186.  
  187.  
  188. PROCEDURE Valid_OK
  189. *----------------------------------------------------------------------------
  190. * NAME
  191. *   Valid_OK - On Click handler efName2 for File Name prompt
  192. *
  193. *----------------------------------------------------------------------------
  194.     PRIVATE cEditFld, lOk, cTypeFile, cTemp, cFileExt, nDotPos, lExact, ;
  195.             cError, cDirSave
  196.  
  197.     oActive = OpenFile.ActiveControl()
  198.     DO CASE
  199.         CASE m->oActive = OpenFile.lbName8
  200.  
  201.             cNewPath = OpenFile.lbName8.Value
  202.             IF UPPER( m->cNewPath ) = "<EMPTY>"
  203.                 RETURN
  204.             ENDIF
  205.  
  206.             *-----------------------------------------------
  207.             *-- User selected bar in the Directory list box.
  208.             *-----------------------------------------------
  209.             lExact = SET( "EXACT" ) = "ON"
  210.             SET EXACT ON
  211.  
  212.             cError = ""
  213.             cDirSave = SET( "DIRECTORY" )
  214.  
  215.             DO CASE
  216.                 CASE m->cNewPath = "\"
  217.                     cPath = LEFT( SET( "DIRECTORY" ), 2 ) + "\"
  218.                     ON ERROR cError = MESSAGE()
  219.                     SET DIRECTORY TO &cPath
  220.                     ON ERROR
  221.  
  222.                 CASE m->cNewPath = ".."
  223.                     ON ERROR cError = MESSAGE()
  224.                     SET DIRECTORY TO ..
  225.                     ON ERROR
  226.  
  227.                 OTHERWISE
  228.                     cPath = SET( "DIRECTORY" )
  229.                     IF RIGHT( m->cPath, 1 ) <> "\"
  230.                         cPath = m->cPath + "\"
  231.                     ENDIF
  232.                     cPath = m->cPath + TRIM( m->cNewPath )
  233.                     ON ERROR cError = MESSAGE()
  234.                     SET DIRECTORY TO &cPath
  235.                     ON ERROR
  236.             ENDCASE
  237.  
  238.             IF .NOT. ISBLANK( m->cError )
  239.                 DO ErrorMsg WITH m->cError
  240.                 SET DIRECTORY TO &cDirSave
  241.             ELSE
  242.                 DO UpPostDir
  243.             ENDIF
  244.  
  245.             IF .NOT. m->lExact
  246.                 SET EXACT OFF
  247.             ENDIF
  248.  
  249.         CASE m->oActive = OpenFile.cbName5
  250.             *--------------------------------------------
  251.             *-- User selected bar in the file types list.
  252.             *--------------------------------------------
  253.             cValue = OpenFile.cbName5.Value
  254.             nSpace = AT( " ", m->cValue )
  255.             cFileSpec = LEFT( m->cValue, m->nSpace - 1 )
  256.             OpenFile.ActiveType = m->cFileSpec
  257.         
  258.             OpenFile.efName2.Value = LEFT( m->cFileSpec + SPACE(80), 80 )
  259.             DO BldFile WITH cFileSpec, OpenFile.lbName3
  260.             OpenFile.lbName3.firstTime = .T.
  261.  
  262.             *------------------------------------------------------
  263.             *-- Update the radio button text based on the file type
  264.             *------------------------------------------------------
  265.             IF poReturn.ShowRadio
  266.                 DO UpRadio WITH m->cFileSpec
  267.             ENDIF
  268.  
  269.         CASE oActive = OpenFile.lbDrives
  270.             *-------------------------------
  271.             *-- User selected bar in Drives.
  272.             *-------------------------------
  273.             cCurrent = OpenFile.lbDrives.Value
  274.             cDirSave = SET( "DIRECTORY" )
  275.             lOk = .T.
  276.             ON ERROR lOk = .F.
  277.             SET DIRECTORY TO &cCurrent
  278.             ON ERROR
  279.             IF m->lOk
  280.                 DO UpPostDir
  281.             ELSE
  282.                 SET DIRECTORY TO &cDirSave
  283.             ENDIF
  284.  
  285.         OTHERWISE
  286.             lOk = .F.
  287.             cEditFld = LTRIM( TRIM( UPPER( OpenFile.efName2.Value ) ) )
  288.             cEditFld = TRIM( m->cEditFld ) + ""
  289.             cDirSave = SET( "DIRECTORY" )
  290.  
  291.             *-----------------------------------
  292.             *-- Is there a wild card in the name
  293.             *-----------------------------------
  294.             IF "*" $ m->cEditFld .OR. "?" $ m->cEditFld
  295.  
  296.                 *--------------------------------------
  297.                 *-- Adjust the file extension as needed
  298.                 *--------------------------------------
  299.                 nDot = RAT( ".", m->cEditFld )
  300.                 IF nDot > RAT( "\", m->cEditFld )
  301.                     *---------------------------------
  302.                     *-- There is a file extension here
  303.                     *---------------------------------
  304.                     cWildExt = "*." + SUBSTR( m->cEditFld + "   ", m->nDot + 1, 3 )
  305.                     cWildExt = TRIM( UPPER( m->cWildExt ) )
  306.                     IF OpenFile.ActiveType # m->cWildExt
  307.                         *--------------------------------------------------
  308.                         *-- A type change occured.  Scan the File Types for
  309.                         *-- a match.
  310.                         *--------------------------------------------------
  311.                         lExact = SET( "EXACT" ) = "ON"
  312.                         SET EXACT OFF
  313.                         nCurSave = OpenFile.cbName5.CurSel
  314.                         nRow = 1
  315.                         OpenFile.cbName5.CurSel = m->nRow
  316.                         DO WHILE .T.
  317.                             IF OpenFile.cbName5.Value = m->cWildExt
  318.                                 OpenFile.cbName5.CurSel = m->nRow
  319.                                 EXIT
  320.                             ENDIF
  321.                             OpenFile.cbName5.CurSel = m->nRow + 1
  322.                             IF OpenFile.cbName5.CurSel = m->nRow
  323.                                 *----------------------------------------
  324.                                 *-- Restore listbox highlight to original
  325.                                 *----------------------------------------
  326.                                 OpenFile.cbName5.CurSel = m->nCurSave
  327.                                 EXIT
  328.                             ENDIF
  329.                             nRow = m->nRow + 1
  330.                         ENDDO
  331.                         IF m->lExact
  332.                             SET EXACT ON
  333.                         ENDIF
  334.  
  335.                         OpenFile.ActiveType = m->cWildExt
  336.                     ENDIF
  337.                 ENDIF
  338.  
  339.  
  340.                 *----------------------------------------------------
  341.                 *-- If a directory change is in the wild card, try to
  342.                 *-- reposition the directory.
  343.                 *----------------------------------------------------
  344.                 IF "\" $ m->cEditFld
  345.                     cError = ""
  346.                     DO VerifyDir
  347.                     IF ISBLANK( m->cError )
  348.                         DO UpPostDir
  349.                     ELSE
  350.                         *----------------------------------------------------
  351.                         *-- Display the error message and reset the directory
  352.                         *----------------------------------------------------
  353.                         DO ErrorMsg WITH m->cError
  354.                         SET DIRECTORY TO &cDirSave
  355.                     ENDIF
  356.  
  357.                 ELSE
  358.                     *------------------------------------------------------
  359.                     *-- Build a new file list for the wild card if possible
  360.                     *------------------------------------------------------
  361.                     DO BldFile WITH m->cEditFld, OpenFile.lbName3
  362.                     OpenFile.lbName3.firstTime = .T.
  363.  
  364.                 ENDIF
  365.  
  366.             ELSE
  367.  
  368.                 *-----------------------------------------------
  369.                 *-- Make sure we have a valid file to start with
  370.                 *-----------------------------------------------
  371.                 IF .NOT. ISBLANK( m->cEditFld )
  372.                     lOk = FNAME( m->cEditFld, FN_VALIDFILE )
  373.                 ELSE
  374.                     lOk = .F.
  375.                 ENDIF
  376.  
  377.                 IF lOk
  378.                     *---------------------------
  379.                     *-- Normal file name is here
  380.                     *---------------------------
  381.                     cEditFld = FNAME( m->cEditFld, FN_FULLPATH )
  382.                     cFileExt = FNAME( m->cEditFld, FN_FILETYPE )
  383.  
  384.                     *--------------------------------------------
  385.                     *-- Add on the file extension if not supplied
  386.                     *--------------------------------------------
  387.                     cTypeFile = m->cFileExt
  388.                     nDotPos = RAT( ".", m->cEditFld )
  389.                     IF ISBLANK( m->cFileExt ) .AND.  m->nDotPos # LEN( m->cEditFld )
  390.  
  391.                         *--------------------------
  392.                         *-- Add file extension here
  393.                         *--------------------------
  394.                         cTypeFile = OpenFile.cbName5.Value
  395.                         cTypeFile = TRIM( SUBSTR( m->cTypeFile, 3, 3 ) )
  396.  
  397.                         *----------------------------------------------------
  398.                         *-- If current File Type is not *.*, pull in the type
  399.                         *----------------------------------------------------
  400.                         IF m->cTypeFile <> "*"
  401.                             cTemp = TRIM( m->cEditFld ) + "." + m->cTypeFile
  402.                             cEditFld = m->cTemp
  403.                             OpenFile.efName2.Value = ;
  404.                                               LEFT( m->cEditFld + SPACE(80), 80 )
  405.                         ENDIF
  406.                     ENDIF
  407.                 ENDIF
  408.  
  409.                 *---------------------------------------------------------
  410.                 *-- Set NewName .T. if this is a valid file name that
  411.                 *-- does not exist.
  412.                 *---------------------------------------------------------
  413.                 DO CASE
  414.                     CASE m->lOk .AND.  FILE( m->cEditFld ) 
  415.                         poReturn.NewName = .F.
  416.                     CASE m->lOk .AND. .NOT.  FILE( m->cEditFld ) 
  417.                         *------------------------------------------------
  418.                         *-- Make sure the directory exists before setting
  419.                         *------------------------------------------------
  420.                         cError = ""
  421.                         DO VerifyDir
  422.                         IF .NOT. ISBLANK( m->cError )
  423.                             *----------------------------------------
  424.                             *-- Directory doesn't exist, so set error
  425.                             *----------------------------------------
  426.                             DO ErrorMsg WITH m->cError
  427.                             poReturn.NewName = .F.
  428.                             lOk = .F.
  429.                         ELSE
  430.                             poReturn.NewName = .T.
  431.                         ENDIF
  432.                         *------------------------
  433.                         *-- Restore the directory
  434.                         *------------------------
  435.                         SET DIRECTORY TO &cDirSave
  436.  
  437.                     CASE .NOT. m->lOk .AND.  FILE( m->cEditFld ) 
  438.                         DO ErrorMsg WITH [Invalid file name: ] + m->cEditFld
  439.                     CASE .NOT. m->lOk .AND. .NOT.  FILE( m->cEditFld ) 
  440.                         DO ErrorMsg WITH [Invalid file name: ] + m->cEditFld
  441.                 ENDCASE
  442.  
  443.             ENDIF
  444.  
  445.             IF m->lOk
  446.                 OpenFile.Action = .T.
  447.                 lVoid = OpenFile.Close()
  448.             ENDIF
  449.     ENDCASE
  450.  
  451. RETURN
  452. *-- EOP: Valid_OK
  453.  
  454. PROCEDURE VerifyDir
  455. *----------------------------------------------------------------------------
  456. * NAME
  457. *   VerifyDir - Validate the directory path for the file.  This is a support
  458. *               routine for Valid_OK.  This routine leaves the directory
  459. *               set to the specified one if valid.
  460. *
  461. * VARIABLES
  462. *   cEditFld    = Name of file with path to verify
  463. *   cError      = Set to error message if any
  464. *   cDirSave    = Starting directory
  465. *
  466. *----------------------------------------------------------------------------
  467.     PRIVATE cPath, nPathLen
  468.     *-------------------------------------------
  469.     *-- In case of an error, display the message
  470.     *-------------------------------------------
  471.     cPath = SET( "DIRECTORY" )
  472.  
  473.     ON ERROR cError = MESSAGE()
  474.     cPath = FName( m->cEditFld, 1 ) 
  475.     ON ERROR
  476.  
  477.     IF .NOT. ISBLANK( cError )
  478.         *-----------------------
  479.         *-- Try the hard way now
  480.         *-----------------------
  481.         cDrv = FileDrv( m->cEditFld )
  482.         cPat = FilePath( m->cEditFld )
  483.         IF .NOT. ISBLANK( cDrv )
  484.             cNewPath = cDrv + ":" + cPat + "n.txt"
  485.         ELSE
  486.             cNewPath = cPat + "n.txt"
  487.         ENDIF
  488.         cError = ""
  489.         ON ERROR cError = MESSAGE()
  490.         cPath = FName( m->cNewPath, 1 )
  491.         ON ERROR
  492.     ENDIF
  493.  
  494.     IF ISBLANK( cError )
  495.         *--------------------------------------
  496.         *-- Chop off the last slash in the path
  497.         *--------------------------------------
  498.         nPathLen = LEN( m->cPath )
  499.         IF m->nPathLen > 1
  500.             cPath = LEFT( m->cPath, m->nPathLen - 1 )
  501.         ENDIF
  502.  
  503.         *---------------------------------------------
  504.         *-- Now, take a shot at changing the directory
  505.         *---------------------------------------------
  506.         cError = ""
  507.         ON ERROR cError = MESSAGE()
  508.         SET DIRECTORY TO &cPath
  509.         ON ERROR
  510.     ENDIF
  511.  
  512.  
  513. RETURN
  514. *-- EOP: VerifyDir
  515.  
  516.  
  517. PROCEDURE UpFile
  518. *----------------------------------------------------------------------------
  519. * NAME
  520. *   UpFile - 
  521. *
  522. * DESCRIPTION
  523. *
  524. *----------------------------------------------------------------------------
  525.     PRIVATE cValue, nWidth
  526.  
  527.     IF UPPER( This.Value ) # "<EMPTY>"
  528.         cValue = This.Value
  529.         nWidth = This.Width
  530.  
  531.         OpenFile.efName2.Value = LEFT( m->cValue + SPACE(80), 80 )
  532.         OpenFile.efName2.Width = m->nWidth
  533.     ENDIF
  534.  
  535. RETURN
  536. *-- EOP: UpFile
  537.  
  538.  
  539. PROCEDURE ModUpFil
  540. *----------------------------------------------------------------------------
  541. * NAME
  542. *   ModUpFil - OnGotFocus for File list box.
  543. *
  544. *----------------------------------------------------------------------------
  545.     PRIVATE cValue, nWidth
  546.  
  547.     IF This.firstTime .AND. UPPER( This.Value ) # "<EMPTY>"
  548.         cValue = This.Value
  549.         nWidth = This.Width
  550.         OpenFile.efName2.Value = LEFT( m->cValue + SPACE(80), 80 )
  551.         OpenFile.efName2.Width = m->nWidth
  552.         This.firstTime = .F.
  553.     ENDIF
  554.  
  555. RETURN
  556. *-- EOP: ModUpFil
  557.  
  558. PROCEDURE TypeLost
  559. *----------------------------------------------------------------------------
  560. * NAME
  561. *   OnLType - 
  562. *
  563. * DESCRIPTION
  564. *
  565. *----------------------------------------------------------------------------
  566.  
  567.     cCurrent = This.Value
  568.     cSave    = OpenFile.cWildCard
  569.  
  570.     IF LEFT( m->cCurrent, 5 ) <> LEFT( m->cSave, 5 )
  571.         cValue = This.Value
  572.         nSpace = AT( " ", m->cValue )
  573.         cFileSpec = LEFT( m->cValue, m->nSpace - 1 )
  574.     
  575.         OpenFile.efName2.Value = LEFT( m->cFileSpec + SPACE(80), 80 )
  576.         DO BldFile WITH cFileSpec, OpenFile.lbName3
  577.         OpenFile.lbName3.firstTime = .T.
  578.  
  579.         *------------------------------------------------------
  580.         *-- Update the radio button text based on the file type
  581.         *------------------------------------------------------
  582.         IF poReturn.ShowRadio
  583.             DO UpRadio WITH m->cFileSpec
  584.         ENDIF
  585.     ENDIF
  586.     OpenFile.cWildCard = This.Value
  587.  
  588. RETURN
  589. *-- EOP: TypeLost
  590.  
  591. PROCEDURE TypeGot
  592. *----------------------------------------------------------------------------
  593. * NAME
  594. *   OnGType - 
  595. *
  596. * DESCRIPTION
  597. *
  598. *----------------------------------------------------------------------------
  599.     OpenFile.cWildCard = This.Value
  600.  
  601. RETURN
  602. *-- EOP: GotType
  603.  
  604. PROCEDURE ChngType
  605. *----------------------------------------------------------------------------
  606. * NAME
  607. *   ChngType - 
  608. *
  609. * DESCRIPTION
  610. *
  611. *----------------------------------------------------------------------------
  612.     cValue = This.Value
  613.     nSpace = AT( " ", m->cValue )
  614.     cFileSpec = LEFT( m->cValue, m->nSpace - 1 )
  615.  
  616.     OpenFile.efName2.Value = LEFT( m->cFileSpec + SPACE(80), 80 )
  617.     DO BldFile WITH cFileSpec, OpenFile.lbName3
  618.  
  619.     *------------------------------------------------------
  620.     *-- Update the radio button text based on the file type
  621.     *------------------------------------------------------
  622.     IF poReturn.ShowRadio
  623.         DO UpRadio WITH m->cFileSpec
  624.     ENDIF
  625.  
  626. RETURN
  627. *-- EOP: ChngType
  628.  
  629. PROCEDURE UpRadio
  630. PARAMETERS poFileSpec
  631. *----------------------------------------------------------------------------
  632. * NAME
  633. *   UpRadio - Update the radio buttons after a change in file spec.
  634. *
  635. * PARAMETERS
  636. *   poFileSpec = Wild card selected.
  637. *
  638. *----------------------------------------------------------------------------
  639.     OpenFile.Draw = .F.
  640.     OpenFile.rbModify.Visible   = .T.
  641.     OpenFile.rbDoIt.Visible     = .T.
  642.     DO CASE
  643.         CASE poFileSpec = "*.PRG"
  644.             OpenFile.rbModify.Text  = [~M~odify]
  645.             OpenFile.rbModify.Value = .T.
  646.             OpenFile.rbDoIt.Text    = [~D~o]
  647.             OpenFile.rbDoIt.Value   = .F.
  648.         CASE poFileSpec = "*.DBF"
  649.             OpenFile.rbModify.Text  = [~M~odify]
  650.             OpenFile.rbModify.Value = .F.
  651.             OpenFile.rbDoIt.Text    = [~B~rowse]
  652.             OpenFile.rbDoIt.Value   = .T.
  653.         CASE poFileSpec = "*.FMT"
  654.             OpenFile.rbModify.Text  = [~M~odify]
  655.             OpenFile.rbModify.Value = .T.
  656.             OpenFile.rbDoIt.Text    = [~S~et]
  657.             OpenFile.rbDoIt.Value   = .F.
  658.         CASE poFileSpec = "*.QBE"
  659.             OpenFile.rbModify.Text  = [~M~odify]
  660.             OpenFile.rbModify.Value = .F.
  661.             OpenFile.rbDoIt.Text    = [~B~rowse]
  662.             OpenFile.rbDoIt.Value   = .T.
  663.         CASE poFileSpec = "*.SCR"
  664.             OpenFile.rbModify.Text  = [~M~odify]
  665.             OpenFile.rbModify.Value = .T.
  666.             OpenFile.rbDoIt.Text    = [~S~et]
  667.             OpenFile.rbDoIt.Value   = .F.
  668.         CASE poFileSpec = "*.FRM"
  669.             OpenFile.rbModify.Text  = [~M~odify]
  670.             OpenFile.rbModify.Value = .T.
  671.             OpenFile.rbDoIt.Text    = [~D~o]
  672.             OpenFile.rbDoIt.Value   = .F.
  673.         CASE poFileSpec = "*.LBL"
  674.             OpenFile.rbModify.Text  = [~M~odify]
  675.             OpenFile.rbModify.Value = .T.
  676.             OpenFile.rbDoIt.Text    = [~D~o]
  677.             OpenFile.rbDoIt.Value   = .F.
  678.         CASE poFileSpec = "*.DFM"
  679.             OpenFile.rbModify.Text  = [~M~odify]
  680.             OpenFile.rbModify.Value = .T.
  681.             OpenFile.rbDoIt.Text    = [~D~o]
  682.             OpenFile.rbDoIt.Value   = .F.
  683.         CASE poFileSpec = "*.PRJ"
  684.             OpenFile.rbModify.Visible   = .F.
  685.             OpenFile.rbModify.Value     = .T.
  686.             OpenFile.rbDoIt.Visible     = .F.
  687.         OTHERWISE
  688.             OpenFile.rbModify.Text  = [~M~odify]
  689.             OpenFile.rbModify.Value = .T.
  690.             OpenFile.rbDoIt.Text    = [~D~o]
  691.             OpenFile.rbDoIt.Value   = .F.
  692.     ENDCASE
  693.  
  694.     OpenFile.Draw = .T.
  695.     lVoid = OpenFile.efName2.SetFocus()
  696.  
  697. RETURN
  698. *-- EOP: UpRadio WITH poFileSpec
  699.  
  700. PROCEDURE DriveGot
  701. *----------------------------------------------------------------------------
  702. * NAME
  703. *   DriveGot - OnGotFocus handler for lbDrives
  704. *
  705. * DESCRIPTION
  706. *
  707. *----------------------------------------------------------------------------
  708.     OpenFile.cDrive = This.Value
  709.  
  710.  
  711. RETURN
  712. *-- EOP: DriveGot
  713.  
  714. PROCEDURE DriveLost
  715. *----------------------------------------------------------------------------
  716. * NAME
  717. *   DriveLost - OnLostFocus handler for lbDrives
  718. *
  719. * DESCRIPTION
  720. *
  721. *----------------------------------------------------------------------------
  722.     cCurrent = TRIM( This.Value )
  723.     cSave    = TRIM( OpenFile.cDrive )
  724.     IF m->cCurrent <> m->cSave
  725.         cDirSave = SET( "DIRECTORY" )
  726.         lOk = .T.
  727.         ON ERROR lOk = .F.
  728.         SET DIRECTORY TO &cCurrent
  729.         ON ERROR
  730.         IF m->lOk
  731.             DO UpPostDir
  732.         ELSE
  733.             SET DIRECTORY TO &cDirSave
  734.         ENDIF
  735.     ENDIF
  736.     OpenFile.cDrive = m->cCurrent
  737.  
  738. RETURN
  739. *-- EOP: DriveLost
  740.  
  741. PROCEDURE UpPostDir
  742. *----------------------------------------------------------------------------
  743. * NAME
  744. *   UpPostDir - Update lists after a change in directory
  745. *
  746. *----------------------------------------------------------------------------
  747.     OpenFile.txName7.Text = SET( "DIRECTORY" )
  748.     OpenFile.txName7.Width = OpenFile.Width - OpenFile.txName7.Left - 2
  749.     OpenFile.txName7.Height = 1
  750.  
  751.     DO BldDirs WITH OpenFile.lbName8
  752.  
  753.     cFileSpec = OpenFile.ActiveType
  754.  
  755.     OpenFile.efName2.Value = LEFT( m->cFileSpec + SPACE(80), 80 )
  756.     DO BldFile WITH cFileSpec, OpenFile.lbName3
  757.  
  758. RETURN
  759. *-- EOP: UpPostDir
  760.  
  761.  
  762.  
  763.  
  764.