DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Conditional image visibility in DiAdem Report

Solved!
Go to solution

Does anyone know of a way to make an image conditionally visible in a report in DiAdem?

 

What I would like to do is display a certain .jpg image on the report based on a property of a data file loaded in the portal.  I am creating a generic report structure that actively changes based on what file is loaded in the data portal.

 

Has anyone ever tried this or even wanted to?

 

Steve

0 Kudos
Message 1 of 9
(4,713 Views)

Hi Steve,

 

You can programmatically change the file path to the image in the image object's configuration, including making it the empty string (which makes the image disappear).  The usual <Ctrl-A> trick will show you the commands and variables you need to use.  The question is how the VBScript will get run.  It is possible to run script code as part of the TDR layout refresh cycle.  In DIAdem 2010 and later there is also a REPORT event when a user drops channels onto a graph.  And you may already be running a VBScript that we can add a few commands to.

 

Care to describe the user scenario?

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 9
(4,698 Views)

Thanks for the response, Brad.

 

The user experience is usually to open a report file, load a few data files into the data portal, then refresh the report to populate the various graphs and tables.  I would imagine I could put it in a script and use one of the "F" shortcuts from within the Report window.  Adding that extra step would be okay.

 

I tried inserting a graphic while recording a script and tried the Ctrl-A trick, but nothing recorded for me.  Any chance you can post some sample code?

 

Steve

0 Kudos
Message 3 of 9
(4,677 Views)
Solution
Accepted by topic author Steve Koza

Hi Steve,

 

I meant after you created the picture object, double-click on it and THEN use <Ctrl-A> to get all the properties.  I played with that just now and found that you can set the size to 0 to hide it.

Call GraphObjOpen("Metafile1")
  MtaWidth  = 0
  MtaHeight = 0
Call GraphObjClose("Metafile1")
Call PicUpdate

  

Like I was saying, you can also insert this logic in the "Before refresh:" field at the bottom of the "Layout Parameters" dialog, which then gets saved with the TDR file and runs every time you refresh the graph.

Call GraphObjOpen("Metafile1") : MtaWidth  = L1*3 : MtaHeight = L1 : Call GraphObjClose("Metafile1")

You might want to use an IIF(Condition, TrueValue, FalseValue) assignment instead of the L1 stuff, but you haven't told me yet what the visibility of the picture is contingent on.  Maybe a property value in the Data Portal?

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

 

 

Message 4 of 9
(4,665 Views)

Gold.  Thanks for the help, Brad!

0 Kudos
Message 5 of 9
(4,653 Views)

Brad, I got the script to work using an IIF conditional statement for the conditional visibility of the image (which is dependent on the value of a property in the Data Portal), and that works great, but I'm having trouble with getting the script to run before the refresh of the report.  I inserted the name of the script in the "Before Refresh" field in the "Layout Parameters" dialog box, like this "C:\Documents and Settings...Script.vbs" (obviously with the full path and name of the script), but I get an error message back that reads "Error in script or in script call < > for refreshing the graphic".  Any thoughts?

0 Kudos
Message 6 of 9
(4,647 Views)

Hi Steve,

 

If you're going to call a VBScript in the pre-refresh field, you have to use the ScriptStart(ScriptFilePath) command, but unless your commands are much more numerous that the 4 lines I posted earlier, I would recommend that you use the " : " syntax to put all 4 commands on one line and forego the script file path reference.  This will make it easier to move this application to another computer.  The other alternative is to call a known script file and use the same folder as the TDR file-- that's still pretty portable.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 7 of 9
(4,639 Views)

Brad, This is how the code looks in my script:

 

'------------------- Graphic --------------------------

 

Call GraphObjOpen("Metafile1")

MtaFileName = filelocation

MtaPosX = 83.17

MtaPosY = 97.99

MtaRelPos = "r-bot."

MtaWidth = 12

MtaHeight = 12

MtaRatioAdapt = 1

MtaEmbedded = 0

Call GraphObjClose("Metafile1")

Where "filelocation" = path and file name of the desired image.

When I run the code in the Script window, everything works fine, and the image changes to the appropriate file.  When I run the script as part of the refresh cycle in the TDR, It tells me that there is an error "refreshing the graphic".

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0 Kudos
Message 8 of 9
(4,604 Views)

Hi Steve,

 

I'm confused.  Do you still just want to make the image conditionally visible?  If so, then you don't need all those other properties, as I explained several posts above this one.  If you now want to do something different, like changing the color or the size or the image path conditionally, please explain your new goal(s).

 

What is the command line in the "Before refresh" field of the "Layout parameters" dialog of your REPORT layout?  What if you try to run that command line in a new VBScript in the SCRIPT panel?  There's nothing in your posted code that should cause an error (assuming the object name is correct), so that means either you aren't using ScriptStart() or you don't have the path to the VBS file correct.  Either way, taking what you have currently in the Layout parameters dialog and running it instead in the SCRIPT panel for testing purposes should show you the problem.  Note that in the SCRIPT panel you'll need to add a PicUpdate command at the end, because this is implicit as part of the REPORT refresh cycle.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments.

0 Kudos
Message 9 of 9
(4,582 Views)