Displaying column images

You can use PHANTOM fields and the IMAGECOLUMN attribute to display images in a column, to the left of the column value.

To display an image on the left of the column value in table views, define a PHANTOM field to hold the image name, and bind it to a parent column with the IMAGECOLUMN attribute.
LAYOUT
TABLE
{
[c1            |c2          ]
[c1            |c2          ]
[c1            |c2          ]
}
END
END
ATTRIBUTES
PHANTOM FORMONLY.file_icon;
EDIT c1 = FORMONLY.file_name, IMAGECOLUMN=file_icon;
EDIT c2 = FORMONLY.file_size;
...
END
INSTRUCTIONS
SCREEN RECORD sr(FORMONLY.*);
END
The program code can then display the specified image with each row.
DEFINE arr DYNAMIC ARRAY OF RECORD
     file_icon STRING,
     file_name STRING,
     file_size INTEGER
  END RECORD
...
FOR x=1 TO max_files
    CASE file_type(arr[x].file_name)
    WHEN "file" LET arr[x].file_icon = "file"
    WHEN "dir"  LET arr[x].file_icon = "folder"
    END CASE
END FOR
...
DISPLAY ARRAY arr TO sr.*
   ...
END DISPLAY
When images come from the database, these are typically fetched into BYTE variables. If the BYTE variable is located in a file (LOCATE IN FILE), it can be bound to the IMAGECOLUMN field: The runtime system will automatically display the image data. Note, however, that each BYTE element of the array must be located in a distinct file. This can be done as follows:
DEFINE arr DYNAMIC ARRAY OF RECORD
           pic_num INTEGER,
           pic_data BYTE,
           pic_when DATETIME YEAR TO SECOND
       END RECORD
...
DECLARE c1 CURSOR FOR SELECT * FROM mypics
LET i=1
LOCATE arr[i].pic_data IN FILE
FOREACH c1 INTO arr[i].*
    LOCATE arr[i:=i+1].pic_data IN FILE
END FOREACH
CALL arr.deleteElement(i)
...
Depending on the data source, you might want to use a program array structured with sub-records, to define database table related data from row information used at runtime only, as described in Variable binding in DISPLAY ARRAY:
SCHEMA shop
DEFINE a_items DYNAMIC ARRAY OF RECORD
                   item_data RECORD LIKE items.*,
                   it_image STRING,
                   it_count INTEGER
               END RECORD