Search these areas:
Support Forums
Product Info

DataWeb: What's New
Creating an Application
The DataWeb Designer
Application Management
Data Tables
Data Tables
Data Analysis
Object Model
JavaScript Objects
General Scripting Objects
-Classes Object
-Email Object
-Request Object
-Response Object
-Script Object
Data Access Objects
File Access Objects
Http Client Objects
Security and Membership Objects
Document Object Model (DOM)
Error Descriptions
Object Model Extensions
Full-Text Search
Domain and Email Hosting
HotBlock Modules
Account Management
New Responsive UI Module

DataWeb Help
Support Forums
Script Library
Knowledge Base

Home > Support

DataWeb User's Guide

Classes Object
The Classes object represents the set of DataWeb Script classes available in the web. The Classes object is a prototype object and cannot be instantiated.

Prototype Methods

import(classpath) Imports the public members of the class specified by the classpath argument. Returns a reference to the specified class. Returns null if classpath does not exist in the web or if the class cannot be imported. This parameter expects a string path as it value, so values for this parameter must begin with a '/'.

The Classes object has a single method, the import() method. The import() method makes the public members of a class available to script in another class. In this way you can organize reusable code into classes rather than duplicating it.

The import() method returns a reference to the specified class. You can assign this reference to a variable and use it as an object in your script, as shown in the following example. The function defined below, CalcAvePrice(), imports the class from the web root. It then calls a public function from that class named average(), which finds the average of a set of numbers stored in an array.
webcall function CalcAvgPrice()
  var c = classes.import("/");

  //Create a resultset on the Products table.
  var r = new resultset("Products",
    "UnitPrice", "*");

  //Move through resultset and add each value
  //to an array.
  var arr = new Array();

  return c.average(arr);
A custom script class such as functions as a prototype object in script. That is, only a single instance of the class ever exists in memory, no matter how many times you import the class. In the following code fragment, both c1 and c2 refer to the same object:
var c1 = classes.import("/");
var c2 = classes.import("/");
Because these two variables refer to the same object in memory, any public variables declared in the class will always have the same value, wherever they are used. For example, in the following code fragment, the value property for both objects will be 3.1415:
c2.value = 3.1415;

Related Topics

Calling Functions

Affiliate | Partner | Terms of Use | Privacy Policy | Contact Us | Pricing | Bring DataWeb In-House    
Email Us