4d-database

How do you export pictures from 4D's tool box?


I am using 4D version 11.6 (72398) in remote mode and am trying to export three pictures from a database. How do you extract pictures from the tool box? Screenshots and editing are not acceptable if avoidable.


Solution

  • The Picture Library area of the Tool Box does not have an export feature. However, the following commands will help you export the pictures:

    PICTURE LIBRARY LIST gets an Array of Picture Names and an Array of Picture Reference ID's

    GET PICTURE FROM LIBRARY uses the Picture Reference ID to get the picture from the Picture Library into a Picture variable.

    WRITE PICTURE FILE writes the Picture variable to disk.

    The following code could be used to export all of the pictures in the Picture Library to disk as PNG files.

    C_TEXT($vsPicName;$vsFileName)
    C_LONGINT($vlNbPictures;$vlPicture;$vlPicRef)
    C_PICTURE($vgPicture)
    ARRAY TEXT($asPicName;0)
    PICTURE LIBRARY LIST($alPicRef;$asPicName)
    $vlNbPictures:=Size of array($alPicRef)
    If ($vlNbPictures>0)
        For ($vlPicture;1;$vlNbPictures)
            $vlPicRef:=$alPicRef{$vlPicture}
            $vsPicName:=$asPicName{$vlPicture}
            GET PICTURE FROM LIBRARY($alPicRef{$vlPicture};$vgPicture)
            If (OK=1)
                $vsFileName:=String($vlPicRef)+$vsPicName+".png"
                WRITE PICTURE FILE($vsFileName;$vgPicture;".png")
            End if 
        End for 
    Else 
        ALERT("The Picture Library is empty.")
    End if 
    

    If you run the code above from Single-user or from the Server the files will be placed next to the structure file.

    If you run the code above from from the Client the files will be placed into the 4D Client Cache folder which can be quickly opened using the following code:

    SHOW ON DISK(Get 4D folder(4D Client Database Folder);*)