[西门子] TwinCAT - 字符串相关函数 01

[复制链接]
查看49343 | 回复0 | 2024-1-27 08:52:54 | 显示全部楼层 |阅读模式

    LREAL_TO_FMTSTR

double := 0.5;s1     := LREAL_TO_FMTSTR( double, 25, FALSE );s2     := LREAL_TO_FMTSTR( double, 2, FALSE );s3     := LREAL_TO_FMTSTR( double, 0, TRUE );s4     := LREAL_TO_FMTSTR( double, 2, TRUE );

s1 = '0.4999999999999999756000000'

s2 = '0.49'

s3 = '0'

s4 = '0.50'

2. DWORD_TO_DECSTR
nCnt := 43981;s1   := DWORD_TO_DECSTR( nCnt, 1 );s2   := DWORD_TO_DECSTR( nCnt, 10 );nCnt := 0;s3   := DWORD_TO_DECSTR( nCnt, 0 );

s1 = '43981'

s2 = '0000043981'

s3 = ''

3. DWORD_TO_HEXSTR
nCnt := 43981;s1   := DWORD_TO_HEXSTR( nCnt, 1, FALSE );s2   := DWORD_TO_HEXSTR( nCnt, 1, TRUE );nCnt := 15;s3   := DWORD_TO_HEXSTR( nCnt, 4, FALSE );nCnt := 0;s4   := DWORD_TO_HEXSTR( nCnt, 0, FALSE );

s1 = 'ABCD'

s2 = 'abcd'

s3 = '000F'

s4 = ''

4. DWORD_TO_OCTSTR
nCnt := 43981;s1   := DWORD_TO_OCTSTR( nCnt, 1 );s2   := DWORD_TO_OCTSTR( nCnt, 10 );nCnt := 0;s3   := DWORD_TO_OCTSTR( nCnt, 0 );

s1 = '125715'

s2 = '0000125715'

s3 = ''

5. DWORD_TO_BINSTR
s1   := DWORD_TO_BINSTR( 16#81, 16 );nCnt := 15;s2   := DWORD_TO_BINSTR( nCnt, 1 );nCnt := 0;s3   := DWORD_TO_BINSTR( nCnt, 0 );

s1 = '0000000010000001'

s2 = '1111'

s3 = ''

6. F_ToUCase
sUCase := F_ToUCase( 'to upper case 1234567890 äöüß' );

sUCase  = 'TO UPPER CASE 1234567890 ÄÖÜß'

7. F_ToLCase
sLCase := F_ToLCase( 'TO LOWER CASE 1234567890 ÄÖÜß' );

sLCase = 'to lower case 1234567890 äöüß'

8. F_LTrim
sLTrim := F_LTrim(' <trim ');(* result: '<trim ' *)sLTrim := F_LTrim(' <trim');(* result: '<trim' *)sLTrim := F_LTrim('<trim');(* result: '<trim' *)sLTrim := F_LTrim('');(* result: '' *)

sLTrim = '<trim '

sLTrim = '<trim'

sLTrim = '<trim'

sLTrim = ''
您需要登录后才可以回帖 登录 | 注册哦

本版积分规则