Forum Discussion
russleikis
15 years agoContributor
Do you really need to use Script Extension to accomplish what you are doing? You can create custom classes and prototypes inside the TC jScript engine.
Since jScript had no equivalent to an Enum, I found this workaround to keep these hard-coded strings limited to a single location in the code base. (It's a little messy but saves a ton of work and human error.) This Enum class is located in the same API script unit that it's related function is in so that they are referenced together.
I apologize for the inclusion of AUT specific code, but I didn't want bother renaming anything to make it generic. I do have an alternate way to create the same Enum's but it clutters the Code Completion and requires about three times as much code in the class. I know this isn't directly related to what you are doing, but I'm just saying that it works well inside the TC engine itself.
/// <summary>
/// Enum ETabType
///
/// Enum parameters for selecting a Ribbon Tab.
/// \note Usage: To construct the enum and set the desired value: i.e. SelectTab((new ETabType()).Source())
/// \note Usage: Evaluate obj._currentState to get current state against available enum values.
/// </summary>
/// <returns>A ETabType Enum object</returns>
function ETabType ()
{
this.Source_state = "source"
this.BeamDisplay_state = "beam display"
this.Capture_state = "capture"
this.Computations_state = "computations"
this.Aperture_state = "aperture"
this.BeamProfile_state = "beam profile"
this.Charts_state = "charts"
this.Logging_state = "logging"
this.Reports_state = "reports"
this.ExtraComputations_state = "extracomputations"
}
ETabType._currentState = null
ETabType.prototype.Source = function() {this._currentState = this.Source_state; return this;}
ETabType.prototype.BeamDisplay = function() {this._currentState = this.BeamDisplay_state; return this;}
ETabType.prototype.Capture = function() {this._currentState = this.Capture_state; return this;}
ETabType.prototype.Computations = function() {this._currentState = this.Computations_state; return this;}
ETabType.prototype.Aperture = function() {this._currentState = this.Aperture_state; return this;}
ETabType.prototype.BeamProfile = function() {this._currentState = this.BeamProfile_state; return this;}
ETabType.prototype.Charts = function() {this._currentState = this.Charts_state; return this;}
ETabType.prototype.Logging = function() {this._currentState = this.Logging_state; return this;}
ETabType.prototype.Reports = function() {this._currentState = this.Reports_state; return this;}
ETabType.prototype.ExtraComputations = function() {this._currentState = this.ExtraComputations_state; return this;}
Since jScript had no equivalent to an Enum, I found this workaround to keep these hard-coded strings limited to a single location in the code base. (It's a little messy but saves a ton of work and human error.) This Enum class is located in the same API script unit that it's related function is in so that they are referenced together.
I apologize for the inclusion of AUT specific code, but I didn't want bother renaming anything to make it generic. I do have an alternate way to create the same Enum's but it clutters the Code Completion and requires about three times as much code in the class. I know this isn't directly related to what you are doing, but I'm just saying that it works well inside the TC engine itself.
/// <summary>
/// Enum ETabType
///
/// Enum parameters for selecting a Ribbon Tab.
/// \note Usage: To construct the enum and set the desired value: i.e. SelectTab((new ETabType()).Source())
/// \note Usage: Evaluate obj._currentState to get current state against available enum values.
/// </summary>
/// <returns>A ETabType Enum object</returns>
function ETabType ()
{
this.Source_state = "source"
this.BeamDisplay_state = "beam display"
this.Capture_state = "capture"
this.Computations_state = "computations"
this.Aperture_state = "aperture"
this.BeamProfile_state = "beam profile"
this.Charts_state = "charts"
this.Logging_state = "logging"
this.Reports_state = "reports"
this.ExtraComputations_state = "extracomputations"
}
ETabType._currentState = null
ETabType.prototype.Source = function() {this._currentState = this.Source_state; return this;}
ETabType.prototype.BeamDisplay = function() {this._currentState = this.BeamDisplay_state; return this;}
ETabType.prototype.Capture = function() {this._currentState = this.Capture_state; return this;}
ETabType.prototype.Computations = function() {this._currentState = this.Computations_state; return this;}
ETabType.prototype.Aperture = function() {this._currentState = this.Aperture_state; return this;}
ETabType.prototype.BeamProfile = function() {this._currentState = this.BeamProfile_state; return this;}
ETabType.prototype.Charts = function() {this._currentState = this.Charts_state; return this;}
ETabType.prototype.Logging = function() {this._currentState = this.Logging_state; return this;}
ETabType.prototype.Reports = function() {this._currentState = this.Reports_state; return this;}
ETabType.prototype.ExtraComputations = function() {this._currentState = this.ExtraComputations_state; return this;}
Related Content
- 10 years ago
- 11 years ago
Recent Discussions
- 17 hours ago
- 2 months ago