length path  $  60;

FSEINIT:
      /* Assign a variable to the directory containing    */
      /* image files.                                     */
   path="directory-name";
      /* Assign an identifier to the image.               */
   img_id=picopen(1);
      /* Was the identifier assigned successfully?        */
   if (img_id=0) then
      do;
         _msg_="Image startup error";
         return;
      end;
   control term;
   return;

INIT:
      /* Initialize image variable.                       */
   image="";
      /* Initialize the region identifier.                */
   reg_id=0;
      /* Does the entry have a value for STYLE?           */
   if (style ne "") then
      do;
            /* Build possible names for the image file.   */
            /* Filename has .tif extension.               */
         filet=path||lowcase(style)||".tif";
            /* Filename has .gif extension.               */
         fileg=path||lowcase(style)||".gif";
            /* Image is in IMAGE entry.                   */
         filec="bolt.images."||style||".image";
            /* If the .tif file exists, specify TIFF      */
            /*    format in LNAMEMK.                      */
         if (fileexist(filet)) then
            img_path=lnamemk(1,filet,"format=tiff");
         else
            do;
                  /* If the .gif file exists, specify GIF */
                  /* format in LNAMEMK.                   */
               if (fileexist(fileg)) then
                  img_path=lnamemk(1,fileg,"format=gif");
               else
                  do;
                     /* If the image entry exists,        */
                     /* specify CAT format in LNAMEMK.    */
               if (cexist(filec)) then
                  img_path=lnamemk(5,filec,"format=cat");
                  end;
            end;
         if ( image ne "" ) then
            reg_id=picfill(img_id,"image",1,50,20,73,
               img_path);
      end;
   return;

MAIN:
   return;

TERM:
      /* Remove the image from the region in the screen.  */
   if (reg_id ne 0 and img_id ne 0) then
      rc=picdelete(img_id,reg_id);
   return;

FSETERM:
   if (img_id ne 0) then
      rc=picclose(img_id);
   return;