Thursday, October 25, 2012

Cicode- Citect SCADA


/* Fill form list with the first 256 Variable Tags. We limit the maximum number of variables, otherwise the list box is too large and hard to use. */

FUNCTION
_tagDebugFillTagList()
        INT     nMaxList;
        INT     nRec;
        INT     hVarRDB     = -1;
        INT     hLocVarRDB  = -1;
        INT     hClustRDB   = -1;
        INT     nClusters   = 0;
        STRING  sCluster    = "";
       
        hClustRDB = RdbOpen("_CLUSTER");
        IF hClustRDB >= 0 THEN
            nClusters = RdbNoRec(hClustRDB);   
            RdbClose(hClustRDB);
            hClustRDB = -1;
        END
               
        nMaxList = 256;
        hVarRDB = RDBOpen("_VARIABL");
        IF hVarRDB >= 0 THEN
                nRec = RDBFirstRec(hVarRDB);
                WHILE nMaxList >= 0 AND nRec >= 0  DO
                        sTag = RDBGet(hVarRDB, "Tag");
                       
                        IF (nClusters > 1) THEN
                            sCluster = RdbGet(hVarRDB, "Cluster");
                            sTag = sCluster + "." + sTag;  
                        END
                       
                        FormAddList(sTag);
                       
                        nRec = RDBNextRec(hVarRDB);                               
                        nMaxList = nMaxList - 1;        
                END
                RDBClose(hVarRDB);
                hVarRDB = -1;
        END
       
        IF nMaxList >= 0 THEN
                hLocVarRDB = RDBOpen("_LOCVAR");
                IF hLocVarRDB >= 0 THEN
                        nRec = RDBFirstRec(hLocVarRDB);
                        WHILE nMaxList >= 0 AND nRec >= 0  DO
                                sTag = RDBGet(hLocVarRDB, "Name");
                                FormAddList(sTag);
                                nRec = RDBNextRec(hLocVarRDB);                                
                                nMaxList = nMaxList - 1;       
                        END
                        RDBClose(hLocVarRDB);
                        hLocVarRDB = -1;
                END
        END
END

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.