Applies To:
  • CitectSCADA 3.00

Summary:
Question: The FormNumPad dialog does not support the international Windows date seperator. How can I get this support? 

Solution:
Yes it is correct to say that the current version of FormNumPad supplied in the Version 3.00 Include project does not support the International Windows date seperator. The function was designed to use the "/" date seperator only. However a few simple changes can be made so that the function does support the International Date Seperator (like the rest of Citect)

Make the following changes to the file Numpad.ci in the include project. The lines that have been changed or added are in bold.

/*
** FILENAME : NUMPAD.CI
**
**
** DESCRIPTION : This file contains cicode functions that are used
** on the forms with keypads.
*/

INT hNumPadForm = -1;
INT bNumPadClear = TRUE;
STRING sNumpadValue = "";
string sWindowsDateSeperator = "/";

/*
** FUNCTION : FormNumPad
**
** This function generates a form that allows the user
** to enter values through a number pad.
**
** The function supports the following modes
**
** 0 Normal keypad
** 1 With a Password style edit field.
** 2 Mode not yet implemented
** 4 With "+/-" button.
** 8 With Windows Date Seperator Button button. (Default "/")
** 16 With "." button.
** 32 With ":" button, not compatable with mode "+/-".
** 64 With "AM" and "PM" buttons, not compatable with mode "/" or "."
** 128 With "Now" button,
** 256 With "1hr", "2hr", "8hr", "24hr" buttons, not compatable with mode "Now"
**
** Returns the string of value entered through the keypad if closed with the accept button or
** a null string if closed any other way.
**
*/

STRING
FUNCTION FormNumPad(STRING sTitle, STRING sInput, INT iMode = 0)

   STRING sVoid;
   INT nExtraRows = 0;

   sNumPadValue = sInput;
   bNumPadClear = TRUE;
   sWindowsdateSeperator=GetWindowsDateSeperator();

   IF (iMode bitand 4) OR (iMode bitand 8) OR (iMode bitand 16) OR (iMode bitand 32) OR (iMode bitand 64) THEN
      nExtraRows = 1;
   END
   IF (iMode bitand 128) OR (iMode bitand 512) THEN
      nExtraRows = 2;
   END

   IF hNumPadForm = -1 THEN
      hNumPadForm = FormNew(sTitle, 18, 9 + nExtraRows, (8+16));
      IF hNumPadForm > -1 THEN
         _NumPadPosition();
         FormField(2, 1, 14, 1, (iMode bitand 1) + 1, sNumPadValue, "", _NumPadKey1);
         IF (iMode bitand 2) THEN
            ! NYI
         END
         IF (iMode bitand 4) THEN
            FormField(2, 7, 4, 1, 4, sVoid, "+/-", _NumPadKeySign);
         END
         IF (iMode bitand 8) THEN
            FormField(7, 7, 4, 1, 4, sVoid, "&"+sWindowsDateSeperator, _NumPadDateSeperator);
         END
         IF (iMode bitand 16) THEN
            FormField(12, 7, 4, 1, 4, sVoid, "&.", _NumPadKeyPoint);
         END
         IF (iMode bitand 32) THEN
            FormField(2, 7, 4, 1, 4, sVoid, "&:", _NumPadKeyColon);
         END
         IF (iMode bitand 64) THEN
            FormField(7, 7, 4, 1, 4, sVoid, "&AM", _NumPadKeyAM);
            FormField(12, 7, 4, 1, 4, sVoid, "&PM", _NumPadKeyPM);
         END
         IF (iMode bitand 128) THEN
            FormField(2, 8, 4, 1, 4, sVoid, "&Now", _NumPadKeyNow);
         END
         IF (iMode bitand 512) THEN
            FormField(2, 8, 4, 1, 4, sVoid, "1hr", _NumPadKey1hr);
            FormField(7, 8, 4, 1, 4, sVoid, "2hr", _NumPadKey2hr);
            FormField(12, 8, 4, 1, 4, sVoid, "8hr", _NumPadKey8hr);
         END

         FormField(2, 5, 4, 1, 4, sVoid, "&1", _NumPadKey1);
         FormField(7, 5, 4, 1, 4, sVoid, "&2", _NumPadKey2);
         FormField(12, 5, 4, 1, 4, sVoid, "&3", _NumPadKey3);
         FormField(2, 4, 4, 1, 4, sVoid, "&4", _NumPadKey4);
         FormField(7, 4, 4, 1, 4, sVoid, "&5", _NumPadKey5);
         FormField(12, 4, 4, 1, 4, sVoid, "&6", _NumPadKey6);
         FormField(2, 3, 4, 1, 4, sVoid, "&7", _NumPadKey7);
         FormField(7, 3, 4, 1, 4, sVoid, "&8", _NumPadKey8);
         FormField(12, 3, 4, 1, 4, sVoid, "&9", _NumPadKey9);
         FormField(2, 6, 4, 1, 4, sVoid, "&0", _NumPadKey0);
         FormField(7, 6, 4, 1, 4, sVoid, "<-", _NumPadKeyBack);
         FormField(12, 6, 4, 1, 4, sVoid, "C&lr", _NumPadKeyReset);
         FormField(0, 0, 18, 10 + nExtraRows, 7, sVoid, "", 0);
         FormField(2, 8 + nExtraRows, 6, 1, 5, sVoid, "&OK", 0);
         FormField(9, 8 + nExtraRows, 7, 1, 6, sVoid, "&Cancel", 0);

         IF (FormRead(0) <> 0) THEN
            sNumPadValue = sInput;
            ErrSetHw(-1,299);
         END

         hNumPadForm = -1;

         RETURN sNumPadValue;
      END
   END
   RETURN "";
END

FUNCTION
_NumPadPosition()
   INT x;
   INT y;
   INT xMax;
   INT yMax;
   INT xForm = 189;
   INT yForm = 363;

   DspAnGetPos(KeyGetCursor(), x, y);
   xMax = WndInfo(16);
   yMax = WndInfo(17);

   y = Max(2, y - yForm);
   y = Min(y, yMax - yForm);
   x = Min(x, xMax - xForm);

   FormPosition(x, y, 0);
END

FUNCTION _NumPadGetData(STRING char)
   IF bNumPadClear THEN
      sNumPadValue = "";
      bNumPadClear = FALSE;
   ELSE
      FormGetData(hNumPadForm);
   END
   sNumPadValue = sNumPadValue + char;
   FormSetData(hNumPadForm);
END

/*
** FUNCTION : Key Callback functions
**
** The following functions are callback functions for FormNumPad.
** They update the value of the global variable sNumPadValue.
*/

INT FUNCTION _NumPadKey1()
   _NumPadGetData("1");
   RETURN 0;
END

INT FUNCTION _NumPadKey2()
   _NumPadGetData("2");
   RETURN 0;
END

INT FUNCTION _NumPadKey3()
   _NumPadGetData("3");
   RETURN 0;
END

INT FUNCTION _NumPadKey4()
   _NumPadGetData("4");
   RETURN 0;
END

INT FUNCTION _NumPadKey5()
   _NumPadGetData("5");
   RETURN 0;
END

INT FUNCTION _NumPadKey6()
   _NumPadGetData("6");
   RETURN 0;
END

INT FUNCTION _NumPadKey7()
   _NumPadGetData("7");
   RETURN 0;
END

INT FUNCTION _NumPadKey8()
   _NumPadGetData("8");
   RETURN 0;
END

INT FUNCTION _NumPadKey9()
   _NumPadGetData("9");
   RETURN 0;
END

INT FUNCTION _NumPadKey0()
   _NumPadGetData("0");
   RETURN 0;
END

INT FUNCTION _NumPadKeyColon()
   _NumPadGetData(":");
   RETURN 0;
END

INT FUNCTION _NumPadKeySign()
   INT iLength;
   STRING sSign = "+";
   _NumPadGetData("");

   IF (StrLeft(sNumPadValue, 1) = "+") THEN
      iLength = StrLength(sNumPadValue);
      sNumPadValue = StrRight(sNumPadValue, (iLength-1));
      sSign = "-";
   END
   IF (StrLeft(sNumPadValue, 1) = "-") THEN
      iLength = StrLength( sNumPadValue);
      sNumPadValue = StrRight(sNumPadValue, (iLength-1));
      sSign = "+";
   END
   sNumPadValue = sSign + sNumPadValue;
   FormSetData(hNumPadForm);
   RETURN 0;
END

INT FUNCTION _NumPadDateSeperator()
   _NumPadGetData(sWindowsDateSeperator);
   RETURN 0;
END

INT FUNCTION _NumPadKeyPoint()
   _NumPadGetData(".");
   RETURN 0;
END

INT FUNCTION _NumPadKeyReset()
   sNumPadValue = "";
   FormSetData(hNumPadForm);
   RETURN 0;
END

INT FUNCTION _NumPadKeyBack()
   INT iLength;
   FormGetData(hNumPadForm);
   iLength = StrLength(sNumPadValue);
   IF iLength > 0 THEN
      sNumPadValue = StrLeft(sNumPadValue, (iLength-1));
   END
   FormSetData(hNumPadForm);
   RETURN 0;
END

INT FUNCTION _NumPadKeyAM()
   INT iLength;
   FormGetData(hNumPadForm );
   IF ((StrRight(sNumPadValue, 3)=" AM") OR (StrRight(sNumPadValue, 3)=" PM")) THEN
      iLength = StrLength(sNumPadValue);
      sNumPadValue = StrLeft( sNumPadValue, (iLength-3) );
   END
   sNumPadValue = sNumPadValue + " AM";
   FormSetData(hNumPadForm );
   RETURN 0;
END

INT FUNCTION _NumPadKeyPM()
   INT iLength;
   FormGetData(hNumPadForm );
   IF ((StrRight(sNumPadValue, 3)=" AM") OR (StrRight(sNumPadValue, 3)=" PM")) THEN
      iLength = StrLength(sNumPadValue);
      sNumPadValue = StrLeft(sNumPadValue, (iLength-3));
   END
   sNumPadValue = sNumPadValue + " PM";
   FormSetData(hNumPadForm);
   RETURN 0;
END

INT FUNCTION _NumPadKeyNow()
   bNumPadClear = FALSE;
   sNumPadValue = Time(1);
   FormSetData(hNumPadForm );
   RETURN 0;
END

INT FUNCTION _NumPadKey1hr()
   bNumPadClear = FALSE;
   sNumPadValue = "01:00:00";
   FormSetData(hNumPadForm);
   RETURN 0;
END

INT FUNCTION _NumPadKey2hr()
   bNumPadClear = FALSE;
   sNumPadValue = "02:00:00";
   FormSetData(hNumPadForm);
   RETURN 0;
END

INT FUNCTION _NumPadKey8hr()
   bNumPadClear = FALSE;
   sNumPadValue = "08:00:00";
   FormSetData(hNumPadForm);
   RETURN 0;
END

STRING FUNCTION GetWindowsDateSeperator()
   ...
   RETURN WndGetProfile("Intl","sDate","/");
END

 

Keywords:
 

Attachments