Resolving WinCC V7 Function Trend DeleteData Script Errors
The Function Trend Control in Siemens WinCC V7 (and V7.1 specifically) accepts VBScript calls to clear and repopulate its trend buffer during runtime. Engineers commonly attempt to set the DeleteData property equal to True to clear the buffer, but the assignment silently fails and produces no trend update. The correct API path uses the RemoveData() method followed by InsertData X, Y, both exposed on the trend object returned by GetTrend(...). This article documents the symptom, the underlying cause, the verified workaround, and the migration path to the equivalent controls in WinCC Unified / TIA Portal V20.
ScreenItems(...).GetTrend(...). For TIA Portal / WinCC Unified projects, jump to the Migration to WinCC Unified section.Problem Description
When a runtime script attempts to clear and re-insert points into a Function Trend Control using the DeleteData property, the buffer is not cleared and the new dataset is either concatenated with stale data or rejected entirely. The original (failing) pattern looks like this:
Dim objTrendControl
Dim objTrend
Set objTrendControl = ScreenItems("Control1")
Set objTrend = objTrendControl.GetTrend("Trend 1")
' The following line is a no-op in WinCC V7.1:
objTrend.DeleteData = True
Expected behavior: the Function Trend Control's DataBuffer is emptied so that the next InsertData call repaints the trend from a clean slate. Actual behavior: no visible update occurs; diagnostic HMIRuntime.Trace output around the surrounding logic prints normally, so the script appears to succeed even though the display does not refresh.
Variants of the same defect seen in the field:
- Calling
objTrend.DeleteDataas a method with parentheses (objTrend.DeleteData()) raises error Wrong number of arguments or invalid property assignment (WinCC VBScript error 450 / 800A01B5). - Assigning
objTrend.DeleteData = Truereturns the value of the read-only property back to the engine; no exception is raised, the buffer is left untouched. - Calling
objTrend.InsertData X, Yafter the failedDeleteDatacall produces an overflow when the buffer reaches its configured size and the trend visibly clips.
Root Cause Analysis
The Function Trend Control in WinCC V7 is a hybrid COM/ActiveX object whose data buffer can be populated in two mutually exclusive ways:
- Tag-driven mode — a tag is bound as the Provider; the control samples it on its configured cycle.
-
Script-driven mode — no Provider is configured; the engineer pushes data points through the automation interface using
InsertData.
When the control is in tag-driven mode, almost every write-oriented method on the returned objTrend object is rejected at runtime with the diagnostic message:
An error occured in the Script
Application: CCTrendingCtrl
Picture: NewPdl2.pdl_Events
Function: Sub Button7_OnClick(ByVal Item)
Line: 22
Error: Can not execute method if a Provider is configured
This message is raised by the control's internal guard against double-population. Even in script-driven mode, however, the DeleteData property is not a writeable property; the documentation exposes it as a Boolean that reflects the buffer-cleared state, not a setter. Therefore, assigning True to it is accepted by the VBScript engine (because the property exists), but the underlying COM object ignores the write because the setter is not implemented on this interface.
Siemens support confirmed the correct path is the RemoveData() method — a separate, properly-implemented method on the same automation object. Calling RemoveData() empties the DataBuffer synchronously and allows the immediate InsertData call to repopulate it from index 0.
Properties vs. Methods: Interface Audit
The mismatch is best explained with a complete interface table. The following table summarizes the public members of the objTrend object returned by GetTrend("<Trend Name>") in WinCC V7.1 (valid for V7.0 SP3 through V7.5 unless otherwise noted):
| Member | Type | Read | Write | Effect |
|---|---|---|---|---|
InsertData X(), Y() |
Method | — | — | Appends X/Y pairs to the buffer (script-driven mode only) |
RemoveData() |
Method | — | — | Empties the entire buffer; resets index to 0 (script-driven mode only) |
DeleteData |
Property | Yes | No | Read-only status flag, not a setter |
TagName |
Property | Yes | Yes | Returns / sets the bound tag name (Property mode) |
Provider |
Property | Yes | Yes | Returns / sets the configured provider (Tag / OnlineTrendControl) |
Count |
Property | Yes | No | Number of points currently in the buffer |
TimeAxis |
Property | Yes | No | Time axis configuration object |
ValueAxis |
Property | Yes | No | Value axis configuration object |
DeleteData appears writable in IntelliSense: WinCC's VBScript editor parses the type library and exposes DeleteData with both Get and Let accessors. The Let accessor is a stub that returns the assigned value to the engine without performing any work. Always verify method/property semantics against the official WinCC V7 documentation set, not the IntelliSense tooltip.Verified Solution: RemoveData() + InsertData
Siemens support provided the following working pattern, validated on WinCC V7.1 with Function Trend Control build 7.1.0.0 and runtime build 7.1.0.x:
Sub OnClick(Byval Item)
Dim Index
Dim X(15)
Dim Y(15)
Dim objTrendControl
Dim objTrend
Set objTrendControl = ScreenItems("Control1")
Set objTrend = objTrendControl.GetTrend("Trend 1")
' 1. Build the arrays to push into the buffer
For Index = 0 To 15
X(Index) = Index * 10
Y(Index) = 10 + Index
HMIRuntime.Trace CStr(X(Index)) & " - " & CStr(Y(Index)) & vbCrLf
Next
' 2. Clear the existing buffer (script-driven mode only)
objTrend.RemoveData()
' 3. Insert the new dataset from index 0
objTrend.InsertData X, Y
End Sub
This script can be attached to any event — a button click, a tag-change event on a "Refresh" tag, or a scheduler-driven cyclic event. The OnClick handler signature Sub OnClick(Byval Item) is the canonical WinCC V7 VBScript button event signature; for tag-change events, use Sub OnChange(ByVal Item, ByVal Qualifier).
Working in Provider-Configured Mode
If the Function Trend Control has a Provider configured (the most common deployment for process-data trending), the RemoveData() / InsertData approach is blocked by the guard message. Two legitimate solutions exist:
Option A — Remove the Provider, drive the control by script
In Graphics Designer, open the Function Trend Control's properties, navigate to Trend > Provider, and clear the Tag Name / OnlineTrendControl field. Save, regenerate the runtime, and the script-driven pattern works. Reconfigure the time-axis range to match the X-axis range of your pushed data (X = 0 to 150 in the example above).
Option B — Use the configured provider; do not push data by script
Switch the OnClick handler to refresh the source data the provider is sampling. For tag-driven Function Trend, the provider is typically a process tag; changing that tag's value updates the trend on the next sampling cycle. Use HMIRuntime.Tags("MyTag").Write value rather than InsertData.
RemoveData() / InsertData regardless of how the property dialog looks. The decision must be made at design time.Diagnostic & Error Catalog
| Symptom | Root Cause | Resolution |
|---|---|---|
No error, buffer unchanged after objTrend.DeleteData = True
|
DeleteData is read-only; assignment is silently dropped |
Use objTrend.RemoveData()
|
Error 800A01B5 / "Wrong number of arguments or invalid property assignment" on objTrend.DeleteData()
|
Treating read-only property as a method | Switch to RemoveData()
|
Error "Can not execute method if a Provider is configured" on RemoveData() or InsertData
|
Provider is configured; control is in tag-driven mode | Remove the provider at design time, or drive data via the provider tag |
| Trend clips at the configured buffer size |
InsertData appended without RemoveData(); old points were not cleared |
Always call RemoveData() immediately before InsertData
|
| X-axis label shows wrong time, Y-axis is correct | X values are absolute timestamps but axis is in relative mode, or vice versa | Match X values to the trend's time-axis configuration (e.g. seconds-since-picture-open) |
Trend does not repaint after InsertData
|
Redraw suppressed; or the call occurred during screen change | Force a refresh with objTrendControl.ReDraw = True, or call from a stable screen context |
Performance and Buffer Sizing
The Function Trend Control's buffer size is configured per-trend under Properties > Trend > BufferSize. The default is 600 points in WinCC V7.1. When pushing data through InsertData, observe these limits:
- Maximum points per
InsertDatacall: 1000 (WinCC V7.1, V7.2); 10,000 (V7.3 and later when ExtendedBuffer is enabled). - Array dimensions: VBScript's
Dim X(n)allocates indices 0..n, so the array length is n+1. - Update frequency: avoid calling
RemoveData() / InsertDatafaster than 100 ms; the control's redraw engine will drop frames and the GDI surface can leak. Use a 250–500 ms cycle for human-readable trends. - CPU cost: each
RemoveData() + InsertDatacycle forces a full buffer re-rasterization. On Windows 7 / Windows Server 2008 R2 panels (typical V7.1 target), keep the point count below 300 per cycle to hold CPU below 5% per panel.
Migration to WinCC Unified (TIA Portal V20)
WinCC V7 is in long-term maintenance; new deployments should use WinCC Unified in TIA Portal V20 or later. The equivalent controls are documented at:
-
Function trend control (RT Unified) - WinCC Unified — represents the values of a tag as a function of another tag. The Unified equivalent retains the V7 X = f(Y) model but replaces the COM automation interface with a JavaScript API exposed on the screen object's
UIproperty. - Trend control (RT Unified) - WinCC Unified — displays tag values from the current process or from the log in the form of trends as an autorepeat. This is the direct replacement for the OnlineTrendControl in WinCC V7.
API Translation: WinCC V7 VBScript → WinCC Unified JavaScript
| Operation | WinCC V7 (VBScript) | WinCC Unified (JavaScript, TIA V20) |
|---|---|---|
| Acquire trend object | objTrend = objTrendControl.GetTrend("Trend 1") |
let trend = HMIRuntime.UI.Find("TrendControl1").TrendItems.GetItem("Trend 1"); |
| Clear buffer | objTrend.RemoveData() |
trend.ClearData(); (Unified trend item method) |
| Append X/Y pairs | objTrend.InsertData X, Y |
trend.InsertData(xArray, yArray); |
| Read point count | n = objTrend.Count |
let n = trend.Count; |
| Tag write | HMIRuntime.Tags("T").Write v |
Tags("T").Write(v); |
GetTrend / RemoveData / InsertData pattern, (1) re-create the screen in TIA Portal with the Unified Function Trend Control, (2) bind the X-source and Y-source tags in the trend configuration, (3) replace every VBScript handler with a Unified JavaScript function, (4) validate the buffer-cleared behavior on a Unified Runtime (PC or Unified Comfort Panel) before commissioning.Verification Procedure
- Compile check: In Graphics Designer, save the picture and verify the script compiles cleanly. WinCC V7 reports syntax errors through the Output window of the script editor.
- Static analysis: Confirm that the Function Trend Control in the picture has no Provider configured (right-click → Properties → Trend → Provider → empty).
- Runtime smoke test: Activate the project, open the picture, click the trigger button. The trend must repaint from index 0 with the new X/Y pairs.
-
Buffer state inspection: Add a temporary diagnostic line
HMIRuntime.Trace "Count=" & objTrend.Countimmediately afterInsertData. The expected value matches the array length (16 for the example, i.e. 0..15). -
Idempotency test: Click the button 10 times in 1 second. Each click must produce a complete, identical repaint. If the count grows past the expected value, the
RemoveData()call was missed or rejected. - Long-run soak: Drive the button by a 1-second timer for 1 hour. Monitor panel CPU and GDI handles (Process Explorer → add GDI Objects column). Both should remain stable.
Field-Notes and Best Practices
- Always pair
RemoveData()withInsertDatain the same atomic event. Splitting them across events leaves the buffer in an undefined state if the second event is missed. - Cap the array length to match the configured BufferSize. Truncating a 1000-point push to fit a 600-point buffer clips the trend at the upper index.
- Use the ReDraw property of the control (not the trend) to suppress flicker during bulk updates, then restore it after
InsertData. - Never reference
objTrendfrom a picture's Open event; the control's automation object is not yet fully instantiated. UseOnClick,OnChange, or a delayed script triggered by a 1-shot timer. - In WinCC V7.3 and later, prefer the OnlineTrendControl for tag-driven trends and reserve the FunctionTrendControl for script-driven Y = f(X) use cases. The two controls share a similar COM interface but the FunctionTrendControl is the only one with the
InsertDatamethod. - On TIA Portal V20 / WinCC Unified, do not recreate the V7 pattern verbatim. The Unified Function Trend Control exposes a SourceTagX and SourceTagY configuration that replaces the script-driven push model entirely; reserve scripting for non-X/Y trend shapes only.
Related Controls in WinCC V7
| Control | Typical Use | Data Interface |
|---|---|---|
| OnlineTrendControl | Real-time process values over time | Tag(s) configured as data source; sampling cycle |
| FunctionTrendControl | Y = f(X) plots, e.g. valve curve, pump curve |
InsertData X(), Y() from VBScript, or a single tag for X |
| OnlineTableControl | Tabular trend view | Tag(s) configured as data source |
| FunctionTableControl | Tabular Y = f(X) view | Mirrors FunctionTrendControl's data interface |
Frequently Asked Questions
Why does setting objTrend.DeleteData = True not clear the buffer in WinCC V7.1?
Because DeleteData is a read-only Boolean property on the trend object — it is a status flag, not a setter. The assignment is silently accepted by the VBScript engine and discarded by the COM object. Use the RemoveData() method to actually empty the buffer.
What is the difference between RemoveData() and InsertData in the Function Trend Control?
RemoveData() synchronously empties the trend's data buffer and resets the insert index to 0. InsertData X, Y appends the supplied X/Y arrays to the buffer (or overwrites from index 0 if called immediately after RemoveData()). The two methods are designed to be paired: clear, then push.
Why do I get the error "Can not execute method if a Provider is configured"?
The Function Trend Control rejects RemoveData() and InsertData when a Provider is configured in the trend's properties, because the control cannot simultaneously source data from a tag/OnlineTrendControl and from a script. Either remove the provider at design time, or drive the data through the configured provider tag and do not call the script-driven methods.
Does the same DeleteData problem exist in WinCC Unified (TIA Portal V20)?
No. The Unified Function Trend Control exposes a different automation interface based on JavaScript and the HMIRuntime.UI model. The Unified trend items use ClearData() (or rely on the configured SourceTagX / SourceTagY) and do not expose a DeleteData property. See the Function trend control (RT Unified) manual for the V20 reference.
What is the maximum number of points I can push in a single InsertData call in WinCC V7.1?
1,000 points per call on WinCC V7.0 SP3 through V7.2, raised to 10,000 points per call on V7.3 and later when the ExtendedBuffer property is enabled. The control's overall buffer is capped at the configured BufferSize (default 600).