Resolving APL Faceplate VBScript Error (Variable Is Undefined - APL_GetIndexForIntlkQualityCode) in PCS 7

Resolving APL Faceplate VBScript Error (Variable Is Undefined - APL_GetIndexForIntlkQualityCode) in PCS 7

When opening an APL faceplate (such as @PG_OpDi01_STANDARD.pdl) fails and generates the APDiag error 'Variable is undefined: APL_GetIndexForIntlkQualityCode' inside function csoQCInterlock_Index_Trigger, the root cause is a missing or desynchronized global VBScript module file (APL_VBScripts.bmo) in the local WinCC project. This function calculates quality code status indices for interlock icons. This error occurs on simulation or secondary PCs when the WinCC project was copied without compiling the global script header, or when the APL library was not installed. To resolve this error, copy APL_VBScripts.bmo into the project's ScriptLib directory, open the WinCC Global Script editor to save and regenerate script headers, and restart WinCC Runtime.

Table of Contents

Executive Summary

In SIMATIC PCS 7 process plants utilizing the Advanced Process Library (APL), opening a technological faceplate—such as the digital operation block OpDi01 or standard valve/motor faceplates—triggers automated VBScript and C-action routines to evaluate interlocking conditions, operator permissions, and signal quality codes. On simulation workstations, engineering laptops, or newly cloned OS projects, engineers frequently discover that clicking a block icon fails to display faceplate interlock graphics, or throws VBScript runtime errors recorded in apdiag.exe:

Application: PDLRT
Picture: @PG_OpDi01_STANDARD.pdl_Triggers
Function: Function csoQCInterlock_Index_Trigger(ByVal Item)
Line: 14
Error: Variable is undefined: 'APL_GetIndexForIntlkQualityCode'

Crucially, the exact same project often operates without error on the production online server. This technical guide explains the role of global binary script modules (*.bmo), identifies why simulation PCs drop script headers, and details the recovery steps.

APL Faceplate Script Architecture: The Role of APL_VBScripts.bmo

The PCS 7 Advanced Process Library optimizes faceplate execution speed by consolidating common VBScript helper routines into compiled binary modules:

  • Compiled Binary Module (*.bmo): Instead of parsing raw text scripts on every faceplate click, APL precompiles functions into binary script libraries, primarily APL_VBScripts.bmo.
  • Global Function Export: APL_VBScripts.bmo exports global helper functions such as APL_GetIndexForIntlkQualityCode, APL_OpenFaceplate, and APL_CheckPermission.
  • Project Repository Location: In every WinCC OS project, this file must reside inside the project directory: <Project_Path>\ScriptLib\APL_VBScripts.bmo.

Why apdiag.exe Reports 'Variable is Undefined: APL_GetIndexForIntlkQualityCode'

VBScript runtime error 'Variable is undefined' occurs during function evaluation:

  1. Trigger Invocation: When @PG_OpDi01_STANDARD.pdl opens, object csoQCInterlock triggers function csoQCInterlock_Index_Trigger to evaluate the quality code of the interlock signal.
  2. Missing Function Reference: Line 14 calls APL_GetIndexForIntlkQualityCode(Item).
  3. Execution Failure: Because VBScript is an interpreted language, if the global module exporting this function was not loaded into the PDLRT process memory at runtime activation, VBScript assumes APL_GetIndexForIntlkQualityCode is an uninitialized local variable, halting execution with the undefined variable error.

The csoQCInterlock Dynamic Quality Code Evaluation Function

The csoQCInterlock object is a standardized graphical element embedded in APL faceplates:

  • Function: Visually displays signal quality codes for interlock conditions (e.g. Good = 16#80, Bad = 16#00, Simulated = 16#60).
  • Index Translation: APL_GetIndexForIntlkQualityCode translates the raw 8-bit IEEE quality code into a graphic state index (1 to 8) that selects the appropriate status icon.
  • When this function fails, the interlock icon remains blank or shows a script error icon.

Why Simulation PCs Differ from Production Online Stations

A frequent puzzle is why the error occurs exclusively on simulation PCs while the production server works:

  • Missing Library Installation: Production servers had the complete PCS 7 APL Faceplate Library installed from official DVD media. Simulation laptops often have only bare WinCC and STEP 7 installed, lacking the underlying APL system installation.
  • Corrupted Script Header Index: When a project is copied across computers (e.g. via USB stick or ZIP archive), the local WinCC script header cache (*.h / ScriptLib registry) is not automatically rebuilt. The runtime engine does not register the .bmo file until the Global Script editor re-saves it.

Step-by-Step Procedure to Restore Missing APL Global Scripts

To resolve the VBScript error and restore APL faceplates on simulation PCs:

  1. Verify File Existence:
    * On the simulation PC, open Windows Explorer and navigate to <Project_Folder>\ScriptLib\.
    * Confirm whether APL_VBScripts.bmo exists.
    * If missing, copy APL_VBScripts.bmo from the production server (located in <Production_Project>\ScriptLib\ or C:\Program Files (x86)\Siemens\WinCC\aplib\).
  2. Re-save in Global Script Editor:
    * Open the project in WinCC Explorer.
    * Open Global Script -> VBS-Editor.
    * In the VBS-Editor, verify that APL_VBScripts.bmo appears in the project library tree.
    * Select File -> Save All to recompile script headers and rebuild the internal index.
  3. Run OS Project Editor:
    * In WinCC Explorer, double-click OS Project Editor and click OK.
    * This ensures all required APL system PDLs and script triggers are synchronized.
  4. Restart WinCC Runtime: Deactivate WinCC Runtime, wait 10 seconds, and reactivate runtime.

APL Faceplate Script Diagnostic and Troubleshooting Matrix

The following table provides diagnosis and remediation for APL faceplate scripting faults:

APDiag Error MessageSubsystem / FunctionRoot CauseCorrective Engineering ActionVariable is undefined: APL_GetIndexForIntlkQualityCodeVBScript / csoQCInterlockAPL_VBScripts.bmo missing or uncompiledCopy BMO file to ScriptLib; re-save in VBS EditorPicture not found: @PG_*.pdlGraphics Runtime (PDLRT)Faceplate PDL missing in GraCSRun OS Project Editor in WinCC ExplorerCannot open script moduleScript EngineCorrupt script cache after project copyDelete temporary files in ScriptLib; save all in VBS editorQuality code display shows '?'APL Signal RoutingInterlock signal quality code evaluates to BadInspect field transmitter and CFC interlock connectionsPermission denied in faceplate scriptWinCC User RightsOperator lacks Authorization 5/6Check user authorizations in User Administrator

Verification

Confirm that APL faceplate VBScript execution is healthy:

  1. APDiag Real-Time Audit: Open apdiag.exe from WinCC\uTools, open the Output Window, and click the OpDi01 block icon.
  2. Verify Zero Script Errors: Confirm that the APDiag output window displays zero runtime error lines.
  3. Faceplate Display Check: Verify that @PG_OpDi01_STANDARD.pdl opens instantly, the interlock icon displays valid status (green/yellow/gray), and quality code indicators evaluate accurately.
  4. Simulation Test Mode: In S7-PLCSIM, toggle the interlock permissive bit. Confirm that the faceplate interlock icon updates dynamically.

Best Practices for Synchronizing WinCC Script Libraries across Workstations

When moving projects between simulation laptops and plant servers:

  • Install Full PCS 7 Library Set: Always install the complete PCS 7 Advanced Process Library software package on simulation PCs to ensure all global BMO and PDL templates exist in system paths.
  • Use Project Duplicator: When copying projects, utilize the official WinCC Project Duplicator tool rather than raw Windows copy, ensuring that all database and script library handles are preserved.
  • Audit ScriptLib Directory: Verify that the ScriptLib folder is included in all version archives.

Limitations and Operational Precautions

Never attempt to edit compiled .bmo files with standard text editors. Modifying binary BMO files corrupts internal compilation signatures, crashing the WinCC VBScript runtime engine (pdlrt.exe).

Always verify faceplate script functionality in an offline simulation environment (S7-PLCSIM) prior to deploying modified graphics to live plant operator stations.

Engineer FAQ

What is a .bmo file in WinCC?

A .bmo file is a binary compiled VBScript module containing precompiled functions optimized for high-speed execution in WinCC graphics.

Can I extract the source code from APL_VBScripts.bmo?

No. Siemens compiles APL_VBScripts.bmo for performance and intellectual property protection; source functions cannot be decompiled.

Why did replacing the PDL file not fix the error?

Because the error is not inside the PDL graphic itself; it is inside the global script module (APL_VBScripts.bmo) that the PDL calls.

Does S7-PLCSIM cause this scripting error?

No. S7-PLCSIM emulates only controller CPU execution; WinCC VBScript errors are strictly confined to the local WinCC runtime PC.

Technical References

Related Articles

Related Tags

8 respuestas