ActiveReports6 Send comments on this topic.
AddCode Method
See Also  Example
ActiveReports6 Assembly > DataDynamics.ActiveReports Namespace > ActiveReport Class : AddCode Method

script
Script code written in the specified report scripting language.
Adds additional valid script code to the report's scripting context.  Using AddCode allows complete functions to be added to a report's script at run time.  The added functions can be called from the report events in script.

Syntax

Visual Basic (Declaration) 
Public Sub AddCode( _
   ByVal script As String _
) 
C# 
public void AddCode( 
   string script
)

Parameters

script
Script code written in the specified report scripting language.

Example

C#Copy Code
public string addThisCode()
{
     
string sCode = "public string ShowACMessage()"{return \"my Added Code\";}";
     
return sCode;
}

private void rptAddCode_ReportStart(object sender, System.EventArgs eArgs)
{
     
this.AddCode(addThisCode());
}  
Visual BasicCopy Code
Public Function addThisCode() As String
      Dim sCode As String = "Public Function ShowACMessage() As String" _
        + Environment.NewLine + "ShowACMessage = ""my Added Code""" _
        + Environment.NewLine + "End Function"
        addThisCode = sCode
End Function

Private Sub rptAddCode_ReportStart(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.ReportStart
      Me.AddCode(addThisCode())
End Sub


Remarks

This method is typically used when executing stand-alone reports that are not compiled into the application.  Injected code allows the report to access features such as custom calculation functions and data access modules in the calling application.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also