Source language: Translate to:

Getting a variable = error 80020101

Questions and information about using VBScript and JavaScript in NeoBook functions

Moderator: Neosoft Support

Getting a variable = error 80020101

Postby dpayer » Fri Oct 31, 2008 5:26 am

I am attempting to use a VBScript to pull a list of directories.

The script I am adapting to use in NB is the following:
Code: Select all
Set FSO = CreateObject("Scripting.FileSystemObject")
ShowSubfolders FSO.GetFolder("C:\temp")
Sub ShowSubFolders(Folder)
    For Each Subfolder in Folder.SubFolders
        Wscript.Echo Subfolder.Path
        ShowSubFolders Subfolder
    Next
End Sub


To test this, you can change the place that has c:\temp to read a folder of your choice. Save this file as listfolder.vbs and then execute it at a command prompt with:

cscript listfolder.vbs

You will see that it pulls the name of all subfolders and displays them on the screen. I remove the line: ShowSubFolders Subfolder so it will only show the subfolders of the first folder (in this case: c:\temp) and not recurse the entire directory.

In my NBBrowserExecScript, I do not want to Echo the value, I want to get it and set a NB variable

The help file says to use the following format:
Code: Select all
window.external.nbSetVar( variable name, value )



So I create a folder with only one subfolder for testing and try to execute this:

Code: Select all
Set CNTR = 1Set FSO = CreateObject("Scripting.FileSystemObject")
ShowSubfolders FSO.GetFolder("C:\temp\xyz")

Sub ShowSubFolders(Folder)
    For Each Subfolder in Folder.SubFolders
       
        Set PPF = (Subfolder.Path)
        window.external.nbSetVar( '[PPF]', PPF )

   
End Sub


I put in an alertbox to show the contents of the variable but when I run the app I get the following error:

"could not complete the oreration due to error: 80020101"

A google search only pointed to javascript examples with this error.

Just in case this was an error that dealt with special characters, I also tried using the %hex equivalent of the ' ] [ keys. No luck.

Did I use the example incorrectly? Is it the same for VB and JavaScript? Is " window.external.nbSetVar" meant to use a specific name in my instance like: "webbrowser1.nbsetvar"?

Any insight is appreciated.

David Payer
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Postby beno » Fri Oct 31, 2008 5:43 am

Hi David,

I have found that error code when there is a missing object or property in my code.

For example if I try to access a element (getElementById()) and the object referenced does not exist then this error pops.

I have not used VBScript yet, nor tested your code. I am just sharing my experience with this error, which is familiar to me.

HTH,

beno
User avatar
beno
 
Posts: 678
Joined: Fri Apr 01, 2005 9:03 am
Location: México

Postby Gaev » Fri Oct 31, 2008 5:57 am

David Payer:

a) Not sure if you copy/pasted the code sections directly from your NeoBook Function files or just typed them in from memory ... but there is no matching Next command to the For Each SubFolder ... command in your second code block

b) VBScript has some syntax differences compared to Javascript ... instead of Set PPF = in Javascript, VBScript uses PPF = ... but you also need to define such a variable first using the Dim command.

Also, not sure why you have brackets around the SubFolder.Path.

c) Don't know if window.external.nbSetVar( '[PPF]', PPF ) works when used in NeoBook Functions of the VBScript kind ... or just when inside html documents running in a Browser Object ... but I use ...publication.nbSetVar "[PPF]",PPF


80020101 is the "catch all" zipcode ... I mean error code ... that gets returned for every kind of error encountered in such an environment ... often, the only recourse is to add one command to a working Function ... test ... repeat until you encounter an error ... then figure out why it balks at the latest change.
User avatar
Gaev
 
Posts: 3717
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby dpayer » Fri Oct 31, 2008 6:43 am

Gaev wrote:David Payer:

a) Not sure if you copy/pasted the code sections directly from your NeoBook Function files or just typed them in from memory ... but there is no matching Next command to the For Each SubFolder ... command in your second code block

b) VBScript has some syntax differences compared to Javascript ... instead of Set PPF = in Javascript, VBScript uses PPF = ... but you also need to define such a variable first using the Dim command.

Also, not sure why you have brackets around the SubFolder.Path.

c) Don't know if window.external.nbSetVar( '[PPF]', PPF ) works when used in NeoBook Functions of the VBScript kind ... or just when inside html documents running in a Browser Object ... but I use ...publication.nbSetVar "[PPF]",PPF


80020101 is the "catch all" zipcode ... I mean error code ... that gets returned for every kind of error encountered in such an environment ... often, the only recourse is to add one command to a working Function ... test ... repeat until you encounter an error ... then figure out why it balks at the latest change.


Thanks Gaev (and Beno) for your comments.

a) you are right but since I created a folder with only one subfolder, I would have thought that not an issue
b) interestingly enough, in my testing, I did use DIM statements to see if it made a difference. It didn't. Also, the script itself (which works) does a set without a DIM statement. I think it is recommended to be explicit and define all variables but not required for a local case like this.
c) I think this is where my error most likely is to be found. I did place a browser window in my NB pub and reference it when I execute the script. (I believe it acts as a host for the script in the same way cscript.exe does at a command line). I don't know if I am supposed to be using something more specific.

re: brackets around the path. Well, I thought it had to 'resolve' that and not treat it like a variable. Ahh.... learning the syntax of a language. I am pretty sure I have some sort of syntax error in my use.

OK, I will play with this a bit more. The NB docs in the help file are a bit sparse on this.

One question, can you execute a script without a browser object? The dialogue box requires and object to utilize a script. It didn't recognize my entry when I simply tried to name it something. I had to reference an existing object in the NB file.

David P
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Postby dpayer » Fri Oct 31, 2008 6:52 am

Gaev wrote:c) Don't know if window.external.nbSetVar( '[PPF]', PPF ) works when used in NeoBook Functions of the VBScript kind ... or just when inside html documents running in a Browser Object ... but I use ...publication.nbSetVar "[PPF]",PPF


Specific question:

When you say: ... but I use ...publication.nbSetVar "[PPF]",PPF

are you recommending I literally use publication.nbSetVar or MYPUBNAME.nbsetvar ?

Do you drop the parenthesis around the "[PPF]",PPF and use full quotes instead of single quote (apostrophe?) as in the helpfile?

Thanks.

David P
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Postby Gaev » Fri Oct 31, 2008 8:35 am

David Payer:
you are right but since I created a folder with only one subfolder, I would have thought that not an issue

... different languages have different levels of "strictness" about syntax structures ... most (including html) are gravitating towards "full compliance" ... as it becomes too difficult to figure out the complex nested structures.

interestingly enough, in my testing, I did use DIM statements to see if it made a difference. It didn't.

... if there were multiple errors, and this reduced them by one, you will still get this error message until there are none left.

Also, the script itself (which works) does a set without a DIM statement. I think it is recommended to be explicit and define all variables but not required for a local case like this.

... the one that works does not have any user created variables ... properties of created object are NOT standalone variables.

I think this is where my error most likely is to be found. I did place a browser window in my NB pub and reference it when I execute the script. (I believe it acts as a host for the script in the same way cscript.exe does at a command line). I don't know if I am supposed to be using something more specific.

... pardon me but all my comments were under the ASSumption (on my part) that you were deploying your code in a NeoBook Function ... as facilitated with v5.6 ... and not as a script inside an html that you load into a WebBrowser Object.

One question, can you execute a script without a browser object?

... as part of a NeoBook Function ... see comment above.

The dialogue box requires and object to utilize a script. It didn't recognize my entry when I simply tried to name it something. I had to reference an existing object in the NB file.

... sorry I do not understand this at all.

When you say: ... but I use ...publication.nbSetVar "[PPF]",PPF

are you recommending I literally use publication.nbSetVar or MYPUBNAME.nbsetvar ?

Do you drop the parenthesis around the "[PPF]",PPF and use full quotes instead of single quote (apostrophe?) as in the helpfile?

... literally publication.nbSetVar .. followed by [someNeoBookVariableName] inside double quotes .... followed by a comma ... followed by the VBScript variable name.

This is a command that the VBScript command interpreter interprets/executes ... publication is an automatically created "object" that VBScript knows about ... nbSetVar is a "method" defined within this object.

I think you need to look at the Help section that refers to coding of "commands" inside NeoBook Functions using a Javascript or VBScript language ... not the section that deals with html/script code in html pages that are loaded inside Browser Objects.
User avatar
Gaev
 
Posts: 3717
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada


Return to NeoBook Functions - VBScript & JavaScript

Who is online

Users browsing this forum: No registered users and 0 guests