FarCall "TargetDatabase", ".Procedure" result does not match running ".Procedure" locally


#1

I am probably doing something wrong, but when I run a procedure using the FarCall statement, I don’t get the exact same result as running the procedure locally. Specifically, the procedure assigns a Global variable from a Permanent variable located in the target database. The FarCall statement thinks that the Permanent variable has a value of Null, when in fact, it does not. Any ideas or thoughts? I am working late, so maybe my brain is not functioning properly.


#2

FarCall doesn’t make the target database active. The database you are calling from may have a fileglobal variable with that name, that hasn’t been given a value, or there might be a global variable with that name, but no value. When you run it locally, it gets the value from the variable belonging to that file. If there is also a global by that name, the permanent variable (which is a file global) takes precedence. When you do the FarCall, and another database is active, its fileglobal is in scope, or if it doesn’t have one, the global variable is in scope.

If this is the only thing the procedure is doing, you might just want to do something like this, instead of the FarCall.

theGlobal = fileglobalvalue("TargetDatabase", "thePermanent")