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:

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

The last recording is then read, and the image saved on the PC with HExtractMemo.

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 HExtractMemo.

 

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)