Exists: Difference between revisions

From BR Wiki
Jump to navigation Jump to search
m (moved Exists to EXISTS)
No edit summary
Line 4: Line 4:
The '''exists''' [[internal function]] returns a nonzero value if the specified file exists and the user has read privileges. If one or both of these conditions is false, exists returns a value of zero. NOTE that on single-user systems, all files have read privileges for the current user.
The '''exists''' [[internal function]] returns a nonzero value if the specified file exists and the user has read privileges. If one or both of these conditions is false, exists returns a value of zero. NOTE that on single-user systems, all files have read privileges for the current user.


The exists function now returns:
The exists function returns:
*a value of 1 for directories
* a value of 1 for directories
*a number greater than 1 for files
* a number greater than 1 for files


====Comments and Examples====
====Comments and Examples====
Line 12: Line 12:
{{Future|Future releases of [[Business Rules!]] may return the file type (e.g., 4 for internal, 9/10/11 for programs).}}
{{Future|Future releases of [[Business Rules!]] may return the file type (e.g., 4 for internal, 9/10/11 for programs).}}


For the present, do not test for any specific positive value; only zero or non-zero tests should be used. Recommended coding practices for programs are:
For the present, do not test for any specific positive value. Only zero or non-zero tests should be used. Recommended coding practices for programs are:


  00010 IF EXISTS("filename") THEN GOTO FOUND
  00010 IF EXISTS("filename") THEN GOTO FOUND
Line 27: Line 27:


====Related Functions====
====Related Functions====
For additional information about files, see the following functions:  
For additional information about files, see the following functions:  
*[[File]]
*[[File (internal function)]]
*[[File$]]
*[[File$]]
*[[FileNum]]
*[[FileNum]]
Line 40: Line 41:


====Technical Considerations====
====Technical Considerations====
# Due to anticipated enhancements for this function, it is strongly recommended that you use only zero or nonzero tests in your code; do not attempt to test for a specific nonzero value.
# Due to anticipated enhancements for this function, it is strongly recommended that you use only zero or nonzero tests in your code. Do not attempt to test for a specific nonzero value.


<noinclude>
<noinclude>
[[Category:Internal Functions]]
[[Category:Internal Functions]]
</noinclude>
</noinclude>

Revision as of 10:50, 24 January 2012

Exists(filename$)

The exists internal function returns a nonzero value if the specified file exists and the user has read privileges. If one or both of these conditions is false, exists returns a value of zero. NOTE that on single-user systems, all files have read privileges for the current user.

The exists function returns:

  • a value of 1 for directories
  • a number greater than 1 for files

Comments and Examples

Future
Future releases of Business Rules! may return the file type (e.g., 4 for internal, 9/10/11 for programs).



For the present, do not test for any specific positive value. Only zero or non-zero tests should be used. Recommended coding practices for programs are:

00010 IF EXISTS("filename") THEN GOTO FOUND
00020 IF EXISTS("filename") <> 0 THEN GOTO FOUND
00030 IF NOT EXISTS("filename") THEN GOTO NOTFOUND
00040 IF EXISTS("filename") = 0 THEN GOTO NOTFOUND

Recommended coding practices for procedures

SKIP FOUND IF EXISTS(filename)
SKIP FOUND IF EXISTS(filename) <> 0
SKIP NOTFOUND IF NOT EXISTS(filename)
SKIP NOTFOUND IF EXISTS(filename) = 0

Related Functions

For additional information about files, see the following functions:

Technical Considerations

  1. Due to anticipated enhancements for this function, it is strongly recommended that you use only zero or nonzero tests in your code. Do not attempt to test for a specific nonzero value.