Applies To:
  • CitectSCADA 6.xx, 7.xx
  • CitectHMI 6.xx, 7.xx

Summary:

How can I display the current value of an object in the tooltip?  


Solution:

Copy the following Cicode into your project and run the ToolTip() function on startup. The code will append the current value to the end of the tooltip only if the current object has an associated set point ("_SP" tag). This is useful when using genies that include multiple tags. "_SP" should be changed in accordance to the projects naming convention.

///////////////////////////////////////////////////////////////////////
// Function: ToolTip
// Author: Lee Duguid - Citect Support
// Date: 7/08/07
// DESCRIPTION: Function to get current tool tip from a graphical object and append the current tag value to the end, only if the
//object has an associated "_SP" tag.

FUNCTION ToolTip()

INT ix
INT iy
INT iAN
INT iTagIndex
INT iStrSearch
INT iTipdone
INT iStrLength
INT iTotalChar
INT iTagReadLength
STRING sTagRead
STRING sText
STRING hInfo
STRING sTagname
STRING sTip
STRING sRefreshTip 

    WHILE 1 DO 
        DspGetMouse(ix,iy); // find the location of the mouse and set the x and y coordinated into ix and iy. 
        iAN = DspGetNearestAn(ix,iy); // store the AN number into a cicode variable 
        hInfo = DspInfoNew(iAN); 
        sTagname = DspInfo(hInfo,3,0); // reads the variable tag name of the current AN 
        sTagRead = TagRead(sTagname); // reads the current value of the tag 
        sTip = DspGetTip(iAN,0); // gets the tool tip of current AN 
        iStrLength = StrLength(sTip); // number of characters in tool tip 
        iStrSearch = StrSearch(0,sTagname,"_SP"); // searches for SP tag 
        iTipdone = StrSearch(0,sTip," Current Value:"); // verifies if tip has been appended 
        SleepMS(60); 
        
        IF iStrSearch <> -1 AND iTipdone = -1 THEN // IF the tags is a set point AND hasn't been updated THEN 
            DspSetTip(iAN, sTip + " Current Value:" + sTagRead); //sets the tool tip 
        ELSE 
            SleepMS(30); 
        END 
        
        IF iStrSearch <> -1 AND iTipdone <> -1 THEN // IF the tag is a set point AND has been updated THEN 
            iTagReadLength = StrLength(sTagRead) // reads the tag length 
            iTotalChar = iStrLength - 15 - iTagReadLength; // calculates the length of characters to keep 
            sRefreshTip = StrLeft(sTip,iTotalChar); // stores the characters to keep 
            DspSetTip(iAN, sRefreshTip + " Current Value:" + sTagRead); // sets the new tool tip 
        ELSE 
            SleepMS(10); 
        END 
    END
END

 

Keywords:
 

Attachments