Question

I am trying to call an existing VFP 6 application using Jacob which is a COM bridge for Java.

val vfp = new Application(new ActiveXComponent("VisualFoxPro.Application").getProperty("Application").toDispatch())
vfp.setVisible(false)

try {
  vfp.doCmd("do my.exe with myconfig.txt")
} catch {
  case t: Throwable => t.printStackTrace
} finally {
  vfp.doCmd("close data")
  vfp.doCmd("clear all")
  vfp.doCmd("clear")
  vfp.quit
  vfp.safeRelease
}

When there are no error conditions this code executes well and generates the expected .dbfs. The problem is that when an error occurs (.dbf not found, file in use by another user, etc) a GUI window pops up and stops execution of the program until I use the mouse to cancel it. I want this program to run on a server with no user interaction so this won't work.

How can I gracefully handle the errors preferably without making a change to the VFP 6 program?

Was it helpful?

Solution

Since you have the source code for VFP6, I would suggest looking into

SYS(2335,0)

Sys 2335 is used to identify if the program is running in an "unattended" mode, any such popup dialog boxes will throw an error and prevent an actual "hit" ok/cancel/whatever button to continue. This includes popup window prompting user to pick a table.

I'm not positive of when it was made available as I had limited use of it. Like you, when dealing with a COM server under IIS and obviously nobody there to respond.

OTHER TIPS

Start JVM in headless mode, catch HeadlessException or something. Or, write a Java program that will execute your GUI program using Runtime, and restart in a case of parsed errors in console.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top