hexagon logo

How to Insert Multiple Images Into the Report

Hi All,

A bit over a year ago I asked this question on how to have an image generated on the fly shown in the report. The very helpful answer provided by was to create a custom report label template and use an Events script to update the image when the label is run. This works great when I only have one image. What I'm trying to do now, though, is run multiple similar calculations using subroutines and bring an image from each into my program.

Right now, my subroutine uses a particular custom label template, containing a single image. The subroutine copies the image I want to show to the file referenced in the label and then shows the label. When I run my test program, the report as shown in the report window looks as I would expect - a different image is shown for each subroutine call. However, the printed PDF shows the last shown image repeated each time the label is used. The same thing happens if I hit the refresh icon in the report window - the refreshed report shows the same image repeated.

Here's the code that calls my label in the subroutine. The image is copied into the right name using the FILE/COPY command, and the label name is specified by a variable so I can switch between development/test and production versions:

ASSIGN/IMAGENAME=TMPDIR + QUEUESTRUCT.OUTFILENAME + ".bmp"
FILE/COPY,IMAGENAME,TMPDIR + "SHOW_temporary_image_file.bmp",OVERWRITE
REPORT/LABEL, FILENAME= REPTLABEL​


Here's the event update code in the label template, under event "EventReportData":

this.Bitmap = "C:\CMM_local_data\tmp\SHOW_temporary_image_file.bmp"


The only thing in my label template is this bitmap object.

Is there some way (perhaps specifying a different event? How would I do that?) to "lock" the label template to the image it loads when the REPORT/LABEL command is called? Is there another way to accomplish loading multiple different images through a label template like this?
Parents
  • I played around with this some. I modified the image label to look for a variable inside of pcdmis (ASSIGN statement).

    On the EventReportData event for the bitmap I put the lines

    Dim Command As Object
    Dim imagePath As String
    Dim assignName As String
    Dim done As integer
    
    imagePath = "D:\Temp\label1.jpg" ' give it a default
    
    Set Command = ReportData.GetCommand
    done = 0
    
    While Not(Command is Nothing) And done <> 1
        If Command.Type = 195 Then
             assignName = Command.GetText(133, 1)
             If assignName = "IMAGEPATH" Then
                imagePath = Command.GetText(134, 1)
                If Mid(imagePath, 1, 1) = """" Then   ' strip off added quotes
                   imagePath = Mid(imagePath, 2, Len(imagePath)-2)
                End If
                done = 1
             End If
       End If  
       Command.Prev
    Wend
    
    this.bitmap = imagePath
    ​


    which looks into the PRG from the REPORT command going backwards for the variable IMAGEPATH and uses the value to create the image on the report.

                ASSIGN/IMAGEPATH="D:\TEMP\MYLABEL.JPG"
                REPORT/LABEL, FILENAME= IMAGELABEL.LBL
                ASSIGN/IMAGEPATH="D:\TEMP\SMART2.JPG"
                REPORT/LABEL, FILENAME= IMAGELABEL.LBL
                ASSIGN/IMAGEPATH="D:\TEMP\IMAGE.JPG"
                REPORT/LABEL, FILENAME= IMAGELABEL.LBL
    ​


    I used my path and JPG files as I was just seeing if it would work.
    Seems to with my limited testing.

    195 is the ASSIGN statement type
    133 is the destination variable name
    134 is the source expression
Reply
  • I played around with this some. I modified the image label to look for a variable inside of pcdmis (ASSIGN statement).

    On the EventReportData event for the bitmap I put the lines

    Dim Command As Object
    Dim imagePath As String
    Dim assignName As String
    Dim done As integer
    
    imagePath = "D:\Temp\label1.jpg" ' give it a default
    
    Set Command = ReportData.GetCommand
    done = 0
    
    While Not(Command is Nothing) And done <> 1
        If Command.Type = 195 Then
             assignName = Command.GetText(133, 1)
             If assignName = "IMAGEPATH" Then
                imagePath = Command.GetText(134, 1)
                If Mid(imagePath, 1, 1) = """" Then   ' strip off added quotes
                   imagePath = Mid(imagePath, 2, Len(imagePath)-2)
                End If
                done = 1
             End If
       End If  
       Command.Prev
    Wend
    
    this.bitmap = imagePath
    ​


    which looks into the PRG from the REPORT command going backwards for the variable IMAGEPATH and uses the value to create the image on the report.

                ASSIGN/IMAGEPATH="D:\TEMP\MYLABEL.JPG"
                REPORT/LABEL, FILENAME= IMAGELABEL.LBL
                ASSIGN/IMAGEPATH="D:\TEMP\SMART2.JPG"
                REPORT/LABEL, FILENAME= IMAGELABEL.LBL
                ASSIGN/IMAGEPATH="D:\TEMP\IMAGE.JPG"
                REPORT/LABEL, FILENAME= IMAGELABEL.LBL
    ​


    I used my path and JPG files as I was just seeing if it would work.
    Seems to with my limited testing.

    195 is the ASSIGN statement type
    133 is the destination variable name
    134 is the source expression
Children
No Data