PreviousNext
Help > Development > W-Language Functions for AS/400 > IFS functions > ASfLoadText - ASfLoadBinary > Complete example
Complete example

 

Into this example, we use the following table:

Une image présente sur l’IFS est chargée dans un buffer avec la fonction ASfChargeBinaire, et ensuite un nouvel enregistrement est inséré dans la table avec la fonction HAjoute.

Le dernier enregsitrement est ensuite lu et l’image sauvée sur le PC avec la fonction HExtraitMémo.

An image on the IFS is loaded into a buffer with the ASfLoadBinary (ASfChargeBinaire) function, and then a new record is inserted into the table with the HAjoute function.

The last recording is then read and the image saved on the PC with HExtraitMémo.

 

id est un entier

bufIn est un Buffer

 

HOuvreConnexion(MaConnexionpower8)

 

QUAND EXCEPTION DANS

       zsChemin est une chaîne      

       zsChemin = "/tmp/Photo.gif"

       bufIn = ASfChargeBinaire(zsChemin,MaConnexionpower8)

      

       Blobced.Image = bufIn

      

       SI HAjoute(Blobced) ALORS

              Info("ajoute done!")

          SINON

                  Info(ErreurInfo())

          FIN

      

      

       // retrieve ID value of the last record

          SI HLitDernier(Blobced, Idblobced) ALORS

              Info(Blobced.Idblobced)

              id = Blobced.Idblobced

             

          SINON

                   Info("Fichier non trouvé " + ErreurInfo())

          FIN

      

      

FAIRE

       Info("exception!"

       Info(ExceptionInfo())

FIN

 

//////////////////////////////////////////

// Read last record

//////////////////////////////////////////

 QUAND EXCEPTION DANS

       Info(id)

       HRAZ(Blobced,Idblobced)

       SI HLitRecherchePremier(Blobced,Idblobced,id)

              zsCheminc est une chaîne      

              zsCheminc = "C:\temp\Photo6.gif"

                   // Extrait le document sur le disque

                   SI    HExtraitMémo(Blobced, Image, zsCheminc) ALORS

                           Info("extrait!")

                   SINON

                           Info(ErreurInfo())

                   FIN

          SINON

                   Info("Fichier non trouvé " + ErreurInfo())

          FIN

FAIRE

          Info("exception!"

          Info(ExceptionInfo())

FIN

 

HFermeConnexion(MaConnexionpower8)