home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a079 / 1.img / FMW.LZH / SB_SELEC.PRG < prev    next >
Encoding:
Text File  |  1992-04-06  |  10.2 KB  |  348 lines

  1. *:*********************************************************************
  2. *:
  3. *: Procedure file: D:\FOX2\FM\INSTALL\SB_SELEC.PRG
  4. *:
  5. *:         System: FoxMasters install
  6. *:         Author: Braunstein
  7. *:      Copyright (c) 1992, Tetra
  8. *:  Last modified: 04/06/92     14:56
  9. *:
  10. *:         Set by: INITALIZE()        (function  in FMINSTAL.PRG)
  11. *:               : GETFMLOC()         (function  in SMOVER.PRG)
  12. *:
  13. *:          Calls: SB_CLOSE.PRG
  14. *:
  15. *:      Documented 04/06/92 at 15:18               FoxDoc  version 2.10b
  16. *:*********************************************************************
  17. *
  18. *   sb_selec.prg
  19. *
  20. *   to open (without reopening) a file
  21. *   and select the index order
  22. *
  23. *
  24. FUNCTION sb_selec
  25.    
  26.    
  27.    PARAMETERS location, dbf_name, idx_name, new_alias, modifyer
  28.    
  29.    *            |         |          |            |        |
  30.    *  drive +   |         |          |            |        |
  31.    *  subdirectory    database   index      alias |      use command
  32.    *  where file      name       tag name   (if not      modifyer such
  33.    *  located                                filename)   as EXCLUSIVE
  34.    *
  35.    *
  36.    *   set up memory variables as private
  37.    SELECT 0
  38.    PRIVATE ;
  39.       location  , ;
  40.       dbf_name  , ;
  41.       idx_name  , ;
  42.       new_alias , ;
  43.       modifyer  , ;
  44.       ret_val
  45.    
  46.    
  47.    *
  48.    *   operate with the presumption that the file
  49.    *   will be successfully opened, and the order
  50.    *   successfully set.  change to .f. when fails.
  51.    *
  52.    STORE .T. TO ret_val
  53.    *
  54.    *   convert names to standard format
  55.    *
  56.    *   fix the location name (parameter required)
  57.    IF !EMPTY(location)
  58.       *
  59.       *   fix text
  60.       STORE TRIM(UPPER(location)) TO location
  61.       *
  62.       *   fix format ie. dr:\subdir\
  63.       IF RIGHT(location,1) # '\'
  64.          *
  65.          *  add backslash as required
  66.          STORE location + '\' TO location
  67.       ELSE
  68.          *
  69.          *   name already includes backslash,
  70.          *   no action required
  71.          *
  72.       ENDIF        right(location,1) # '\'
  73.       *
  74.    ELSE
  75.       *
  76.       *   reduce chances of it getting in the way
  77.       STORE '' TO location
  78.       *
  79.    ENDIF        !EMPTY(location)
  80.    *
  81.    *   fix the dbf_name (parameter required)
  82.    STORE TRIM(UPPER(dbf_name)) TO dbf_name
  83.    *
  84.    *   fix the idx_name
  85.    IF PARAMETERS() > 2
  86.       STORE TRIM(UPPER(idx_name)) TO idx_name
  87.    ELSE
  88.       STORE '' TO idx_name
  89.    ENDIF        PARAMETERS() > 2
  90.    *
  91.    *   fix the new alias name
  92.    IF PARAMETERS() > 3
  93.       STORE TRIM(UPPER(new_alias)) TO new_alias
  94.    ELSE
  95.       STORE '' TO new_alias
  96.    ENDIF        PARAMETERS() > 3
  97.    *
  98.    *   fix the modifyer
  99.    IF PARAMETERS() > 4
  100.       STORE TRIM(UPPER(modifyer)) TO modifyer
  101.    ELSE
  102.       STORE '' TO modifyer
  103.    ENDIF        PARAMETERS() > 4
  104.    *
  105.    *   test for exsistence of a open files modifyer,
  106.    *   if there is one, just open the files
  107.    *
  108.    IF EMPTY(modifyer)
  109.       *
  110.       *   test for file already open,
  111.       *   if it is, just change the order and proceed
  112.       *
  113.       *   determine current file status
  114.       DO CASE
  115.       CASE ALIAS() = new_alias .AND. !EMPTY(new_alias)
  116.          *
  117.          *   file selected, change master index
  118.          *   make sure an index is desired before opening it
  119.          IF EMPTY(idx_name)
  120.             *
  121.             *   no index desired
  122.             SET ORDER TO 0
  123.             *
  124.          ELSE
  125.             *
  126.             *   check to see if already in desired order
  127.             IF ORDER() # idx_name
  128.                *
  129.                *   Make change to desired order when necessary
  130.                SET ORDER TO TAG (idx_name)
  131.                *
  132.             ELSE
  133.                *
  134.                *   already in desired order, no action required
  135.                *
  136.             ENDIF        ORDER() # idx_name
  137.          ENDIF        EMPTY(idx_name)
  138.          *
  139.       CASE ALIAS() = dbf_name
  140.          *
  141.          *   file selected, change master index
  142.          *   make sure an index is desired before opening it
  143.          IF EMPTY(idx_name)
  144.             *
  145.             *   no index desired
  146.             SET ORDER TO 0
  147.          ELSE
  148.             *
  149.             *   check to see if already in desired order
  150.             IF ORDER() # idx_name
  151.                *
  152.                *   Make change to desired order when necessary
  153.                SET ORDER TO TAG (idx_name)
  154.                *
  155.             ELSE
  156.                *
  157.                *   already in desired order, no action required
  158.                *
  159.             ENDIF        ORDER() # idx_name
  160.          ENDIF        EMPTY(idx_name)
  161.          *
  162.       CASE USED("&new_alias") .AND. !EMPTY(new_alias)
  163.          *
  164.          *   file open in an unselected work area
  165.          SELECT (new_alias)
  166.          *
  167.          *   file selected, change master index
  168.          *
  169.          *   make sure an index is desired before opening it
  170.          IF EMPTY(idx_name)
  171.             *
  172.             *   no index desired
  173.             SET ORDER TO 0
  174.          ELSE
  175.             *
  176.             *   check to see if already in desired order
  177.             IF ORDER() # idx_name
  178.                *
  179.                *   Make change to desired order when necessary
  180.                SET ORDER TO TAG (idx_name)
  181.                *
  182.             ELSE
  183.                *
  184.                *   already in desired order, no action required
  185.                *
  186.             ENDIF        ORDER() # idx_name
  187.          ENDIF        EMPTY(idx_name)
  188.          *
  189.          *
  190.       CASE USED("&dbf_name")
  191.          *
  192.          *   file open in an unselected work area
  193.          SELECT (dbf_name)
  194.          *
  195.          *   file selected, change master index
  196.          *
  197.          *   make sure an index is desired before opening it
  198.          IF EMPTY(idx_name)
  199.             *
  200.             *   no index desired
  201.             SET ORDER TO 0
  202.          ELSE
  203.             *
  204.             *   check to see if already in desired order
  205.             IF ORDER() # idx_name
  206.                *
  207.                *   Make change to desired order when necessary
  208.                SET ORDER TO TAG (idx_name)
  209.                *
  210.             ELSE
  211.                *
  212.                *   already in desired order, no action required
  213.                *
  214.             ENDIF        ORDER() # idx_name
  215.          ENDIF        EMPTY(idx_name)
  216.          *
  217.          *
  218.       OTHERWISE
  219.          *
  220.          *   file not open
  221.          *   test for exsistence before opening
  222.          STORE location + dbf_name + '.DBF' TO temp_name
  223.          IF FILE("&temp_name")
  224.             *
  225.             *   set up flag to interact with sb_err
  226.             STORE .T. TO sb_selec
  227.             *
  228.             *   open the file
  229.             
  230.             SELECT 0
  231.             IF EMPTY(new_alias)
  232.                USE (location) + (dbf_name) ALIAS (dbf_name)
  233.             ELSE
  234.                USE (location) + (dbf_name) ALIAS (new_alias)
  235.             ENDIF        EMPTY(new_alias)
  236.             *
  237.             *   test for successful file opening
  238.             IF !sb_selec
  239.                STORE .F. TO ret_val
  240.             ELSE
  241.                *
  242.                *   if file selected, change master index
  243.                *   make sure an index is desired before opening it
  244.                IF EMPTY(idx_name)
  245.                   *
  246.                   *   no index desired
  247.                   SET ORDER TO 0
  248.                ELSE
  249.                   *
  250.                   *   check to see if already in desired order
  251.                   IF ORDER() # idx_name
  252.                      *
  253.                      *   Make change to desired order when necessary
  254.                      SET ORDER TO TAG (idx_name)
  255.                      *
  256.                   ELSE
  257.                      *
  258.                      *   already in desired order, no action required
  259.                   ENDIF        ORDER() # idx_name
  260.                ENDIF        EMPTY(idx_name)
  261.             ENDIF        !sb_selec
  262.             *
  263.          ELSE
  264.             *
  265.             *   file not located, message
  266.             WAIT WINDOW ' FILE, ' + dbf_name + ' NOT FOUND! '
  267.             *
  268.             *   function failed
  269.             STORE .F. TO ret_val
  270.             *
  271.          ENDIF        FILE("&temp_name")
  272.          *
  273.          *
  274.       ENDCASE
  275.       *
  276.       *   open file with modifyer
  277.    ELSE
  278.       *
  279.       *
  280.       *   first, test for exsistence before opening
  281.       STORE location + dbf_name + '.DBF' TO temp_name
  282.       IF FILE("&temp_name")
  283.          *
  284.          *   second, close file
  285.          *   (no way to tell what the current condition is and change it)
  286.          *
  287.          IF EMPTY(new_alias)
  288.             *
  289.             *   close using filename
  290.             DO sb_close WITH dbf_name
  291.             *
  292.             *   open with modifyer, use dbf_name as alias
  293.             SELECT 0
  294.             STORE location + dbf_name + ' ALIAS ' + dbf_name + modifyer TO t_file
  295.             USE (t_file)
  296.             *
  297.          ELSE
  298.             *
  299.             *   close using the new_alias name
  300.             DO sb_close WITH new_alias
  301.             *
  302.             *    open with new modifyer and new alias
  303.             SELECT 0
  304.             STORE location + dbf_name + ' ALIAS ' + new_alias + modifyer TO t_file
  305.             USE (t_file)
  306.             *
  307.          ENDIF        EMPTY(new_alias)
  308.          *
  309.          *   set the appropriate order
  310.          *
  311.          *   make sure an index is desired before opening it
  312.          IF EMPTY(idx_name)
  313.             *
  314.             *   no index desired
  315.             SET ORDER TO 0
  316.          ELSE
  317.             *
  318.             *   check to see if already in desired order
  319.             IF ORDER() # idx_name
  320.                *
  321.                *   Make change to desired order when necessary
  322.                SET ORDER TO TAG (idx_name)
  323.                *
  324.             ELSE
  325.                *
  326.                *   already in desired order, no action required
  327.                *
  328.             ENDIF        ORDER() # idx_name
  329.          ENDIF        EMPTY(idx_name)
  330.          *
  331.       ELSE
  332.          *
  333.          *   file not located, message
  334.          WAIT WINDOW ' FILE, ' + dbf_name + ' NOT FOUND! '
  335.          *
  336.          *   function failed
  337.          STORE .F. TO ret_val
  338.          *
  339.       ENDIF        FILE("&temp_name")
  340.    ENDIF        EMPTY(modifyer)
  341.    *
  342.    *   go back with the news
  343.    RETURN ret_val
  344. *
  345. *   end of sb_selec.prg
  346. *
  347. *: EOF: SB_SELEC.PRG
  348.