Options

Export pictures...

bin-dophbin-doph Member Posts: 4
Hi community,

I'm trying to export all the pictures from table contact to my local filesystem (I do have an old database and only the pictures are needed to import in my actual database). I'm pretty new to navision and tried a couple of stuff, but I always end up in having "functional code, what does not what I expect". I keep getting no images exported this way:
IF contact.FIND('-') THEN BEGIN
//  MessageCount := 1;
  REPEAT
//   MessageCount := MessageCount + 1;
//   IF (MessageCount < 10) THEN 
//     MESSAGE('currently working' + contact."No.");
// Check if image exists and export
    IF (contact.Picture.HASVALUE) THEN
//BEGIN
//     MESSAGE('Exportiere Bild von Kunde ' + contact."No.");
      contact.Picture.EXPORT('C:\navision_images\' + contact."No." + '.BMP',FALSE)
//   END
//   ELSE 
//     IF (MessageCount < 20) THEN
//       MESSAGE('%1 has no image', contact."No.");
  UNTIL contact.NEXT = 0;
END;

I commented out the debugging stuff, but my .HASVALUE-condition seems never to be true :?

thx for any piece of help in my noob-quest in advance
-fe

Comments

  • Options
    GoMaDGoMaD Member Posts: 313
    Add
    contact.calcfields(Picture)
    

    after the Repeat

    thus resulting in:

    Code:
    IF contact.FIND('-') THEN BEGIN 
    //  MessageCount := 1; 
      REPEAT 
      contact.CALCFIELDS(Picture);
    //   MessageCount := MessageCount + 1; 
    //   IF (MessageCount < 10) THEN 
    //     MESSAGE('currently working' + contact."No."); 
    // Check if image exists and export 
        IF (contact.Picture.HASVALUE) THEN 
    //BEGIN 
    //     MESSAGE('Exportiere Bild von Kunde ' + contact."No."); 
          contact.Picture.EXPORT('C:\navision_images\' + contact."No." + '.BMP',FALSE) 
    //   END 
    //   ELSE 
    //     IF (MessageCount < 20) THEN 
    //       MESSAGE('%1 has no image', contact."No."); 
      UNTIL contact.NEXT = 0; 
    END; 
    

    The calcfields is necessary because of the fact that the Picture
    field is a BLOB field.

    Regards
    Now, let's see what we can see.
    ...
    Everybody on-line.
    ...
    Looking good!
  • Options
    bin-dophbin-doph Member Posts: 4
    thx a lot!
  • Options
    Alesh77Alesh77 Member Posts: 4
    Hey! Could this code be also used in other way - to import pictures for Items? Thanks alot. #-o
  • Options
    bin-dophbin-doph Member Posts: 4
    Alesh77 wrote:
    Hey! Could this code be also used in other way - to import pictures for Items? Thanks alot. #-o

    I don't know... I basically don't know if it's possible to glob for files in a directory and to extract information out of the filename (which would be the no. so just the .BMP is dropped). But the import-function is there so I guess it should be possible...somehow...
    GoMaD wrote:
    contact.calcfields(Picture)
    

    I run that code using calcfields and it did what I wanted. I uncommented my debugging-messages, but it didn't do what I expect, as I said, I'm not that experienced yet, but maybe you could give me some further explaination. I expected something like that:
      get record tell me what record it is ("currently working on...") check if hasvalue yes: tell me and export no: tell me a (max 20 times)

    What I saw was something different. First all pictures got exported (that took a lot of time, load of pics, that's why I mentioned it), then I had to click away my nasty debug messages. Also the references I have (printouts and onlinehelp) tell me that calcfields is only used to refresh flowfields, but IMHO Picture is not a flowfield (or am I wrong here?)

    Would be nice, if someone could briefly explain that behaviour to me, thx in advance
    -fe
Sign In or Register to comment.