An error occurred in script '/home/yhr1ef23xez5/public_html/web2/app/model/bannerhit.php' on line 17:
Undefined index: HTTP_REFERER

    [type] => solution
    [name] => bp-Implements

WinWrap® | Extend the WinWrap® Basic Scripting Language with Implements
logo WinWrap®

Extend the WinWrap® Basic Scripting Language with Implements

WinWrap® Basic is an embedded macro language component available for .NET and COM 32/64 bit Windows applications. The WinWrap® Basic Component is an alternative to Visual Basic for Applications (VBA), ActiveX (e.g. VBScript, JScript, PerlScript, Rexx-based WSH engines and others), and VSTA for this purpose. The WinWrap® Basic Component is compatible with VBA, Sax Basic, VB.NET and Visual Basic 6.0 style scripts.

Create a Scriptable Application using Implements

  • Call interface methods using normal .NET syntax
  • Implement interface methods with script code
  • Enforce script interface during parsing
  • Automatic interface prototypes generated by the IDE

Scriptable Architecture with Implements

Using Implements to Extend the WinWrap Basic Scripting Language

You or your customer can write script code that executes when method calls are made by the application. Scripts are validated for syntactic correctness and all the application has to do is call an interface method. This is a great way to script, with the application calling your script code at the appropriate time.

Create an Instance of Script Class

The application parses the script (ModuleInstance) and creates an instance (CreateInstance), gets an interface reference (Cast) and calls the script method.

try { using (var module = basicNoUIObj.ModuleInstance(ScriptPath(Script), false)) { if (module == null) { // script parsing error LogError(basicNoUIObj.Error); } else { using (var instance = basicNoUIObj.CreateInstance(ScriptPath(Script) + ">IncidentAction")) { // Execute script code via an interface IIncidentAction action = instance.Cast<iincidentaction>(); TheIncident.Start(action, this.Text); } } catch (WinWrap.Basic.TerminatedException) { // script execution terminated, ignore error } catch (Exception ex) { // script caused an exception basicNoUIObj.ReportError(ex); } } } }

Call Script Methods using Normal .NET Syntax

The expression action.Started(this) calls the script code.

[Scriptable] public class Incident { ... public void Start(IIncidentAction action, string firedby) { FiredBy = firedby; action.Started(this); } ... }

Interface Provides the Bridge Between the Application and the Script

The application defines the IIncidentAction interface and its methods.

[Scriptable] public interface IIncidentAction { [Scriptable] void Started(Incident incident); }

Implement Custom Behavior as Script Methods

A script class module implements the IIncidentAction interface and its methods.

'#Language "WWB.NET" Public Class IncidentAction Implements IIncidentAction Public Sub Started(ByVal incident As Incident) Implements IIncidentAction.Started incident.FilledInBy = ScriptName() incident.LogMe() End Sub End Class

The WinWrap® Basic IDE facilitates writing the methods for an implemented interface:

Implements before pressing Enter

Pressing "Enter" at the end of the Implements line writes all the needed interface prototypes:

Implements after pressing Enter

Conclusion: Scripts are Clear, Concise and Strongly Typed

WinWrap® Basic provides a comprehensive solution to adding scripting to your application. Calling script code with an interface and Implements is an alternative to calling script code through events. Both this solution and the Extend the WinWrap® Basic Scripting Language solution present roughly equivalent techniques for calling script code. It may be a matter of style which technique you use.

See WinWrap Examples for instructions on how to download and run "Example 5 - Implements".

Copyright Polar Engineering, Inc.