Author Topic: help on migrating to IMatch 5  (Read 11420 times)

peterverm

  • Jr. Member
  • *
  • Posts: 70
help on migrating to IMatch 5
« on: August 19, 2014, 08:12:20 PM »
I'm trying to get my IMatch 3.6 scripts working in IMatch 5.

What is the IMatch 5 equivalent of the following IMatch 3.6 instructions ?

Application.WaitDialogOpen "Processing images...", 0, , True

MyDatabase.ParseVariables("{file.EXIF.Date and time Original}",MyFile)

Thanks,

Peter

JohnZeman

  • Global Moderator
  • *****
  • Posts: 1442
  • I'm too damn old to act my age.
Re: help on migrating to IMatch 5
« Reply #1 on: August 19, 2014, 11:24:46 PM »
The attached script demonstrates how to do both.



[attachment deleted by admin]

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 29382
Re: help on migrating to IMatch 5
« Reply #2 on: August 20, 2014, 09:03:36 AM »
There is a script migration guide in the IMatch help which explains what has changed. It explicitly mentions the progress dialog etc. Did you yet read this topic?

Ferdinand

  • 100 years since I was shot and a war was started
  • Global Moderator
  • *****
  • Posts: 1670
Re: help on migrating to IMatch 5
« Reply #3 on: August 20, 2014, 11:43:41 AM »
There is a section of the forum specifically for posts related to migrating scripts and I will move this thread there, where you may find addition tips.

Specifically, I have posted some migration notes that I use when I am migrating scripts to V5:
https://www.photools.com/community/index.php?topic=3088.0
I think it deals with part of your question, although I'm not sure it has all the differences for parsevariables.

You might also look at John Zenman's posts in this now-locked thread, as there are quite a few useful code snippets in the early part.
https://www.photools.com/community/index.php?topic=2769.0

But of course, as Mario observed, the best place to start is the relevant section of the help file.

peterverm

  • Jr. Member
  • *
  • Posts: 70
Re: help on migrating to IMatch 5
« Reply #4 on: August 21, 2014, 09:20:14 PM »
thank you all.

I'm an absolute beginner, I'll give it a try.

Regards,

Peter

peterverm

  • Jr. Member
  • *
  • Posts: 70
Re: help on migrating to IMatch 5
« Reply #5 on: August 24, 2014, 08:54:24 PM »
What is the difference between IMAttributeItem and IIMAttributeItem ?

Thanks,

Peter

Ferdinand

  • 100 years since I was shot and a war was started
  • Global Moderator
  • *****
  • Posts: 1670
Re: help on migrating to IMatch 5
« Reply #6 on: August 24, 2014, 11:36:39 PM »
TBH, I'm not really sure.  The help file has this:

With the scripting classes for Attributes you can create modify and delete Attribute Sets. And you can of course modify the values in global and per-file Attribute Sets. The following classes are available:

.  IMAttributeSet and IMAttributeSets
This class and its corresponding collection class represent Attribute Sets.
.  IIMAttribute and IIMAttributes
This class and its corresponding collection class represent Attributes within a set.
.  IIMAttributeItem and IIMAttributeItems
This class and its corresponding collection class represent Attribute Items stored in a global set or per-file set.
.  IIMAttributeValue and IIMAttributeValues
This class and its corresponding collection class represent individual values within an IIMAttributeItem

I've looked in my scripts and I haven't used any IIM... code, only IM....

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 29382
Re: help on migrating to IMatch 5
« Reply #7 on: August 25, 2014, 07:52:49 AM »
IIMAttributeItem is the COM interface name. Where did you get this from? Typo in the help?

Ferdinand

  • 100 years since I was shot and a war was started
  • Global Moderator
  • *****
  • Posts: 1670
Re: help on migrating to IMatch 5
« Reply #8 on: August 25, 2014, 09:28:05 AM »
My quotation in blue is from the help file.  Perhaps there is a typo, because as it reads now I didn't understand the difference between IM and IIM.

In the scripting editor, if you type "Dim xx as ...", in the drop-down you get both IM and IIM variable types for the attribute related variables.

I don't know where Peter was finding both of these, but that's where I found them.

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 29382
Re: help on migrating to IMatch 5
« Reply #9 on: August 25, 2014, 03:44:42 PM »
Ah, got it. Typo in the help.
In Basic script you always use the IMAttribute etc. Only "IM" at the front (for IMatch). The IIM... is how these classes are internally referenced by the COM subsystem in Windows. If in doubt, always check your the sample scripts.

Ferdinand

  • 100 years since I was shot and a war was started
  • Global Moderator
  • *****
  • Posts: 1670
Re: help on migrating to IMatch 5
« Reply #10 on: August 25, 2014, 04:03:50 PM »
I wasn't in doubt until someone pointed it out.  My scripts are working fine, probably because they were based on those sample scripts.

peterverm

  • Jr. Member
  • *
  • Posts: 70
Re: help on migrating to IMatch 5
« Reply #11 on: August 25, 2014, 07:55:04 PM »
thank you for sorting this out.  I'm making slow but steady progress in converting my scripts to IMatch 5.

Regards,

Peter

peterverm

  • Jr. Member
  • *
  • Posts: 70
Re: help on migrating to IMatch 5
« Reply #12 on: August 25, 2014, 09:17:46 PM »
My new problem :

I want to read an existing attribute, modify it, and write it back.

I find no example with .SetValue (not in the samples, not in the help).  And i don't understand how .SetValue would work, it has no parameter "Attribute name".

Hence I tried .GetValue

I created attribute output_1 as TEXT (edit / preferences / edit attributes)
Dim MyOutput As String
MyIMAttributeItem.GetValue("output_1") = MyOutput

gives as error "Type Mismatch".

MyOutput = MyIMAttributeItem.GetValue("output_1")

gives no error, but is not what i want to do.

Any idea ?

Peter

JohnZeman

  • Global Moderator
  • *****
  • Posts: 1442
  • I'm too damn old to act my age.
Re: help on migrating to IMatch 5
« Reply #13 on: August 25, 2014, 11:01:38 PM »
I don't use SetValue, actually I'm not sure how it should be used since GetValue does everything I need and it sounds like it should for you too.

If you create an attribute set and attribute like I show in the attached screen shot, then select one test image and manually enter a value for the Notes/Comments attribute in the Attributes panel, the below script should read it and change it to "x y z".



[attachment deleted by admin]

Ferdinand

  • 100 years since I was shot and a war was started
  • Global Moderator
  • *****
  • Posts: 1670
Re: help on migrating to IMatch 5
« Reply #14 on: August 26, 2014, 10:04:14 AM »
I don't use SetValue, actually I'm not sure how it should be used since GetValue does everything I need and it sounds like it should for you too.

Ditto.  GetValue is odd, in that it can be used to both read and write metadata.  It's been quite some time since I tried to use SetValue, but my recollection is that I couldn't get it to work.  There are no sample scripts that use it either.

Here is some sample code of mine:

Code: [Select]
            If r.GetValue("this_attribute") <> "" Then
                r.GetValue(this_attribute") = Str(r.GetValue("that_attribute"))
                r_update = 1
            End If

peterverm

  • Jr. Member
  • *
  • Posts: 70
Re: help on migrating to IMatch 5
« Reply #15 on: August 26, 2014, 08:43:35 PM »
Ok, i found the bug.

In fact, i did not tell you everything.

I did not use MyIMAttributeItem.GetValue("output_1") = MyOutput,

but rather MyIMAttributeItem.GetValue("output_" & i) = MyOutput

where i is an integer, ranging from 1 till 4.  And the concatenation did not work. (In IMatch 3.6 it worked just fine.)

Now i use

         MyAttributeName = "output_" & CStr(i)
         MyIMAttributeItem.GetValue( MyAttributeName ) = MyOutput

and it works just fine.

Regards,

Peter

Ferdinand

  • 100 years since I was shot and a war was started
  • Global Moderator
  • *****
  • Posts: 1670
Re: help on migrating to IMatch 5
« Reply #16 on: August 27, 2014, 08:14:17 AM »
I am surprised that your original formulation didn't work, but I haven't tried it. 

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 29382
Re: help on migrating to IMatch 5
« Reply #17 on: September 07, 2014, 12:35:34 PM »
SetValue is used like this:

Code: [Select]
    Dim f As File
    Set f = Application.GetFileWindow(imfwtCurrent).FocusedFile
    If f Is Nothing Then Exit Sub

    Dim item As IMAttributeItem
    If f.AttributeData("Image").Count > 0 Then
        ' File already has items. Get the first item
        Set item = f.AttributeData("Image")(1)

    Dim v As IMAttributeValue
Set v = item.GetValue("Remarks")
v = "A new remark"
item.SetValue(v)

        item.GetValue("Version") = "2.0"
        item.WriteBack
    End If

When you use

item.GetValue("Version") = "Bla"

you are doing the same, just under the hood.
GetValue returns an IMAttribtueValue and the default method is called when you assign to it.
Using SetValue with an instance of IMAttribtueValue allows you to access the formatted value and the value separately if needed, or to copy values.
« Last Edit: September 07, 2014, 01:07:15 PM by Mario »

Ferdinand

  • 100 years since I was shot and a war was started
  • Global Moderator
  • *****
  • Posts: 1670
Re: help on migrating to IMatch 5
« Reply #18 on: September 07, 2014, 02:09:28 PM »
It's been some time since I tried this so my recollection is hazy, but I didn't stumble across this usage.  I suggest this snippet should be in one of the sample scripts, perhaps the metadata one, so that users can see the differences.  Some of this commentary would be good in the help file as well.  I will send this suggestion via the link at the bottom of the help page.

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 29382
Re: help on migrating to IMatch 5
« Reply #19 on: September 07, 2014, 02:33:02 PM »
I have already added this to the help. It's not often used so not that important. Anyway.

peterverm

  • Jr. Member
  • *
  • Posts: 70
Re: help on migrating to IMatch 5
« Reply #20 on: September 14, 2014, 02:08:42 PM »
Gays,

my scripts seem to work, now something else :

In Imatch 3.2, in the slide show, you could work on the image : assign categories and ratings.  this is very practical.

In Imatch 5, in the slide show, i do not find these functionalities.  And when you leave the slide show, you do not return to the last image viewed, but to the start image.  This is not practical.

Did i miss something ?

Regards,

Peter

Ferdinand

  • 100 years since I was shot and a war was started
  • Global Moderator
  • *****
  • Posts: 1670
Re: help on migrating to IMatch 5
« Reply #21 on: September 14, 2014, 02:28:06 PM »
In IMatch 5 you use the Viewer for this.  Select an image and press Enter and you will see the Viewer.  The Slideshow is now just that - for showing images.  The Viewer is the replacement for working with larger views of images.  Note that it can be docked, undocked, on a second screen, etc.  More details in the help.

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 29382
Re: help on migrating to IMatch 5
« Reply #22 on: September 14, 2014, 03:30:09 PM »
Please see also the "For IMatch 3 users" help topic in the IMatch help. And the Visual Index which gives you an overview over all major features.
You find the help in the Help menu and there choose Open the Help System. Or just press <F1> to get help to your current context.

peterverm

  • Jr. Member
  • *
  • Posts: 70
Re: help on migrating to IMatch 5
« Reply #23 on: September 14, 2014, 09:44:13 PM »
OK, found it, thanks.

Peter

peterverm

  • Jr. Member
  • *
  • Posts: 70
Re: help on migrating to IMatch 5
« Reply #24 on: October 01, 2014, 09:13:53 PM »
I found the "HTML report" in the "Import & Export" window.

Can this report be configured ?  I found nothing in the help.

Thanks,

Peter

JohnZeman

  • Global Moderator
  • *****
  • Posts: 1442
  • I'm too damn old to act my age.
Re: help on migrating to IMatch 5
« Reply #25 on: October 02, 2014, 12:05:17 AM »
I am traveling today and not at my IMatch computer so I can't be specific but as I recall when I wrote my own personal html report I started with the provided example and modified it for what I needed.

To use it you select some images in IMatch and drag and drop them onto the html report section of the import export panel.  I think you can use the sample html report the same way by selecting then dragging and dropping files onto the html report but again, I'm not at my IMatch machine to verify that.

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 29382
Re: help on migrating to IMatch 5
« Reply #26 on: October 02, 2014, 07:50:59 AM »
I found the "HTML report" in the "Import & Export" window.

Can this report be configured ?  I found nothing in the help.

Thanks,

Peter

Did you even try this report? Because, when you drop some files on it, the HTML Report module brings up a dialog box where you can configure it...



[attachment deleted by admin]

peterverm

  • Jr. Member
  • *
  • Posts: 70
Re: help on migrating to IMatch 5
« Reply #27 on: October 02, 2014, 09:13:23 PM »
Mario,

please think better of me.  Off course i tried the report.  I do not get a pop up for report configuration.

However, i see there is an update of IMatch.  I will install and let you know.

Regards,

Peter

peterverm

  • Jr. Member
  • *
  • Posts: 70
Re: help on migrating to IMatch 5
« Reply #28 on: October 02, 2014, 09:36:12 PM »
Mario,

i installed the new release.  No change.  I drag and drop images on the report, and an HTML report is generated.  But there is no configuration dialog box.

Regards,

Peter

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 29382
Re: help on migrating to IMatch 5
« Reply #29 on: October 03, 2014, 08:45:39 AM »
The configuration dialog has been added in version 5.1.12. If you don't get it, an old version of the script is installed, and Windows installer for whatever reason does not update the script??? Please delete the script

C:\ProgramData\photools.com\IMatch5\scripts\system\Plugins\HTML Report\HTML Report.bas

and then run a repair of your IMatch installation via the Windows Control Panel > Add/Remove Software.

sinus

  • Global Moderator
  • *****
  • Posts: 4436
  • IMatch-User since 2001 (IMatch 3.6)
Re: help on migrating to IMatch 5
« Reply #30 on: October 03, 2014, 09:06:46 AM »
I tried here too, and it works fine, with this box, where I can change things.
Best wishes from Switzerland! :-)
Markus

Ferdinand

  • 100 years since I was shot and a war was started
  • Global Moderator
  • *****
  • Posts: 1670
Re: help on migrating to IMatch 5
« Reply #31 on: October 03, 2014, 10:03:24 AM »
Works here too.

jch2103

  • Oldtimer
  • ****
  • Posts: 2229
Re: help on migrating to IMatch 5
« Reply #32 on: October 03, 2014, 02:56:35 PM »
Likewise.
John

peterverm

  • Jr. Member
  • *
  • Posts: 70
Re: help on migrating to IMatch 5
« Reply #33 on: October 06, 2014, 05:52:58 PM »
I did as you said.  No change.  No configuration pop up.

In attachment a print screen of my computer, and a print screen of the content of the HTML directory.

Regards,

Peter



[attachment deleted by admin]

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 29382
Re: help on migrating to IMatch 5
« Reply #34 on: October 06, 2014, 06:28:48 PM »
Please attach the HTML Report.BAS (zip it) from your machine to your reply.

peterverm

  • Jr. Member
  • *
  • Posts: 70
Re: help on migrating to IMatch 5
« Reply #35 on: October 07, 2014, 09:17:22 PM »
Found it and solved it !

I had an old version of the HTML script, dated from 13/03/2014.

The new version, dated 23/08/2014, works just as you said.

Thanks,

Peter

[attachment deleted by admin]

peterverm

  • Jr. Member
  • *
  • Posts: 70
Re: help on migrating to IMatch 5
« Reply #36 on: October 11, 2014, 02:41:20 PM »
Dears,

I made a little script to publish my pictures on the web.  In fact, i copied your HTML report script, and made it produce the html outputs that i used to get out of the IMatch3 generator.  Works fine :-)

But : I do not find how i can delete files with a script.  Before i run my 'publish to the web' script, i want to empty the output directory.  How ?

---

And something completely different : in the slide show, after say 30 to 40 slides, the screen turns black.  Looks like a customisation setting that should receive a higher value.  Any idea ?

Regards,

Peter

Ferdinand

  • 100 years since I was shot and a war was started
  • Global Moderator
  • *****
  • Posts: 1670
Re: help on migrating to IMatch 5
« Reply #37 on: October 11, 2014, 02:55:09 PM »
Regarding deleting files with a script, the Database class has DeleteFile and DeleteFiles methods.  I haven't tried them.  If these don't work then a FileSystemObject method should, but use either of these with care.  Make sure that you know which files you're running the script on.

Regarding your slideshow problem, you're better off opening a separate bug report.  But before you do so you may care to search the community first, as this sounds familiar and perhaps it has been fixed.  Are you running the latest version?

peterverm

  • Jr. Member
  • *
  • Posts: 70
Re: help on migrating to IMatch 5
« Reply #38 on: October 14, 2014, 08:57:02 PM »
OK, it took me some time to understand why it didn't work : my output files are written outside the database, and the database class does not work on files outside the database.  Logical, but easily overlooked.

I did not find FileSystemObject in the help.  Can you please explain ?

Thanks,

Peter

JohnZeman

  • Global Moderator
  • *****
  • Posts: 1442
  • I'm too damn old to act my age.
Re: help on migrating to IMatch 5
« Reply #39 on: October 14, 2014, 10:02:26 PM »
In the script editor first you need to go to Edit > References and enable the Windows Script Host object model as shown in the attached screen shot.

Next is a very simple script that deletes a file not in your IMatch database.

Code: [Select]
Sub Main
Dim fs As New FileSystemObject

Dim f As String
f = "C:\Temp PSDs\2008_1005_104708.psd"

If fs.FileExists f Then
fs.DeleteFile(f)
End If
End Sub

[attachment deleted by admin]

peterverm

  • Jr. Member
  • *
  • Posts: 70
Re: help on migrating to IMatch 5
« Reply #40 on: October 18, 2014, 09:40:38 PM »
OK, thanks.

"Dim fs As New FileSystemObject" causes "ActiveX Automation: server cannot create object" error. 

I googled it, and i found

Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")

The script below works. 

Out of curiosity, why doesn't "Dim fs As New FileSystemObject" work ?

---

Const MyFileDirectory As String = "D:\Users\peter\Documents\imatch5\output\Publish_to_the_Web"

Sub Main

' Windows Script Host Object Model

' Dim fs As New FileSystemObject

Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")

Dim f As String
f = MyFileDirectory & "\*.*"

fs.DeleteFile(f, False)


Ferdinand

  • 100 years since I was shot and a war was started
  • Global Moderator
  • *****
  • Posts: 1670
Re: help on migrating to IMatch 5
« Reply #41 on: October 19, 2014, 09:40:09 AM »
I looked at my collection of scripts that use FileSystemObject in V3.6 & V5, and it seems to be used both with and without the "Set" command.  I don't recall why and I'm not enough of a programmer to understand why.

But one thing you should do with commands like "Set variable = ..." is to make sure that you always have a "Set variable = Nothing" command before the script concludes or you will get memory leaks (or so I'm told.  Since I'm not really a programmer I take these statements on trust.)