Applies to: a hand-coded Clarion application using the IP driver; the thread names no versions.
Problem
The app tested IF ~EXISTS('datafile') and then CREATE(datafile) before opening. That does not work when the data files are on the IP server. The poster's first idea, OPEN, SET and RECORDS() = 0, tried an open on a missing file and was awkward. A server-side function returning the result to the client, and checking ERRORCODE() right after OPEN, gave him nothing. CREATE itself worked remotely.
Solution
The answers that worked or were offered, in the order of the thread:
- Open in a loop and read the error:
LOOP 2 TIMES, OPEN, then CASE ERRORCODE(): 0 leaves the loop; NoFileErr (2) calls CREATE and reports a failed create; any other code reports "Cannot open file!". - The poster wrapped this in
checkExists(filLabel)so it replaces EXISTS(): it runs OPEN, then ERRORCODE() = 2 means the file is missing, any other result means it exists, and the file is closed again. A compile switch keptEXISTS(NAME(filLabel))for the standalone build. The first poster of the loop said that "will probably work". - Another poster does SET followed by NEXT and checks the actual error code, and has not seen it fail.
Caveats
- Another poster, using the standard templates, turned the create flag OFF at the dictionary level. With it on, the app was fooled into believing the file did not exist and created an empty file over one with good records.
- The first poster had not yet tested whether error 2 is the only code for a missing file.
- A suggestion to tick "enable table creation" did not fit his hand-coded app.
Today (2026)
Likely still the sound approach, since the test depends on the error code and not on a file path. Not re-tested.
Sources: Tom H. (Oct 2010, the question), Stamos, Mike H., Daan M. (Oct 2010) in softvelocity.clarion.databasedrivers.