Re: [MaxImDL] question about simple script and constants


Dec 5, 2001

 


----------------------------

#803 Dec 5, 2001

This simple script doesn't work properly unless I substitute a "5" in

place of "mxHotPixelKF". Am I missing a command in the beginning of

the script that defines global constants like "mxHotPixelKF"?







Dim doc

Dim docs

Dim app



Set doc = CreateObject("MaxIm.Document")

Set app = CreateObject("MaxIm.Application")



Set docs = app.Documents



For Each Document in docs



Document.KernelFilter mxHotPixelKF, 20



next



----------------------------

#804 Dec 5, 2001

etotman wrote: >

> This simple script doesn't work properly unless I substitute a "5" in

> place of "mxHotPixelKF". Am I missing a command in the beginning of

> the script that defines global constants like "mxHotPixelKF"?

>

> Dim doc

> Dim docs

> Dim app

>

> Set doc = CreateObject("MaxIm.Document")

> Set app = CreateObject("MaxIm.Application")

>

> Set docs = app.Documents

>

> For Each Document in docs

>

> Document.KernelFilter mxHotPixelKF, 20

>

> next



I believe if you're using VBScript the namespace will not be available unless

you do something fancy. In Visual Basic you could import the type library.



Doug



---------------



Doug George

dgeorge@...



Diffraction Limited

Makers of Cyanogen Imaging Products

www.cyanogen.com



100 Craig Henry Drive, Unit 106,

Ottawa, Ontario, Canada, K2G 5W3



Phone: (613) 225-2732

Fax: (613) 225-9688



---------------



----------------------------

#806 Dec 6, 2001

Ed --



Assuming you are using CScript/WScript (Windows Script Host) to run your

script, the named constants are not normally available (see below). While

Windows Script Host is capable of running a straight script as you are

doing, with a bit more effort many more things become possible. For example,

you can mix languages within a single "script".



To do what you want, you use a container file called a WSF file, say

test.wsf, and "run" that. It contains some simple XML to identify the script

itself, and you can reference components in a way that makes their named

symbols available. I used "MaxIm.CCDCamera" below, but actually any of

MaxIm's objects (.Application, .Document) would work in its place. The

effect is to load the symbols from MaxIm into the script's name space.



The name "Job1" can be anything, and the debug="false" can be changed to

"true" if you have a script debugger installed (see below). By the way, if

you are going to Dim variables (a good idea!) add Option Explicit to the

beginning of your script and you'll get errors when you use an undefined

variable (a type, usually, and very hard to diagnose without Option

Explicit!). I also added a line that uses the Windows Script Host "Echo()"

method to give you feedback as the documents are filtered. If you run this

from cscript (cscript xxx.wsf), the names will show in your command window.

If you double-click the WSF file (using wscript), you'll get an annoying

message box when each document completes, so you probably will want to get

rid of that line.



package>

job id="Job1

?job error="true" debug="false" ?>

reference object="MaxIm.CCDCamera"/>

script language="VBScript



Option Explicit

Dim doc, docs, app



Set doc = CreateObject("MaxIm.Document")

Set app = CreateObject("MaxIm.Application")

Set docs = app.Documents

For Each Document in docs

Document.KernelFilter mxHotPixelKF, 20 ' You can use the symbol now!

WScript.Echo "Filtered " & Document.DisplayName " **ADDED **

Next



/script>

/job>

/package>



PS: I used a simplified syntax for the above. It will not pass XML

validation, but will run fine under WSH. See the docs (see below) for the

strict XML syntax.



PLUG>

At the ASCOM site, there is a "Getting Started" document that contains some

valuable resources:



ascom-standards.org/kick-start.html



In the "Useful Tools & Information" section of that page is a link to the

downloadable Microsoft Windows Script documentation:



download.microsoft.com/download/winscript56/Install/5.6/

W982KMeXP/EN-US/scrdoc56en.exe



This is the place where WSF files are described, along with all other things

Windows Script. There is a tutorial on Windows Script Host (cscript/wscript)

in that same document, as well as the reference manuals for VBScript and

JScript. When you installed the ASCOM Platform 1.2, you go the Windows

Script 5.6 engines.



Finally, the ASCOM "Getting Started" document also contains instructions on

how to enable and use the Office 2000 MSE Debugger for debugging scripts. If

you have Microsoft Office 2000, you already have a good debugging tool for

scripts.



Note that scripts written to run under ACP2 (rather than cscript/wscript)

cannot be in the WSF format. I have a wish list item for ACP to add a

built-in method to allow loading object symbols into the scrip's name space,

as well as to pre-load MaxIm's symbols (Camera is already a built-in object

in ACP2's script and ASP name spaces).



-- Bob







Contact Us
This Site's Privacy Policy
Google's privacy policies

S
e
n
i
o
r
T
u
b
e
.
o
r
g