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
- APL Faceplate Script Architecture: The Role of APL_VBScripts.bmo
- Why apdiag.exe Reports 'Variable is Undefined: APL_GetIndexForIntlkQualityCode'
- The csoQCInterlock Dynamic Quality Code Evaluation Function
- Why Simulation PCs Differ from Production Online Stations
- Step-by-Step Procedure to Restore Missing APL Global Scripts
- APL Faceplate Script Diagnostic and Troubleshooting Matrix
- Verification
- Best Practices for Synchronizing WinCC Script Libraries across Workstations
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
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, primarilyAPL_VBScripts.bmo. - Global Function Export:
APL_VBScripts.bmoexports global helper functions such asAPL_GetIndexForIntlkQualityCode,APL_OpenFaceplate, andAPL_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:
- Trigger Invocation: When
@PG_OpDi01_STANDARD.pdlopens, objectcsoQCInterlocktriggers functioncsoQCInterlock_Index_Triggerto evaluate the quality code of the interlock signal. - Missing Function Reference: Line 14 calls
APL_GetIndexForIntlkQualityCode(Item). - Execution Failure: Because VBScript is an interpreted language, if the global module exporting this function was not loaded into the
PDLRTprocess memory at runtime activation, VBScript assumesAPL_GetIndexForIntlkQualityCodeis 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_GetIndexForIntlkQualityCodetranslates 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/ScriptLibregistry) is not automatically rebuilt. The runtime engine does not register the.bmofile 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:
- Verify File Existence:
* On the simulation PC, open Windows Explorer and navigate to<Project_Folder>\ScriptLib\.
* Confirm whetherAPL_VBScripts.bmoexists.
* If missing, copyAPL_VBScripts.bmofrom the production server (located in<Production_Project>\ScriptLib\orC:\Program Files (x86)\Siemens\WinCC\aplib\). - Re-save in Global Script Editor:
* Open the project in WinCC Explorer.
* Open Global Script -> VBS-Editor.
* In the VBS-Editor, verify thatAPL_VBScripts.bmoappears in the project library tree.
* SelectFile -> Save Allto recompile script headers and rebuild the internal index. - 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. - 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:
Variable is undefined: APL_GetIndexForIntlkQualityCodecsoQCInterlockAPL_VBScripts.bmo missing or uncompiledScriptLib; re-save in VBS EditorPicture not found: @PG_*.pdlPDLRT)GraCSCannot open script moduleScriptLib; save all in VBS editorQuality code display shows '?'Permission denied in faceplate scriptVerification
Confirm that APL faceplate VBScript execution is healthy:
- APDiag Real-Time Audit: Open
apdiag.exefromWinCC\uTools, open the Output Window, and click theOpDi01block icon. - Verify Zero Script Errors: Confirm that the APDiag output window displays zero runtime error lines.
- Faceplate Display Check: Verify that
@PG_OpDi01_STANDARD.pdlopens instantly, the interlock icon displays valid status (green/yellow/gray), and quality code indicators evaluate accurately. - 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
ScriptLibfolder 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.