Applies To:
  • CitectSCADA 1.20, 2.01

Summary:
Question: Can Citect display numbers using a comma delimiter rather than the period delimiter? 

Solution:
Yes, from Version 1.20 and 2.01, Citect supports the Number Format Decimal Separator. This is set in the International section of the Windows Control Panel, and allows you to specify any character for the decimal separator. To enable this feature, you must also set the [INTL]bDecimal=1 in the CITECT.INI file. The Windows control Panel will set the [INTL]sDecimal= in WIN.INI to your required character. Therefore, when you change this using the Control Panel, all Windows programs will see this change. If you only want Citect to see the change, set [INTL]sDecimal= in the CITECT.INI file.

When you change the decimal separator, Citect will use this separator whenever it converts a real number into a string. This includes when numbers are displayed on the screen, written to files and in general Cicode. For example:

sReal = rNum : ###.##;

if rNum contains '1.234' and the decimal separator is a ',' sReal will contain " 1,23". Citect will also look for the separator when it converts a string back into a real number. Citect still supports the '.' character at the same time. For example:

rNum = StrToReal("1,234"); ! use separator
rNum = StrToReal("1.234"); ! this is also valid

However, the decimal separator is not changed in the Cicode language, only in the data. Therefore all real numbers must be initialised with the period delimited.

rNum = 1.234; ! must use '.' period
rNum = 1,234; ! THIS IS INCORRECT AND WILL NOT COMPILE

You may get some problems with TaskNew() and MsgRPC() if you change the separator to a comma. These functions take a string that uses the comma as a delimiter. Under this condition, Citect cannot tell the difference between the comma delimiter and the decimal separator, so you must use '.' in this case. For example:

TaskNew("myfunc", "1,23", 0); ! call Myfunc(1,23) two integer arguments
TaskNew("myfunc", "1.23", 0); ! call Myfunc(1.23) one real argument

The first call passes two integers to the function, the second call passes one real. You should beware that when the argument to TaskNew is generated from other Cicode, the other Cicode could have put your decimal separator in the string by some previous conversion. For example:

TaskNew("myfunc", rNum : ###.##, 0); ! this will fail
sArg = rNum1 : ###.## + "," rNum2 : #.###;
TaskNew("myfunc", sArg); ! this will fail

The first call will fail because Citect will convert rNum into " 1,23". TaskNew will see this as two arguments. The second call will also fail for similar reasons. You must use RealToStr() to convert the numbers into strings. If you specify a -ve number of decimal places to RealToStr, the string will use the period separator. The number of decimal places will still be correct, ie -3 will give 3 places with period separator. For example:

TaskNew("myfunc", RealToStr(rNum, 6, -2), 0);
sArg = RealToStr(rNum1, 6, -2)+ "," RealToStr(rNum2, 5, -3);
TaskNew("myfunc", sArg);
 


Keywords:
 

Attachments