Define_start is the section that is run once when a processor first comes online. If you prefer, you could write a function that does the set_length_array and then does the find_string command. This might also be better if you are assigning values to the array using strings and there is a chance that the processor will set the length shorter than the max length.
Define_start is the section that is run once when a processor first comes online. If you prefer, you could write a function that does the set_length_array and then does the find_string command. This might also be better if you are assigning values to the array using strings and there is a chance that the processor will set the length shorter than the max length.
Jeff
I haven't found the need to use set_length_array at all. The array length never changes so I guess I don't understand the need.
Paul
I think the problem may stem from my use of a stack_var in this situation. I have not tried it with a volatile variable that is initialized at definition, but that should probably fix the problem.
I haven't found the need to use set_length_array at all. The array length never changes so I guess I don't understand the need.
Paul
I'm not sure I do either. For some reason I was convinced that there was a problem with initializing character arrays that were populated with zeroes, but today I can't find a problem.
There are two different values for char arrays. There is a length_array and a max_length_array. If you have a variable declared as char sMyString[100], but do not assign anything to it, the length_array = 0 and the max_length_array = 100. If you the do something like sMyString = "'123456789'", the length_array = 9 and max_length_array =100. find_string in the test I ran was using length_array, not max_length_array for it's parsing. As I recall, if you do something like sMyString[50] = '1', the length_array does not change. If I have a minute, I will see if I can write a few tests to clarify all of this. I believe it might also be different for stack_vars vs global variables.
As you can see, you have to do a set_length_array() for find_string to function properly. The only reason it is functioning properly on the persistent variable is because I have run this a couple times and restarted the processor.
P.S.
for display purposes, on the entire array contents, I replaced all of the 0 values with @s. This allows you to see that stack_var arrays are not initialized and could throw false positives if you are not careful.
On global char arrays:
Line 1 (16:47:39.609):: ******Global PERSISTENT char array:
Line 2 (16:47:39.609):: $$$ Before changes
Line 3 (16:47:39.609):: # length_array:25 length_string:25
Line 4 (16:47:39.609):: # max_length_array:100 max_length_string:100
Line 5 (16:47:39.609):: # Contents of incoming array:
Line 6 (16:47:39.609):: # String Assigned
Line 7 (16:47:39.609):: FIND_STRING is reporting: 20
Line 8 (16:47:39.609):: #
Line 9 (16:47:39.609):: - - - - - - - - - - - - - - - - - - - - - - - - -
Line 10 (16:47:39.609):: #
Line 11 (16:47:39.609):: # Contents of entire array:
Line 12 (16:47:39.625):: # String Assigned@@@@1@@@@@@@@@@@@@@T@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Line 13 (16:47:39.625):: FIND_STRING is reporting: 20
Line 14 (16:47:39.625):: #
Line 15 (16:47:39.625):: -------------------------------------------
Line 16 (16:47:39.625):: $$$ After insert into indexed position
Line 17 (16:47:39.625):: # length_array:25 length_string:25
Line 18 (16:47:39.625):: # max_length_array:100 max_length_string:100
Line 19 (16:47:39.625):: # Contents of incoming array:
Line 20 (16:47:39.625):: # String Assigned
Line 21 (16:47:39.625):: FIND_STRING is reporting: 20
Line 22 (16:47:39.625):: #
Line 23 (16:47:39.625):: - - - - - - - - - - - - - - - - - - - - - - - - -
Line 24 (16:47:39.625):: #
Line 25 (16:47:39.625):: # Contents of entire array:
Line 26 (16:47:39.625):: # String Assigned@@@@1@@@@@@@@@@@@@@T@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Line 27 (16:47:39.625):: FIND_STRING is reporting: 20
Line 28 (16:47:39.625):: #
Line 29 (16:47:39.625):: -------------------------------------------
Line 30 (16:47:39.625):: $$$ After assigning a string
Line 31 (16:47:39.625):: # length_array:15 length_string:15
Line 32 (16:47:39.640):: # max_length_array:100 max_length_string:100
Line 33 (16:47:39.640):: # Contents of incoming array:
Line 34 (16:47:39.640):: # String Assigned
Line 35 (16:47:39.640):: FIND_STRING is reporting: 0
Line 36 (16:47:39.640):: #
Line 37 (16:47:39.640):: - - - - - - - - - - - - - - - - - - - - - - - - -
Line 38 (16:47:39.640):: #
Line 39 (16:47:39.640):: # Contents of entire array:
Line 40 (16:47:39.640):: # String Assigned@@@@1@@@@@@@@@@@@@@T@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Line 41 (16:47:39.640):: FIND_STRING is reporting: 20
Line 42 (16:47:39.640):: #
Line 43 (16:47:39.640):: -------------------------------------------
Line 44 (16:47:39.640):: $$$ After setting array length
Line 45 (16:47:39.640):: # length_array:25 length_string:25
Line 46 (16:47:39.656):: # max_length_array:100 max_length_string:100
Line 47 (16:47:39.656):: # Contents of incoming array:
Line 48 (16:47:39.656):: # String Assigned
Line 49 (16:47:39.656):: FIND_STRING is reporting: 20
Line 50 (16:47:39.656):: #
Line 51 (16:47:39.656):: - - - - - - - - - - - - - - - - - - - - - - - - -
Line 52 (16:47:39.656):: #
Line 53 (16:47:39.656):: # Contents of entire array:
Line 54 (16:47:39.656):: # String Assigned@@@@1@@@@@@@@@@@@@@T@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Line 55 (16:47:39.656):: FIND_STRING is reporting: 20
Line 56 (16:47:39.656):: #
Line 57 (16:47:39.656):: ##########################################
on Non-Volatile char arrays:
Line 58 (16:47:39.656):: ******Global NON_VOLATILE char array:
Line 59 (16:47:39.656):: $$$ Before changes
Line 60 (16:47:39.656):: # length_array:0 length_string:0
Line 61 (16:47:39.656):: # max_length_array:100 max_length_string:100
Line 62 (16:47:39.656):: # Contents of incoming array:
Line 63 (16:47:39.671):: #
Line 64 (16:47:39.671):: FIND_STRING is reporting: 0
Line 65 (16:47:39.671):: #
Line 66 (16:47:39.671):: - - - - - - - - - - - - - - - - - - - - - - - - -
Line 67 (16:47:39.671):: #
Line 68 (16:47:39.671):: # Contents of entire array:
Line 69 (16:47:39.671):: # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Line 70 (16:47:39.671):: FIND_STRING is reporting: 0
Line 71 (16:47:39.671):: #
Line 72 (16:47:39.671):: -------------------------------------------
Line 73 (16:47:39.671):: $$$ After insert into indexed position
Line 74 (16:47:39.671):: # length_array:0 length_string:0
Line 75 (16:47:39.671):: # max_length_array:100 max_length_string:100
Line 76 (16:47:39.671):: # Contents of incoming array:
Line 77 (16:47:39.687):: #
Line 78 (16:47:39.687):: FIND_STRING is reporting: 0
Line 79 (16:47:39.687):: #
Line 80 (16:47:39.687):: - - - - - - - - - - - - - - - - - - - - - - - - -
Line 81 (16:47:39.687):: #
Line 82 (16:47:39.687):: # Contents of entire array:
Line 83 (16:47:39.687):: # @@@@@@@@@@@@@@@@@@@1@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Line 84 (16:47:39.687):: FIND_STRING is reporting: 20
Line 85 (16:47:39.687):: #
Line 86 (16:47:39.687):: -------------------------------------------
Line 87 (16:47:39.687):: $$$ After assigning a string
Line 88 (16:47:39.687):: # length_array:15 length_string:15
Line 89 (16:47:39.687):: # max_length_array:100 max_length_string:100
Line 90 (16:47:39.687):: # Contents of incoming array:
Line 91 (16:47:39.687):: # String Assigned
Line 92 (16:47:39.703):: FIND_STRING is reporting: 0
Line 93 (16:47:39.703):: #
Line 94 (16:47:39.703):: - - - - - - - - - - - - - - - - - - - - - - - - -
Line 95 (16:47:39.703):: #
Line 96 (16:47:39.703):: # Contents of entire array:
Line 97 (16:47:39.703):: # String Assigned@@@@1@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Line 98 (16:47:39.703):: FIND_STRING is reporting: 20
Line 99 (16:47:39.703):: #
Line 100 (16:47:39.703):: -------------------------------------------
Line 101 (16:47:39.703):: $$$ After setting array length
Line 102 (16:47:39.703):: # length_array:25 length_string:25
Line 103 (16:47:39.703):: # max_length_array:100 max_length_string:100
Line 104 (16:47:39.703):: # Contents of incoming array:
Line 105 (16:47:39.703):: # String Assigned
Line 106 (16:47:39.718):: FIND_STRING is reporting: 20
Line 107 (16:47:39.718):: #
Line 108 (16:47:39.718):: - - - - - - - - - - - - - - - - - - - - - - - - -
Line 109 (16:47:39.718):: #
Line 110 (16:47:39.718):: # Contents of entire array:
Line 111 (16:47:39.718):: # String Assigned@@@@1@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Line 112 (16:47:39.718):: FIND_STRING is reporting: 20
Line 113 (16:47:39.718):: #
Line 114 (16:47:39.718):: ##########################################
on Global Volatile char arrays:
Line 115 (16:47:39.718):: ******Global VOLATILE char array:
Line 116 (16:47:39.718):: $$$ Before changes
Line 117 (16:47:39.718):: # length_array:0 length_string:0
Line 118 (16:47:39.718):: # max_length_array:100 max_length_string:100
Line 119 (16:47:39.718):: # Contents of incoming array:
Line 120 (16:47:39.718):: #
Line 121 (16:47:39.718):: FIND_STRING is reporting: 0
Line 122 (16:47:39.734):: #
Line 123 (16:47:39.734):: - - - - - - - - - - - - - - - - - - - - - - - - -
Line 124 (16:47:39.734):: #
Line 125 (16:47:39.734):: # Contents of entire array:
Line 126 (16:47:39.734):: # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Line 127 (16:47:39.734):: FIND_STRING is reporting: 0
Line 128 (16:47:39.734):: #
Line 129 (16:47:39.734):: -------------------------------------------
Line 130 (16:47:39.734):: $$$ After insert into indexed position
Line 131 (16:47:39.734):: # length_array:0 length_string:0
Line 132 (16:47:39.734):: # max_length_array:100 max_length_string:100
Line 133 (16:47:39.734):: # Contents of incoming array:
Line 134 (16:47:39.734):: #
Line 135 (16:47:39.734):: FIND_STRING is reporting: 0
Line 136 (16:47:39.734):: #
Line 137 (16:47:39.750):: - - - - - - - - - - - - - - - - - - - - - - - - -
Line 138 (16:47:39.750):: #
Line 139 (16:47:39.750):: # Contents of entire array:
Line 140 (16:47:39.750):: # @@@@@@@@@@@@@@@@@@@1@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Line 141 (16:47:39.750):: FIND_STRING is reporting: 20
Line 142 (16:47:39.750):: #
Line 143 (16:47:39.750):: -------------------------------------------
Line 144 (16:47:39.750):: $$$ After assigning a string
Line 145 (16:47:39.750):: # length_array:15 length_string:15
Line 146 (16:47:39.750):: # max_length_array:100 max_length_string:100
Line 147 (16:47:39.750):: # Contents of incoming array:
Line 148 (16:47:39.750):: # String Assigned
Line 149 (16:47:39.750):: FIND_STRING is reporting: 0
Line 150 (16:47:39.765):: #
Line 151 (16:47:39.765):: - - - - - - - - - - - - - - - - - - - - - - - - -
Line 152 (16:47:39.765):: #
Line 153 (16:47:39.765):: # Contents of entire array:
Line 154 (16:47:39.765):: # String Assigned@@@@1@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Line 155 (16:47:39.765):: FIND_STRING is reporting: 20
Line 156 (16:47:39.765):: #
Line 157 (16:47:39.765):: -------------------------------------------
Line 158 (16:47:39.765):: $$$ After setting array length
Line 159 (16:47:39.765):: # length_array:25 length_string:25
Line 160 (16:47:39.765):: # max_length_array:100 max_length_string:100
Line 161 (16:47:39.765):: # Contents of incoming array:
Line 162 (16:47:39.765):: # String Assigned
Line 163 (16:47:39.765):: FIND_STRING is reporting: 20
Line 164 (16:47:39.765):: #
Line 165 (16:47:39.765):: - - - - - - - - - - - - - - - - - - - - - - - - -
Line 166 (16:47:39.765):: #
Line 167 (16:47:39.781):: # Contents of entire array:
Line 168 (16:47:39.781):: # String Assigned@@@@1@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Line 169 (16:47:39.781):: FIND_STRING is reporting: 20
Line 170 (16:47:39.781):: #
Line 171 (16:47:39.781):: ##########################################
on Local_vars:
Line 172 (16:47:39.781):: ******LOCAL_VAR char array:
Line 173 (16:47:39.781):: $$$ Before changes
Line 174 (16:47:39.781):: # length_array:0 length_string:0
Line 175 (16:47:39.781):: # max_length_array:100 max_length_string:100
Line 176 (16:47:39.781):: # Contents of incoming array:
Line 177 (16:47:39.781):: #
Line 178 (16:47:39.781):: FIND_STRING is reporting: 0
Line 179 (16:47:39.781):: #
Line 180 (16:47:39.781):: - - - - - - - - - - - - - - - - - - - - - - - - -
Line 181 (16:47:39.781):: #
Line 182 (16:47:39.796):: # Contents of entire array:
Line 183 (16:47:39.796):: # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Line 184 (16:47:39.796):: FIND_STRING is reporting: 0
Line 185 (16:47:39.796):: #
Line 186 (16:47:39.796):: -------------------------------------------
Line 187 (16:47:39.796):: $$$ After insert into indexed position
Line 188 (16:47:39.796):: # length_array:0 length_string:0
Line 189 (16:47:39.796):: # max_length_array:100 max_length_string:100
Line 190 (16:47:39.796):: # Contents of incoming array:
Line 191 (16:47:39.796):: #
Line 192 (16:47:39.796):: FIND_STRING is reporting: 0
Line 193 (16:47:39.796):: #
Line 194 (16:47:39.796):: - - - - - - - - - - - - - - - - - - - - - - - - -
Line 195 (16:47:39.796):: #
Line 196 (16:47:39.796):: # Contents of entire array:
Line 197 (16:47:39.812):: # @@@@@@@@@@@@@@@@@@@1@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Line 198 (16:47:39.812):: FIND_STRING is reporting: 20
Line 199 (16:47:39.812):: #
Line 200 (16:47:39.812):: -------------------------------------------
Line 201 (16:47:39.812):: $$$ After assigning a string
Line 202 (16:47:39.812):: # length_array:15 length_string:15
Line 203 (16:47:39.812):: # max_length_array:100 max_length_string:100
Line 204 (16:47:39.812):: # Contents of incoming array:
Line 205 (16:47:39.812):: # String Assigned
Line 206 (16:47:39.812):: FIND_STRING is reporting: 0
Line 207 (16:47:39.812):: #
Line 208 (16:47:39.812):: - - - - - - - - - - - - - - - - - - - - - - - - -
Line 209 (16:47:39.812):: #
Line 210 (16:47:39.812):: # Contents of entire array:
Line 211 (16:47:39.812):: # String Assigned@@@@1@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Line 212 (16:47:39.828):: FIND_STRING is reporting: 20
Line 213 (16:47:39.828):: #
Line 214 (16:47:39.828):: -------------------------------------------
Line 215 (16:47:39.828):: $$$ After setting array length
Line 216 (16:47:39.828):: # length_array:25 length_string:25
Line 217 (16:47:39.828):: # max_length_array:100 max_length_string:100
Line 218 (16:47:39.828):: # Contents of incoming array:
Line 219 (16:47:39.828):: # String Assigned
Line 220 (16:47:39.828):: FIND_STRING is reporting: 20
Line 221 (16:47:39.828):: #
Line 222 (16:47:39.828):: - - - - - - - - - - - - - - - - - - - - - - - - -
Line 223 (16:47:39.828):: #
Line 224 (16:47:39.828):: # Contents of entire array:
Line 225 (16:47:39.828):: # String Assigned@@@@1@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Line 226 (16:47:39.843):: FIND_STRING is reporting: 20
Line 227 (16:47:39.843):: #
Line 228 (16:47:39.843):: ##########################################
on Stack_var char arrays:
Line 229 (16:47:39.843):: ******STACK_VAR char array:
Line 230 (16:47:39.843):: $$$ Before changes
Line 231 (16:47:39.843):: # length_array:0 length_string:0
Line 232 (16:47:39.843):: # max_length_array:100 max_length_string:100
Line 233 (16:47:39.843):: # Contents of incoming array:
Line 234 (16:47:39.843):: #
Line 235 (16:47:39.843):: FIND_STRING is reporting: 0
Line 236 (16:47:39.843):: #
Line 237 (16:47:39.843):: - - - - - - - - - - - - - - - - - - - - - - - - -
Line 238 (16:47:39.843):: #
Line 239 (16:47:39.843):: # Contents of entire array:
Line 240 (16:47:39.843):: # @$05$022$01$01$0A$07$EF$10@$0A$05$80@Friday, Jan 10, 2031@0.0.315@NSX Application@AMX Corp.@$02$04$0A$D37$04@@@g@@@g@@@g@@@g@@@g@@@g
Line 241 (16:47:39.843):: FIND_STRING is reporting: 28
Line 242 (16:47:39.859):: #
Line 243 (16:47:39.859):: -------------------------------------------
Line 244 (16:47:39.859):: $$$ After insert into indexed position
Line 245 (16:47:39.859):: # length_array:0 length_string:0
Line 246 (16:47:39.859):: # max_length_array:100 max_length_string:100
Line 247 (16:47:39.859):: # Contents of incoming array:
Line 248 (16:47:39.859):: #
Line 249 (16:47:39.859):: FIND_STRING is reporting: 0
Line 250 (16:47:39.859):: #
Line 251 (16:47:39.859):: - - - - - - - - - - - - - - - - - - - - - - - - -
Line 252 (16:47:39.859):: #
Line 253 (16:47:39.859):: # Contents of entire array:
Line 254 (16:47:39.859):: # @$05$022$01$01$0A$07$EF$10@$0A$05$80@Frid1y, Jan 10, 2031@0.0.315@NSX Application@AMX Corp.@$02$04$0A$D37$04@@@g@@@g@@@g@@@g@@@g@@@g
Line 255 (16:47:39.859):: FIND_STRING is reporting: 20
Line 256 (16:47:39.859):: #
Line 257 (16:47:39.875):: -------------------------------------------
Line 258 (16:47:39.875):: $$$ After assigning a string
Line 259 (16:47:39.875):: # length_array:15 length_string:15
Line 260 (16:47:39.875):: # max_length_array:100 max_length_string:100
Line 261 (16:47:39.875):: # Contents of incoming array:
Line 262 (16:47:39.875):: # String Assigned
Line 263 (16:47:39.875):: FIND_STRING is reporting: 0
Line 264 (16:47:39.875):: #
Line 265 (16:47:39.875):: - - - - - - - - - - - - - - - - - - - - - - - - -
Line 266 (16:47:39.875):: #
Line 267 (16:47:39.875):: # Contents of entire array:
Line 268 (16:47:39.875):: # String AssignedFrid1y, Jan 10, 2031@0.0.315@NSX Application@AMX Corp.@$02$04$0A$D37$04@@@g@@@g@@@g@@@g@@@g@@@g
Line 269 (16:47:39.875):: FIND_STRING is reporting: 20
Line 270 (16:47:39.875):: #
Line 271 (16:47:39.875):: -------------------------------------------
Line 272 (16:47:39.890):: $$$ After setting array length
Line 273 (16:47:39.890):: # length_array:25 length_string:25
Line 274 (16:47:39.890):: # max_length_array:100 max_length_string:100
Line 275 (16:47:39.890):: # Contents of incoming array:
Line 276 (16:47:39.890):: # String AssignedFrid1y, Ja
Line 277 (16:47:39.890):: FIND_STRING is reporting: 20
Line 278 (16:47:39.890):: #
Line 279 (16:47:39.890):: - - - - - - - - - - - - - - - - - - - - - - - - -
Line 280 (16:47:39.890):: #
Line 281 (16:47:39.890):: # Contents of entire array:
Line 282 (16:47:39.890):: # String AssignedFrid1y, Jan 10, 2031@0.0.315@NSX Application@AMX Corp.@$02$04$0A$D37$04@@@g@@@g@@@g@@@g@@@g@@@g
Line 283 (16:47:39.890):: FIND_STRING is reporting: 20
Line 284 (16:47:39.890):: #
Line 285 (16:47:39.890):: ##########################################
Comments
Jeff
What's "define_start"?
Jeff
I haven't found the need to use set_length_array at all. The array length never changes so I guess I don't understand the need.
Paul
Jeff
I'm not sure I do either. For some reason I was convinced that there was a problem with initializing character arrays that were populated with zeroes, but today I can't find a problem.
Jeff
As you can see, you have to do a set_length_array() for find_string to function properly. The only reason it is functioning properly on the persistent variable is because I have run this a couple times and restarted the processor.
P.S.
for display purposes, on the entire array contents, I replaced all of the 0 values with @s. This allows you to see that stack_var arrays are not initialized and could throw false positives if you are not careful.
On global char arrays:
on Non-Volatile char arrays:
on Global Volatile char arrays:
on Local_vars:
on Stack_var char arrays:
Jeff