×
Siemens Industry Online Support
Siemens AG
Entry type: FAQ Entry ID: 19196438, Entry date: 05/17/2010
(0)
Rate

How do you convert a "BCD"-type variable into an "INTEGER", and vice versa, in S7-SCL?

  • Entry
  • Associated product(s)

Instructions
You can use the two data type conversion functions Class B - "BCD_TO_INT" and "INT_TO_BCD" - of S7-SCL to convert values of variables of the "BCD" type to "INTEGER" and vice versa. The integer value range must be between -999 and +999. The result is undefined outside the value range.

Fig. 01 shows an example of the two conversion functions in S7-SCL.

Fig. 01

The value of the input variable "Int_In" of the INT data type is converted by the "INT_TO_BCD" function into a BCD-coded value of the WORD data type and output at the output parameter "Bcd_Out". The "BCD_TO_INT" function converts the value of the input variable "Bcd_In" of the WORD data type (BCD-coded value) into the INT data type. The integer value is transferred to the output parameter "Int_Out".

More information is available in the S7-SCL Online Help under "Conversion functions Class B".

Creation environment
The picture in this FAQ was created with S7-SCL version V5.3 + SP5.

Note
The BCD representation of integers through the conversion functions described above is supported only as from S7-SCL version V5.3 + SP1. For BCD-INT conversion in earlier versions of S7-SCL, we recommend programming with the "BTI" and "ITB" functions in STL.

Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about cyber security, please visit
https://www.siemens.com/cybersecurity#Ouraspiration.
Rate entry
no rating
Requests and feedback
What do you want to do?
Note: The feedback always relates to the current entry / product. Your message will be forwarded to our technical editors working in the Online Support. In a few days, you will receive a response if your feedback requires one. If we have no further questions, you will not hear from us.