ZTree.com  | ZTreeWiki  | ZEN  | ZEST  | About...  

 Index   Back

[Notice] ZBar Script Host ZAAP   [Notice]

By: Martijn Coppoolse   Homepage   Voorburg, NL  
Date: Apr 14,2009 at 04:20
In Response to: [Notice] ZBar Script Host ZAAP (Ian Binnie)

> I tried running a vbs script (below) using the ZBar Script Host.
>
> Unfortunately I can't seem to do anything useful.
> In particular I wanted to access other WScript Methods/Properties.
> Is this possible?

The WScript object is built into (and specific to) WScript/CScript.exe; the ZBar Host doesn't provide it. The new version I'm working on does provide a (similar) Script object. But it looks like you don't need it for what you're trying to do.

> RegExp.js mentions objects:- zbar, File, OtherFile
> zbar seems to work.
>
> Option Explicit
>
> Dim oShell
>

Note that in scripting there is usually no need for a 'main' function. Just put the code outside any function and it'll be run when the script is loaded. Of course, if you prefer having a Main function, you can still define it, but you'll have to call it on a separate line.

> Function main()
> Set oShell = WScript.CreateObject("WScript.Shell")
> Alert("Main Called")
> End Function

When this function is executed, WScript.CreateObject will error out, as no WScript object exists. In the current version, I don't think I've incorporated a CreateObject function, but IIRC VBScript includes a native CreateObject function; so it should work after removing the 'WScript.' part.

And the 'onAssist' function should fail on 'oShell.Run' ("Object expected" or "Object variable or With block variable not set"), because that object won't exist since the 'main' function hasn't been called.

I've almost finished a new version, which provides a slicker UI (at the price of a huge executable) as well as a higher-resolution timer and more built-in objects, properties and methods.
Oh, and new bugs, of course. ;-)

But for now, the following one should work (off the top of my head, haven't tested it here):

Option Explicit

Dim oShell

Set oShell = CreateObject("WScript.Shell")
Alert("Main Called")

Function onAssist(zbar)
Dim Return
onAssist = TRUE

If ((zbar.ZtreeScreenStatus = Asc("l")) Or (zbar.ZtreeScreenStatus = Asc("r"))) And zbar.ZtreePage = Asc("F") Then
Return = oShell.Run("%#ZThome%\Tfc.exe -b " & """" & zbar.NewFilename & """" & " " & """" & zbar.OtherFilename & """", 0, True)
If Return = 0 Then onAssist = FALSE
End If
End Function


--
Martijn

403 views      
Thread locked
 

Messages in this Thread

 
82,796 Postings in 10,445 Threads, 196 registered users, 13 users online (1 registered, 12 guests)
Index | Admin contact |   Forum Time: Sep 9, 2010 - 4:44 pm CDT  |  Hits:5,288,666  (2,631 Today )
RSS Feed