home *** CD-ROM | disk | FTP | other *** search
/ Phoenix CD 2.0 / Phoenix_CD.cdr / 24b / ntxerr.zip / OPEN_ERR.PRG next >
Text File  |  1988-08-31  |  2KB  |  66 lines

  1. ***
  2. *       open_error(name, line, info, model, _1)
  3. *
  4. FUNCTION open_error
  5. PARAM name, line, info, model, _1
  6. IF NETERR() .AND. model == "USE"
  7.     RETURN .F.
  8. END
  9.  
  10. * The following is a check for a missing/corrupt index. It has a call to
  11. * RedoIndex() which I intend to have in the top calling module of my
  12. * applications for clarity/consistensy, but could appear anywhere.
  13.  
  14. * Each index used must be hardcoded in RedoIndex().
  15. * Once the index has been created/recreated, program execution continues
  16. * as normal, with the requested file in USE in the specified area.
  17.  
  18. * Written Jan 18/88 by Brian Loesgen (Wow! My first S'87 UDF!) with
  19. * assistance from Bill Steele.
  20.  
  21. * If anyone finds anything wrong with this, PLEASE let me know either
  22. * on CRS -or- PCanada PC2098 -or- CIS 17326,1174 -or- Source BFG491
  23. * OPENERRO.PRG
  24.  
  25. * This is a direct replacement for OPEN_ERROR in ERRORSYS.PRG
  26. * It contains everything that was in OPEN_ERROR before, plus the NTX check.
  27.  
  28. * This is public domain, as is, no warrantees at all, etc...
  29.  
  30.  
  31. IF model = "SET INDEX"
  32.     cl_dbf = ALIAS()                       && .DBF name
  33.     cl_index = SUBSTR(_1,1,AT(".",_1)-1)   && .NTX name
  34.     @23,0 CLEA
  35.     IF .NOT. FILE("&_1")
  36.         @24,1 SAY "Index &cl_index is missing. Reindexing..."
  37.     ELSE
  38.         @24,1 SAY "Index &cl_index appears to be corrupted. Reindexing..."
  39.     ENDIF
  40.     RedoIndex()
  41.     @23,0 CLEA
  42.     RETURN .F.
  43. ELSEIF .NOT. FILE(ALIAS()+".DBF")
  44.     @23,0 CLEAR
  45.     @24,0 SAY "Database "+ALIAS()+" not found! -- Aborting..."
  46.     RETURN .T.
  47.  
  48. ELSE                     && ... The following IF NOT an index error
  49.  
  50.     SET DEVICE TO SCREEN
  51.     @ 0, 0
  52.     @ 0, 0 SAY "Proc " + M->name + " line " + LTRIM(STR(M->line)) + ", " +;
  53.                 M->info + " " + M->_1 + " (" + LTRIM(STR(DOSERROR())) + ")"
  54.     @ 0, 65 SAY "Retry? (Y/N)"
  55.     INKEY(0)
  56.     DO WHILE .NOT. CHR(LASTKEY()) $ "YyNn"
  57.         INKEY(0)
  58.     END
  59.     IF .NOT. CHR(LASTKEY()) $ "Yy"
  60.         QUIT
  61.     ENDIF
  62.     @ 0,0
  63.     RETURN .T.
  64. ENDIF
  65. RETURN .T.
  66.