We are trying to create a template to generate dotNet 'xsd' files.
Neither of has used JScript before but we do write javascript classes and code for our ajax based webappliaction using 'prototype'.
Code syntax and structure based on http://msdn2.microsoft.com/en-us/library/667a3hk6(VS.80).aspx
The following code results in the following:
[Error] Microsoft JScript compilation error (10, 0) 1002: Syntax error
Stack Traceclass Param {
- Code: Select all
class Param {
// Private vars.
private var _dbType : String;
private var _direction : String;
private var _name : String;
private var _precision : Integer;
private var _providerType : String;
private var _scale : Integer;
private var _size : integer;
private var _sourceColumn : String;
// Public Accessor methods.
public function get DbType() : String {
return this._dbType;
}
public function get Direction() : String {
return this._direction;
}
public function get Name() : String {
return this._name;
}
public function get Precision() : Integer {
return this._precision;
}
public function get ProviderType() : String {
return this._providerType;
}
public function get Scale() : Integer {
return this._scale;
}
public function get Size() : Integer {
return this._size;
}
public function get SourceColumn() : String {
return this._sourceColumn;
}
// Constructor.
function Param(item) {
this._name = item.Name;
this._precision = item.NumericPrecision;
this._scale = param.NumericScale;
this.DbType = item.TypeName;
this.Direction = item.Direction;
this.ProviderType = item.TypeName;
SetSize(item.TypeName, item.NumericPrecision, item.CharacterMaxLength);
SetSourceColumn(item.Direction, item.Name);
}
// Internal Setter methods.
protected function set DbType(type : String) {
if (type == \"\")
throw \"You can't have a blank DbType!\";
switch(type) {
case \"float\":
this._dbType = \"Double\";
break;
case \"int\":
this._dbType = \"Int32\";
break;
case \"money\":
this._dbType = \"Currency\";
break;
case \"nvarchar\":
this._dbType = \"String\";
break;
case \"real\":
this._dbType = \"Single\";
break;
case \"timestamp\":
this._dbType = \"Binary\";
break;
default:
this._dbType = type;
}
}
protected function set Direction(dir : String) {
this._direction = iif(dir = \"RETURN\", \"ReturnValue\", \"Input\");
}
protected function set ProviderType(type : String) {
this._providerType = PCase(type);
}
protected function SetSize(type : String, precision : Integer, maxLength: Integer) {
switch(type) {
case \"int\":
case \"real\":
this._size = 4;
break;
case \"float\":
case \"money\":
case \"timestamp\":
this._size = 8;
break;
case \"nvarchar\":
this._size = maxLength;
default:
this._size = 4;
}
}
protected function SetSourceColumn(dir : String, name : String) {
this._sourceColumn = \"\";
if (dir != \"RETURN\") {
this._sourceColumn = \" SourceColumn=\\\"\" + name.replace(/@/g, \"\") + \"\\\"\";
}
}
}
