winIDEA SDK
test_index_of.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2#
3# (c) TASKING Germany GmbH, 2023
4
5import isystem.connect as ic
6
7
8winidea_id = ''
9
10
11def test_index_of():
12 connMgr = ic.ConnectionMgr()
13 connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
14
15 optCtrl = ic.COptionController(connMgr, "/IDE/System.Debug.Applications")
16
17 index = optCtrl.index_of("Name", "App")
18 print(f"Index of the item whose 'Name' attribute has value 'App': {index}")
19
20 index = optCtrl.index_of("Name", "x")
21 print(f"Index of the item whose 'Name' attribute has value 'x' (-1 = does not exist): {index}")
22
23 try:
24 optCtrl.index_of("xzy", "App")
25 except Exception as err:
26 print(f"Attribute name must be correct, otherwise exception is raised: 'xzy':\n{err}")
27
28
29if __name__ == "__main__":
30 test_index_of()