教导
该脚本从一个内部变量�ariableFlag?#35835;入一个结构名并给它加上一个事例名。然后该变量的值从一个最终变量读出。
下面的脚本由鼠标在一个按钮上单击触发。
Program listing:
=============
#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
char* InstanceNameA;
DWORD VarContA;
// Presetting of internal variable with structure name,
// this can also have happened at a different point
SetTagChar("VariableFlag","TriangleEnvelopeCurve");
// Reservation of memory
InstanceNameA = SysMalloc(200);
// Read in structure name
strcpy(InstanceNameA,GetTagChar("VariableFlag");
// Test output in diagnostic window
printf("Contents Pointer Position 1: %srn", InstanceNameA);
// Add instance name to variable name
strcat(InstanceNameA,".Triangle_1");
// Test output in diagnostic window
printf("Contents Pointer Position 2: %srn", InstanceNameA);
// Read in variable value
VarInhA = GetTagWord(InstanceNameA);
// Test output in diagnostic window
printf("VariableContents: %drn", VarContA);
// Release of reserved memory
SysFree(InstanceNameA);
}
原创文章,作者:ximenziask,如若转载,请注明出处:https://www.zhaoplc.com/plc332186.html