05-05-2012 06:24 PM
I've inherited an LV6.1 code that I'm updating to to LV2011. A small snippet of the problem code is attached.
In the old code, "Get Report Type.vi" is used to test whether a report has been opened yet. If the report has not already been opened with a call to "New Report.vi", an error is generated. It is this error that triggers a call to "New Report.vi"
In LV2011, no error is generated, as you can see in the attached code, so "New Report.vi" is never called.
How can I test whether a report has been initiated yet?
In another variation of this logic, the program does something based on whether the error flag from "Get Report Type.vi" is True or False, using a "Select" function as a switch. I'll need to handle that issue too.
Thanks very much.
05-07-2012 06:50 PM - edited 05-07-2012 06:51 PM
If you get an error coming out of the "New Report.vi" that's an indicator. The message in the code says that the program is not able to get to the error case in the attach test_report.vi I would check if the report is properly linked to the local variable. As a general rule try to avoid variables and use cables when possible.
05-07-2012 09:50 PM
I think you've missed my point.
The former programmer used the presence of an error to trigger a call to New Report.vi. I know that's goofy logic, but I have to simulate that behavior.
My best guess for a fix would be to establish a global boolean variable named "Report_Initiated" that starts out false, and is set to true as soon as "New Report.vi" has been called.
05-08-2012 01:46 AM
Hi
the newer Report VIs are based on LVOOP ( object oriented). It is not so easy to open a report and use it in another vi without passing the Reort instance ( the chain like, cyan connection). Using a global variable for that is very ugly because it violates the data flow paradigm and you will have to be very careful about the current state of it.
Basically the GetReportType should give an error if you try to use it on a non-instantiated (ie. no NewReport) report. Make sure DisposeReport any old reports
Gabi
05-08-2012 08:33 AM
Gabi: "Basically the GetReportType should give an error if you try to use it on a non-instantiated (ie. no NewReport) report.:
That is precisely the behavior that the original programmer was relying on in order to trigger a call to NewReport.vi. But I proved in "test_report.vi", uploaded to the original message, that no error is generated in LV2011.
So either you are wrong about the expected behavior (I don't see how), or there is a bug in LV2011.
05-09-2012 08:30 AM
Hi I was too quick.
Violatiing data flow is not only ugly, but it makes your predecssors idea not work.
The clipout is a very simple sketch of what you want to do. If you open the GetReportType you see that it simply relies on the DynamicDispatch to check what type the Class-Data has. There is no way (and no need) to check if the data is really valid.
Whats more, branching the (chained) new report, will create a duplicate of it. If I close one, the other is still there.
I don't know how the whole project looks like, maybe you can couple the OO-Global with a "valid"-flag.
But remember the LV-Commandment -- Thou shalt have no Global Variable
Gabi