Source language: Translate to:

JSCRIPT ERROR

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

JSCRIPT ERROR

Postby virger » Mon Apr 26, 2010 11:55 am

Thank in advance
Can anyone help me, this is the function in "jScript" but I get error " expected ';' ".
I have tried the possible options of punctuation with ";"
function msg()
{
return "Hello World!" ;
} ;
publication.nbSetVar "[%1]", msg() ;
-----------------------------------------------------

[%1] is a "variable" , but also functions as texto

From
COSTA RICA
PURA VIDA
User avatar
virger
 
Posts: 524
Joined: Mon Sep 18, 2006 12:21 pm
Location: Costa Rica, America Central

Postby Gaev » Mon Apr 26, 2010 3:09 pm

virger:

Looks like the method publication.nbSetVar does not work with NeoBook Functions of the type jscript ... I tried various combinations of syntax ... just trying to populate a NeoBook Variable with a simple text like "abcd" ... kept giving the same error message.

However, if you define your NeoBook Function as of type vbscript ... and code this ...
Code: Select all
Function msg()
msg = "Hello World!"
End Function

publication.nbSetVar "[%1]", msg()
... it seems to work.

Perhaps Dave can provide example for populating NeoBook Variables from jscript Variables
User avatar
Gaev
 
Posts: 3738
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Ndzn » Mon Apr 26, 2010 6:53 pm

Something like this might be what you're looking for?

Code: Select all
window.external.nbSetVar( '[MyNeoBookVar]', JScriptVar );" "JScript"


Or some variation of it...?
User avatar
Ndzn
 
Posts: 134
Joined: Sun Sep 20, 2009 8:37 am

Postby Neosoft Support » Tue Apr 27, 2010 10:25 am

This works for me:

Code: Select all
nbSetvar( '[%1]', 'Hello World!' );
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5605
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Postby Gaev » Tue Apr 27, 2010 11:03 am

nbSetvar( '[%1]', 'Hello World!' );

Yes that works ... looks like the prefix of publication. is only for scripts written for vbscript type functions ... not sure if this is mentioned in any of the Help doucumentation.
User avatar
Gaev
 
Posts: 3738
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Ndzn » Tue Apr 27, 2010 2:38 pm

Gaev wrote: ... not sure if this is mentioned in any of the Help doucumentation.


From the NeoBook Help file...


nbSetVar

Purpose:
This method assigns a string value to a NeoBook variable.

Syntax:
window.external.nbSetVar( variable name, value )

variable name

The name of a NeoBook variable. The variable name should be surrounded by square brackets.

value

The value to assign to the variable. Must be of type string.

Example:
The following HTML JScript copies the contents of two Text Boxes called "FirstName" and "LastName" to the NeoBook variables [FirstName] and [LastName]:


<script language="JScript">
function SetVars() {
window.external.nbSetVar( '[FirstName]', mainform.FirstName.value );
window.external.nbSetVar( '[LastName]', mainform.LastName.value );
}
</script>

User avatar
Ndzn
 
Posts: 134
Joined: Sun Sep 20, 2009 8:37 am

Postby Gaev » Tue Apr 27, 2010 3:13 pm

Ndzn:

Yes, I had seen that ... but it is in the Help section called Passing Information Between the Browser and NeoBook ... i.e. in relation to Javascript you place inside an HTML document that is loaded within a Browser Object ... and the example refers to ...
Code: Select all
window.external.nbSetVar( '[FirstName]', mainform.FirstName.value );
... I was refering to the section called Function Library where there is an example for Functions scripted in vbscript but none for those scripted in javascript or jscript ... which the context of the initial enquiry by virger.
User avatar
Gaev
 
Posts: 3738
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 1 guest