Technical FAQs

Ask a Question

How can I use DDE Functions in CitectSCADA?

Here is a cicode to use DDE functions in CitectSCADA:

! Read from Excel spreadsheet
STRING FUNCTION GetExcelData();
    INT hChannel;
    STRING sData;
    hChannel = DDEhInitiate("EXCEL", "DATA.XLS");
    IF hChannel > -1 THEN
        sData = DDEhRequest(hChannel, "R1C1");
        DDEhTerminate(hChannel);
        hChannel = -1;
    END;
    RETURN sData;
END
! Write to Excel spreadsheet
FUNCTION SetExcelData(STRING sData);
    INT hChannel;
    hChannel = DDEhInitiate("EXCEL", "DATA.XLS");
    IF hChannel > -1 THEN
        DDEhPoke(hChannel, "R1C1", sData);
        DDEhTerminate(hChannel);
        hChannel = -1;
    END;
END
! Execute Excel Macro
FUNCTION DoExcelMacro();
    INT        hChannel;
    hChannel = DDEhInitiate("EXCEL", "DATA.XLS");
    IF hChannel > -1 THEN
        DDEhExecute(hChannel, "[RUN(^"TestMacro^")]");
        DDEhTerminate(hChannel);
        hChannel = -1;
    END;
END
Was this helpful?
What can we do to improve the information ?