1
Programming / Re: Environment goes away when dropping a file on a WPProgram object
« on: June 05, 2025, 05:18:34 am »It appears to me that an empty environment is passed to the program started when a file is dropped on a WPS program object.
I'm afraid you've found The Bug in DTProgram. I know what the issue is, I'm just not sure how to resolve it. The quick fix is to remove any entries you made on the 'Environment' tab of the program object's notebook.
When you drop a datafile on a program object, the pgm object does *not* open the file. Instead, the datafiles's wpDroppedOnObject() method is called, advising that it was just dropped on the pgm object. The datafile then queries the pgm object for its PROGDETAILS structure which contains the particulars for that program. Using this info, the datafile runs the program itself. And here lies the problem...
PROGDETAILS includes contains an optional 'pszEnvironment' field that can be used to supplement or replace the default environment When DTProgram sees the field contains something, it merges whatever it finds with the existing environment. Unfortunately, WPProgram assumes that the field contains the entire environment, leaving whatever it starts with nothing but your few entries.
The obvious solution is to always merge your entries with the generic environment, but that entails a lot of overhead to resolve a problem that seldom occurs. I'll see what I can do.