Calendar Control ActiveX in Citect

Anonymous
Anonymous
Hi there
I am trying to use Microsoft Date and Time Picker Control 6.0 ActiveX in my Citect 7.2 screen. I am trying to read "Day", "Month", "Year" and "Value" parameters. I have associated tags with each of these properties with data type Long (as suggested by help file) but couldnt display correct values for these ActiveX properties. I have tried other data types like LONGBCD, INT, Real but no success. For example when I select date 11/03/2011, I get 40613 for "Value" property using Long data type and if I use Real data type then I get 1299765632.00. And I get 0 for Day, Month and year in all circumstances. I am trying to read a log file dependant upon dates interval selected by user during runtime using this ActiveX Control. If someone have used any Calendar Control ActiveX in Citect, can you please help me with this.
Hamid


autoit
.
AIT
  • INT FUNCTION ReadDTPicker(OBJECT hDTPicker)
    REAL OleDateTime
    STRING sTime
    IF ObjectIsValid(hDTPicker) THEN
    // grab the times components AND make them into a STRING
    sTime = _OBJECTGetProperty(hDTPicker, "Hour"):#0+":"+_OBJECTGetProperty(hDTPicker, "Minute"):#0+":"+_OBJECTGetProperty(hDTPicker, "Second"):#0
    // The oledatetime value only returns the day part.
    oledatetime = StrToReal(_OBJECTGetProperty(hDTPicker, "Value"))
    // There seems to be a bug in the way we read real values out of active X's - seems to round,
    // so this is to fix it - if the time is more than half a day then take one off the day
    // as this would have caused a round up
    IF StrToTime(sTime) >= 12 * 3600 THEN
    oledatetime = oledatetime - 1
    END
    // OLE Date value seems TO be in LOCAL Time so just add the Time AND treat like LOCAL Time AND we have our UDT "unix time"
    RETURN OLEDateToTime(oledatetime,1) + StrToTime(sTime)
    ELSE
    ErrTrap(ERR_NOOBJECT, 0) // Set error flag AND
    RETURN -1 // this IS a bad Time value so you will have TO trap it
    END
    END

    INT FUNCTION WriteDTPicker(OBJECT hDTPicker, INT iDateTime)
    IF ObjectIsValid(hDTPicker) THEN
    IF iDateTime > 100000000 THEN //some kind of sensible Time
    _OBJECTSETProperty(hDTPicker, "Day", DateDay(iDateTime))
    _OBJECTSETProperty(hDTPicker, "Month", DateMonth(iDateTime))
    _OBJECTSETProperty(hDTPicker, "Year", DateYear(iDateTime,1))
    _OBJECTSETProperty(hDTPicker, "Hour", TimeHour(iDateTime))
    _OBJECTSETProperty(hDTPicker, "Minute", TimeMin(iDateTime))
    _OBJECTSETProperty(hDTPicker, "Second", TimeSec(iDateTime))
    RETURN 0
    ELSE
    RETURN ERR_INVALIDVALUE // a bad Time
    END
    ELSE
    RETURN ERR_NOOBJECT // no OBJECT
    END
    END



    stuart.masters
    System Architect
    Schneider Electric Automation

  • Forgot these at the top of the file

    //constants

    INT ERR_NOOBJECT = 269
    INT ERR_INVALIDVALUE = 257



    stuart.masters
    System Architect
    Schneider Electric Automation