Misplaced Pages

Existence detection

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these messages)
This article does not cite any sources. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "Existence detection" – news · newspapers · books · scholar · JSTOR (February 2023) (Learn how and when to remove this message)
The topic of this article may not meet Misplaced Pages's general notability guideline. Please help to demonstrate the notability of the topic by citing reliable secondary sources that are independent of the topic and provide significant coverage of it beyond a mere trivial mention. If notability cannot be shown, the article is likely to be merged, redirected, or deleted.
Find sources: "Existence detection" – news · newspapers · books · scholar · JSTOR (September 2024) (Learn how and when to remove this message)
(Learn how and when to remove this message)

Existence checking or existence detection is an important aspect of many computer programs. An existence check before reading a file can catch and/or prevent a fatal error, for instance. For that reason, most programming language libraries contain a means of checking whether a file exists.

An existence check can sometimes involve a "brute force" approach of checking all records for a given identifier, as in this Microsoft Excel Visual Basic for Applications code for detecting whether a worksheet exists:

Function SheetExists(sheetName As String) As Boolean
  Dim sheetCount As Integer
  Dim t As Integer
  SheetExists =  False
  sheetCount = ActiveWorkbook.Sheets.Count
  For t = 1 To  sheetCount
    If Sheets(t).Name = sheetName Then
      SheetExists = True
      Exit Function
    End If
  Next t
End Function

References


Stub icon

This computer science article is a stub. You can help Misplaced Pages by expanding it.

Categories: