Alias lost when calling object methods

Topics: Developer Forum
Mar 30 at 12:09 AM
My application has grown fairly complex. I created a table class to manage my tables because my experience is that VFP is absolutely terrible at this. I'm actually using classes and objects for a number of things.

Unfortunately I've discovered that when calling methods from one class in another, the alias is reported as not used() and all kinds of things are failing inexplicably as a result. At the moment my system is completely dysfunctional because tables, cursors, and aliases are usually not accessible for no explicit reason, although sometimes they do work, there is no reason.

if I call aused() and verify the cursor is there, then select it again, it works, but there are places where I can't do that. But I don't really want to scatter aused() calls everywhere just because the system incorrectly reports aliases as not used.

JSON.stringify() for example usually doesn't work anymore for cursors/tables/aliases because used() reports false and there's nothing I can do about that, it returns the literal alias to the client instead.

used() simply returns the wrong state. aused shows the alias is there.
Mar 31 at 10:18 PM
The problem is that when you create an object from a class, the datasession changes. Since up until now I haven't used datasession. In the init() for the base classes, you have to:

set datasession to 1

That takes care of it. I can't do this for JSON.PRG though, it won't compile in AVFP (it's an FLL file in the root). I suppose I can make a subclass.

This is probably part of the reason PDFRun doesn't work, but it would take more time to diagnose that one.