| View previous topic :: View next topic |
| Author |
Message |
ngcgba Junior

Joined: 07 Mar 2019 Posts: 11
|
Posted: 28/04/2019 13:03 Post subject: Help.its about mouse click script get tag name.Intouch 2017 |
|
|
Hi, I use Intouch 2017. I need a script to do this:I have more 200 tags in the screen.I want to have a General script for 200 tags mouse right click event.
But how to know which one tag was mouse right click?
For example , in VB, i can use ActiveControl.Name.
Thanks.
Last edited by ngcgba on 29/04/2019 10:34; edited 1 time in total |
|
| Back to top |
|
 |
abddeeg Junior

Joined: 28 Apr 2019 Posts: 2
|
Posted: 28/04/2019 16:38 Post subject: |
|
|
With the "GetLinkedVariable()" function you read the name of the tag that is linked to an object property. The tag name returned by the "GetLinkedVariable()" function is checked. Once the check has been completed successfully you can then further process the tag name in the application-specific subprogram according to your requirements, read and write WinCC tags, and set other object properties.
Example:
Example for reading the name of a tag that is linked to the object property "OutputValue" of an IO field.
| Code: |
{
char* pszVarName = NULL;
char szVarName[_MAX_PATH+1];
//
//Read tag name of a direct connection
//
pszVarName = GetLinkedVariable(lpszPictureName,lpszObjectName,"OutputValue");
//
//Check return value
//
if (strlen(pszVarName) <0>= sizeof (szVarName)){
printf("Error: the C tag occupies too little memory to be able to accept the complete tag name\r\n");
}
else{
strncpy(szVarName,pszVarName,sizeof (szVarName));
printf("Info: szVarName=\"%s\" value=%f\r\n", szVarName, value);
//============================================
//
//User-specific subprogram
//
//============================================
//At this point you can program your
//application-specific code
}
} |
Parameter of the function GetLinkedVariable:
lpszPictureName: Pointer to the active image
lpszObjectName: Pointer to the active object
"OutputValue": Name of the object property, to which the tag is linked.
Program flow:
The return value of the function GetLinkedVariable in pszVarName is stored intermediately.
As the function GetLinkedVariable does not return a NULL pointer, strlen is used to check if a value has been read.
If a valid value has been returned, the return value is copied into szVarName. There can be saved as a maximum _MAX_PATH characters.
Running userdefined code to process return value.
Notes on Triggering:
In process pictures you should avoid actions with cyclic triggers, because these might lead to a greater loading of the system. You should use variable triggers if possible.
When using variable triggers please make sure that when connecting the user object with the process variables the trigger for triggering the C action is also changed accordingly. |
|
| Back to top |
|
 |
abddeeg Junior

Joined: 28 Apr 2019 Posts: 2
|
Posted: 28/04/2019 16:45 Post subject: |
|
|
By changing a value of a tag (HMI_Tag_1), a script will be called and increment the value of a second tag (HMI_Tag_2).
WinCC could call scripts triggered by time or by Tag change. It makes possible, for example, to call a script (indirectly) by a PLC command.
Configuration main steps:
Create a project.
Activate Global Script Runtime (WinCC Explorer → Project → Computer → Properties → Properties → Stratup)
Create two tags (“HMI_Tag_1” and “HMI_Tag_2” both as “Signed 16-bit value” - WinCC Explorer → Tag Management)
Create a Action (WinCC Explorer → Global Script → VBS Editor → Open → File → New → Action)
Create a script as follow:
| Code: |
Option Explicit
Function action
Dim aaa
Set aaa = HMIRuntime.Tags("HMI_Tag_2")
aaa.Read
aaa.Value = aaa.Value + 1
aaa.Write
End Function
|
Configure the action's trigger to “HMI_Tag_1” (Menu → Tools → info / trigger → tab trigger → select Ta → Add → Tag Name = “HMI_Tag_1”)
Create a Picture
Insert a I/O Field (Smart Objects).
Link the I/O Field with “HMI_Tag_1” (Right mouse click → Configuration Dialog → Tag = “HMI_Tag_1”)
Insert a I/O Field (Smart Objects).
Link the I/O Field with “HMI_Tag_2” (Right mouse click → Configuration Dialog → Tag = “HMI_Tag_2”) |
|
| Back to top |
|
 |
ngcgba Junior

Joined: 07 Mar 2019 Posts: 11
|
Posted: 29/04/2019 10:36 Post subject: |
|
|
| Hi, thank you very much .But i cant find GetLinkedVariable()" function in scripts. I use intouch 2017 |
|
| Back to top |
|
 |
yaqui Member junior

Joined: 30 Aug 2012 Posts: 54
|
Posted: 03/06/2019 00:55 Post subject: |
|
|
| ngcgba wrote: | | Hi, thank you very much .But i cant find GetLinkedVariable()" function in scripts. I use intouch 2017 |
Hi
You can´t find it, because they are talking about WinCC  |
|
| Back to top |
|
 |
|