View previous topic :: View next topic
|
Author |
Message |
nutakkimurali
New User
Joined: 15 Nov 2005 Posts: 22
|
|
|
|
DCL CHNG_AGGR_LENGTH FIXED BIN(15) INIT(LENGTH(STRING(CHNG_AGGR)));
what is the o/p of the above statement and i want to know if we use combination pf LENGHT(STRING) what it means??
DCL 01 CHNG_AGGR BASED(DATA_PTR),
03 UPDATE CHAR(1),
03 IACT CHAR(5),
03 NEWTEXT CHAR(36);
DCL DATA_PTR PTR;
DATA_PTR = ADDR(GDSSOP_DATA(OUTPUT_POS));
DCL GDSSOP_DATA(4000) CHAR(1); |
|
Back to top |
|
|
acp_ajay1
New User
Joined: 13 Mar 2006 Posts: 9
|
|
|
|
Hi nutakkimurali
DCL CHNG_AGGR_LENGTH FIXED BIN(15) INIT(LENGTH(STRING(CHNG_AGGR)));
what is the o/p of the above statement and i want to know if we use combination pf LENGHT(STRING) what it means??
Well dear, the statement Length(String) would give u the length of the string.
In PLI if u don't declare a string as varying then length function will return u the total length which u had given at the time of declaration of string.
i mean if u write "dcl abc char(15)" and "abc ='abc'" then even though length is 3, length function will return u length 15, so use varying option when u declare a string.
The statement DCL CHNG_AGGR_LENGTH FIXED BIN(15) INIT(LENGTH(STRING(CHNG_AGGR))); should return the output as 15.
Ajay. |
|
Back to top |
|
|
acp_ajay1
New User
Joined: 13 Mar 2006 Posts: 9
|
|
|
|
Hi nutakkimurali,
Sorry but the statement
DCL CHNG_AGGR_LENGTH FIXED BIN(15) INIT(LENGTH(STRING(CHNG_AGGR)));
won't work and the compiler won't allow u to go ahead. Along with string function u can only have arguments having bit values or characters.
Ajay |
|
Back to top |
|
|
banu
New User
Joined: 09 Aug 2005 Posts: 8 Location: Chennai
|
|
|
|
DCL CHNG_AGGR_LENGTH FIXED BIN(15) INIT(LENGTH(STRING(CHNG_AGGR)));
what is the o/p of the above statement and i want to know if we use combination pf LENGHT(STRING) what it means??
=> This will work. And if you try to display the variable CHNG_AGGR_LENGTH, the ans would be 42.
But if you observe, the value assigned to 'CHNG_AGGR' would be of length 1.
=>
If CHNG_ADDR is declared as a variable of say Char (12),
Then you need not have to use 'Length(string(chng_addr))'.. Instead you could use 'Length(Chng_addr)' itself.
=>
But in your example, you have declared that variable as structure,
Hence u require the built - in function 'STRING'.
Hope this clears your doubt.. |
|
Back to top |
|
|
|