LENGTH_ARRAY // LENGTH_STRING Question
Hi All,
what is the difference between those command, why they didn't reply the same value.
the response i got is:
Line 1 & 4 return the correct answer but why the answer 2,3,5 & 6 are not the same has 1 & 4. It look the same for me. Thanks to help me understand this one.
what is the difference between those command, why they didn't reply the same value.
button_Event[dvtp,127]
{
push:
{
local_var char ctemp[5]
ctemp='Stop:'
send_string 0,"' LENGTH_ARRAY1: ',itoa(LENGTH_ARRAY(ctemp))"
send_string 0,"' LENGTH_ARRAY2: ',itoa(LENGTH_ARRAY('Stop:'))"
send_string 0,"' LENGTH_ARRAY3: ',itoa(LENGTH_ARRAY("'Stop:'"))"
send_string 0,"' LENGTH_STRING1: ',itoa(LENGTH_STRING(ctemp))"
send_string 0,"' LENGTH_STRING2: ',itoa(LENGTH_STRING('Stop:'))"
send_string 0,"' LENGTH_STRING3: ',itoa(LENGTH_STRING("'Stop:'"))"
}
}
the response i got is:
Line 1 (06:38:28):: LENGTH_ARRAY1: 5 Line 2 (06:38:28):: LENGTH_ARRAY2: 1152244836 Line 3 (06:38:28):: LENGTH_ARRAY3: 1152244836 Line 4 (06:38:28):: LENGTH_STRING1: 5 Line 5 (06:38:28):: LENGTH_STRING2: 1152244836 Line 6 (06:38:28):: LENGTH_STRING3: 1152244836
Line 1 & 4 return the correct answer but why the answer 2,3,5 & 6 are not the same has 1 & 4. It look the same for me. Thanks to help me understand this one.
0
Comments
Perhaps someone knows the rules better, but when I run across something wonky like this, I just backpedal and find the method that gives the correct result and move on. With an interpreted language like Netlinx that has a limited application, sometimes that's the best you can do unless you were involved in writing the compiler.
Is the output I get with the following code:
DEFINE_VARIABLE char sTemp[] = 'Stop:'; DEFINE_START WAIT 500{ local_var char cTemp[5]; cTemp = 'Stop:'; send_string 0,"'LA1 nor:',itoa(length_array(ctemp))"; send_string 0,"'LA2 max:',itoa(max_length_array(ctemp))"; send_string 0,"'LA3 nor:',itoa(length_array(stemp))"; send_string 0,"'LA4 max:',itoa(max_length_array(stemp))"; send_string 0,"'LS1 nor:',itoa(length_string(ctemp))"; send_string 0,"'LS2 max:',itoa(max_length_string(ctemp))"; send_string 0,"'LS3 nor:',itoa(length_string(stemp))"; send_string 0,"'LS4 max:',itoa(max_length_string(stemp))"; send_string 0,"'LA5 nor:',itoa(length_array('Stop:'))"; send_string 0,"'LA6 max:',itoa(max_length_array('Stop:'))"; send_string 0,"'LS5 nor:',itoa(length_string('Stop:'))"; send_string 0,"'LS6 max:',itoa(max_length_string('Stop:'))"; }I'm running it on a ni-3100 running 4.1.404.