Field or variable *hostServer* does not exist

A procedure for shutting down a set of shared files works its way through a list of files. Each file name is loaded into a local named lvFile then the shortcfall below is invoked.

closer:
If dbcheckopen(lvFile) = 0
Rtn
EndIf
SetactiveDatabase lvFile
If Error Rtn EndIf
Save
CloseDatabase lvFile
Rtn

It has worked for some time but this morning, midway through the list of files, someone got an error that field or variable hostServer does not exist. The only place I can find this variable is in _DatabaseLib:PARTIALDATABASEREVERT and _DatabaseLib:SERVERDATABASECONSOLEDUMP.

Why would either be invoked by this shortcall, and why only once after being used reliably for some time.

This variable is used in 51 procedures in _EnterpriseClientLib, which is not searchable by you. One of the procedures that uses this variable is CLIENTCLOSESHAREDDATABASE so that is probably where the problem occurs.

I’m not surprised that save followed by closedatabase might cause a problem. I think this may have even come up in the forum before. On macOS, the save operation is asynchronous. This means that it might not be complete by the time the next statement runs. This is a feature of macOS, it cannot be changed without abandoning use of Apple’s NSDocument framework, which would be a very bad idea. However, this aspect of NSDocument wasn’t really designed with scripting languages in mind.

Because of this asynchronous behavior, if you do need to use the save statement, it’s best for that to be the last statement in the procedure. Or at least make sure that the following statements don’t rely on the save operation being complete.

In your application, I suspect that the save is probably not necessary. I would take that out and let auto-save do it’s thing.