4D v16.3

SET PICTURE TO LIBRARY

Home

 
4D v16.3
SET PICTURE TO LIBRARY

SET PICTURE TO LIBRARY 


 

SET PICTURE TO LIBRARY ( picture ; picRef ; picName ) 
Parameter Type   Description
picture  Picture in New picture
picRef  Longint in Reference number of Picture Library graphic
picName  String in New name of the picture

The SET PICTURE TO LIBRARY command creates a new picture or replaces a picture in the Picture Library.

Before the call, you pass:

  • the picture reference number in picRef (range 1...32767 )
  • the picture itself in picture.
  • the name of the picture in picName (maximum length: 255 characters).

If there is an existing Picture Library graphic with the same reference number, the picture contents are replaced and the picture is renamed according to the values passed in picture and picName.

If there is no Picture Library graphic with the reference number passed in picRef, a new picture is added to the Picture Library.

4D Server: SET PICTURE TO LIBRARY cannot be used from within a method executed on the server machine (stored procedure or trigger). If you call SET PICTURE TO LIBRARY on a server machine, nothing happens—the call is ignored.

Warning: Design objects (hierarchical list items, menu items, etc.) may refer to Picture Library graphics. Use caution when modifying a Picture Library graphic programmatically.

Note: If you pass an empty picture in picture or a negative or null value in picRef, the command does nothing.

No matter what the current contents of the Picture Library, the following example adds a new picture to the Picture Library by first looking for a unique picture reference number:

 PICTURE LIBRARY LIST($alPicRef;$asPicNames)
 Repeat
    $vlPicRef:=1+Abs(Random)
 Until(Find in array($alPicRef;$vlPicRef)<0)
 SET PICTURE TO LIBRARY(vgPicture;$vlPicRef;"New Picture")

The following example imports into the Picture Library the pictures (stored in a document on disk) created by the third example for the command PICTURE LIBRARY LIST:

 SET CHANNEL(10;"")
 If(OK=1)
    RECEIVE VARIABLE($vsTag)
    If($vsTag="4DV6PICTURELIBRARYEXPORT")
       RECEIVE VARIABLE($vlNbPictures)
       If($vlNbPictures>0)
          For($vlPicture;1;$vlNbPictures)
             RECEIVE VARIABLE($vlPicRef)
             If(OK=1)
                RECEIVE VARIABLE($vsPicName)
             End if
             If(OK=1)
                RECEIVE VARIABLE($vgPicture)
             End if
             If(OK=1)
                SET PICTURE TO LIBRARY($vgPicture;$vlPicRef;$vsPicName)
             Else
                $vlPicture:=$vlNbPictures+1
                ALERT("This file looks like being damaged.")
             End if
          End for
       Else
          ALERT("This file looks like being damaged.")
       End if
    Else
       ALERT("The file “"+Document+"” is not a Picture Library export file.")
    End if
    SET CHANNEL(11)
    End

If there is not enough memory to add the picture to the Picture Library, an error -108 is generated. Note that I/O errors may also be returned (i.e., the structure file is locked). You can catch these errors using an error-handling method.



See also 

GET PICTURE FROM LIBRARY
PICTURE LIBRARY LIST
REMOVE PICTURE FROM LIBRARY

 
PROPERTIES 

Product: 4D
Theme: Pictures
Number: 566

This command modifies the Error system variableNot for server

 
HISTORY 

Created: 4D v6

 
ARTICLE USAGE

4D Language Reference ( 4D v16)
4D Language Reference ( 4D v16.1)
4D Language Reference ( 4D v16.2)
4D Language Reference ( 4D v16.3)