🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #20996

Re: ID Windows scripting w/ VB.NET

#20996
From: Greg Brunet
Date: Wed, 15 May 2002 17:37
23 lines
4308 bytes
Ole: 

I think that VBScript uses variants because, in some ways, it's simpler.  It makes it easier for whipping together some quick code.  It's not 'better', however, since most developers prefer 'strongly-typed' languages since it helps in writing better code. 

I've already wondered about the ID object library format in VB6.  In most cases, when I add a reference to a library in VB6, I can do something like: Dim myInDesign As InDesign.Application 

    Set myInDesign = New InDesign.Application                   '** should work but doesn't     Set myInDesign = CreateObject("InDesign.Application.2.0")   '** have to do it this way  

Now you've got to use the second method with VBScript, but the first (or something like it) should work with VB.  Once I have set the reference (Using the 'Project > References' option in VB6 (you need to go to the 'COM' tab in VB.NET), then the editor knows about the object model & intellisense can even help in providing a dropdown of properties & methods if you define the specific object you're going to use.  So at least it's working partially. 

As a further test, I took some working VB6 code and opened it in VB.NET which causes it to translate it into the new language structure.  It automatically picked up the reference to the Type Library, and translated the code fairly well.  It failed on a few items, such as these from the ChangePreference definition sample code in the ID 2.0 Scripting Guide:     myInDesign.FindPreferences = idNothing     myInDesign.ChangePreferences = idNothing Property 'FindPreferences' is 'ReadOnly'. Property 'ChangePreferences' is 'ReadOnly'.  

According to the manual, these properties of the Application object are r/w, but VB.NET doesn't seem to think so.  They are also supposed to be able to be cleared by setting them to 'idNothing', but, of course, that's a constant, and not an object - it's not a problem with a scripting language where everything gets 'coerced' to the right type, but VB.NET is a lot more picky about this, so I'm not sure how to correct this code. 

I also got a whole lot of these kinds of warnings: 'UPGRADE_WARNING: Couldn't resolve default property of object ...  (practically every line generated that kind of message).  These are just warnings, and I can ignore them, but it's likely that there may be some underlying impact. 

After converting the code & making a few tweaks, I was able to run it.  I tested my benchmarking code to see how that would make out and unfortunately saw a performance hit!  I've posted the results in the "ID Win/VB Scripting Benchmarks" thread in case anyone's interested.  An interesting thing is that it actually runs slower as an EXE than in the IDE!  The compiled minimized version is 38% slower than the VB6 code - enough to cause me to consider writing this stuff in VB6.  That's a real pain, since we had hoped to write all of it in VB.NET - maybe next time. 

You mentioned "seeing our object library" - I'm new here, but does that mean that you're an Adobe employee, or at least have some insight about the plans for this portion of ID?  A big question that I have is when (hopefully not just if) we can expect to see native support for .NET for ID Scripting?  As a selling point to Adobe - the .NET languages are all much better integrated than the older versions, so I would expect that by providing support in this manner, they'd provide accessibility to all of the .NET tools with one library. 

Thanks for your help (and for the info on the ID 2.0 sample scripts), 

-- Greg
Technical Details
Message-ID: <ef88970.1@WebX.aaQKaf7vad4>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!newsfeed.online.be!diablo.netcom.net.uk!netcom.net.uk!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <ef88970.-1@WebX.aaQKaf7vad4>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,7a66ec024331ffe5
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2002-05-15 11:07:47 PST
From: "Greg Brunet" <gbrunet@sempersoft.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!newsfeed.online.be!diablo.netcom.net.uk!netcom.net.uk!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Re: ID Windows scripting  w/ VB.NET
Message-ID: <ef88970.1@WebX.aaQKaf7vad4>
Date: Wed, 15 May 2002 10:37:57 -0700
References: <ef88970.-1@WebX.aaQKaf7vad4>
Lines: 72
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit