[TIA PORTAL][CONVERT] Convert Char Array to DInt...DInt to Char Array..Useful and easy function(代码片段
Posted sstan1020
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[TIA PORTAL][CONVERT] Convert Char Array to DInt...DInt to Char Array..Useful and easy function(代码片段相关的知识,希望对你有一定的参考价值。
Function |
"LCA_DI" Convert Char Array to DInt "LDI_CA" Convert DInt to Char Array |
Example |
Parameter |
Input CA Array[0..9] of Char Temp |
Programming |
#DI := "LCA_DI"(#CA); "LDI_CA"(INUM := #DI, OCHR => #CA2);
|
Result |
![]() |
Library |
"LCA_DI" Convert Char Array to DInt |
Parameter |
Input |
Programming |
#TTOL_NUM := 0; #TONE_NUM := 0; #TMOD_NUM := 1; #TUP_BOU := DINT_TO_INT(IN := UPPER_BOUND(ARR := #ICHR, DIM := 1)); #TLW_BOU := DINT_TO_INT(IN := LOWER_BOUND(ARR := #ICHR, DIM := 1)); FOR #TI := #TUP_BOU TO #TLW_BOU BY -1 DO #TONE_NUM := INT_TO_DINT(ABS(CHAR_TO_INT(#ICHR[#TI])) - 16#30); IF #TONE_NUM < 0 OR #TONE_NUM > 9 THEN #TONE_NUM := 0; END_IF; #TTOL_NUM := #TTOL_NUM + DINT_TO_UDINT(#TONE_NUM * #TMOD_NUM); #TMOD_NUM := #TMOD_NUM * 10; END_FOR; #LCA_DI := #TTOL_NUM; |
"LDI_CA" Convert DInt to Char Array |
Parameter |
Input |
Programming |
#TMOD := 0; #TMOD_NUM := 1; #TUP_BOU := DINT_TO_INT(IN := UPPER_BOUND(ARR := #OCHR, DIM := 1)); #TLW_BOU := DINT_TO_INT(IN := LOWER_BOUND(ARR := #OCHR, DIM := 1)); FOR #TI := #TUP_BOU TO #TLW_BOU BY -1 DO #TMOD := UDINT_TO_INT((#INUM / #TMOD_NUM) MOD 10); #OCHR[#TI] := INT_TO_CHAR(ABS(#TMOD) + 16#30); #TMOD_NUM := #TMOD_NUM * 10; END_FOR;
|
Video |
![]() |
以上是关于[TIA PORTAL][CONVERT] Convert Char Array to DInt...DInt to Char Array..Useful and easy function(代码片段的主要内容,如果未能解决你的问题,请参考以下文章
ToString和Convert.ToString处理null值
SVN遇到Can't convert string from 'UTF-8' to native encoding
MySQL Unable to convert MySQL datetime value to System.DateTime 解决方案