Wiki source code of 12 String instructions

Version 2.2 by Leo Wei on 2022/07/20 09:55

Hide last authors
Leo Wei 1.1 1 == (% id="cke_bm_162S" style="display:none" %)** **(%%) ==
2
3 == **LEN/string length detection** ==
4
5 **LEN(P)**
6
7 (% class="wikigeneratedid" %)
8 After detecting the length of the character string specified in (s), store it after the device number specified in (d).
9
10 The data from the device number designated in (s) to the device number of 00H is treated as a character string.
11
12 -[LEN (s) (d)]
13
14 **Content, range and data type**
15
16 (% class="table-bordered" %)
17 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
18 |(s)|String or start number of the device storing the string|-|String|ANYSTRING_SINGLE
19 |(d)|Store the device number of the detected character string length|-|Signed BIN 16 bit|ANY16
20
21 **Device used**
22
23 (% class="table-bordered" %)
24 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="9" %)**Devices**|(((
25 **Offset**
26
27 **modification**
28 )))|(((
29 **Pulse**
30
31 **extension**
32 )))
33 |**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**[D]**|**XXP**
34 |(% rowspan="2" %)LEN|Parameter 1|●|●|●|●|●|●|●|●|●|●|●
35 |Parameter 2| |●|●|●|●|●|●|●|●|●|●
36
37 **Features**
38
39 After detecting the length of the character string specified in (s), store it after the device number specified in (d).
40
41 The data from the device number specified in (s) to the stored device number of 00H is treated as a character string.
42
43 (% style="text-align:center" %)
44 [[image:12_html_ed8cc486d8b12803.png||class="img-thumbnail"]]
45
46 **Error code**
47
48 (% class="table-bordered" %)
49 |**Error code**|**Content**
50 |4085H|(s) The read address exceeds the device range
51 |408AH|(s) The length of the read string exceeds, and the continuous length of the string exceeds 400 characters
52 |408BH|(s) When reading a character string, the maximum range of the device is read, but 00H is not found and the end
53 |4086H|(d) When using offset, the offset address exceeds the device range
54
55 **Example**
56
57 (% style="text-align:center" %)
58 [[image:12_html_bcef3cb437d484ef.png||class="img-thumbnail"]]
59
60 For example, the above Circuit program
61
62 Use the asc instruction to write the string abcdef to the address starting from R0.
63
64 Then use the LEN instruction to determine the length. At this time, D0 will display 6.
65
66 == **{{id name="_Toc31109"/}}{{id name="_Toc32289"/}}{{id name="_Toc24287"/}}LEFT/Extract from the left side of the string** ==
67
68 **LEFT(P)**
69
70 For the character string data stored after the device number specified in (s), the data of (N) characters starting from the left side of the character string (the beginning of the character string) is stored in the device specified in (d) After numbering.
71
72 -[LEFT (s) (d) (N)]
73
74 **Content, range and data type**
75
76 (% class="table-bordered" %)
77 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
78 |(s)|String or start number of the device storing the string|-|String|ANYSTRING_SINGLE
79 |(d)|The start number of the device that stores the (N) character string from the left of (s)|-|String|ANYSTRING_SINGLE
80 |(N)|Number of characters extracted|1 to 400|Signed BIN 16 bit|ANY16
81
82 **Device used**
83
84 (% class="table-bordered" %)
85 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="11" %)**Devices**|(((
86 **Offset**
87
88 **modification**
89 )))|(((
90 **Pulse**
91
92 **extension**
93 )))
94 |**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**K**|**H**|**[D]**|**XXP**
95 |(% rowspan="3" %)LEFT|Parameter 1|●|●|●|●|●|●|●|●|●| | |●|●
96 |Parameter 2| |●|●|●|●|●|●|●|●| | |●|●
97 |Parameter 3| |●|●|●|●|●|●|●|●|●|●|●|●
98
99 **Features**
100
101 For the character string data stored after the device number specified in (s), the data of (N) characters starting from the left side of the character string (the beginning of the character string) is stored in the device specified in (d) After numbering.
102
103 (% style="text-align:center" %)
104 [[image:12_html_dff27d9f4aac5f04.png||class="img-thumbnail"]]
105
106 The character string specified in (s) is the data from the specified device to the position where "00H" is first detected in byte units.
107
108 (N)=7:
109
110 (% style="text-align:center" %)
111 [[image:12_html_3ce6e66cbc96474a.png||class="img-thumbnail"]]
112
113 The final NULL code (00H) representing the character string will be automatically appended to the end of the character string data.
114
115 If the number of extracted characters is an odd number, "00H" is stored in the upper byte of the device storing the final character. If the number of extracted characters is an even number, "0000H" is stored in the device after the device storing the final character.
116
117 When the number of characters specified in (N) is 0, the NULL code (00H) is stored in (d).
118
119 ✎**Note:**
120
121 When handling character codes other than ASCII codes, pay attention to the following points.
122
123 ✎The number of characters is handled in byte units (8 bits). Therefore, like the shifted JIS code, the character code of 1 character is represented by 2 bytes, and the number of characters of 1 character is "2".
124
125 ✎When extracting a character string from a character string containing a character code representing one character in 2 bytes, such as the shift JIS code, the number of characters to be extracted should be considered in the unit of the character code of one character. If only 1 byte of the 2-byte character code is extracted, it will not be the expected character code, so be careful.
126
127 **Error code**
128
129 (% class="table-bordered" %)
130 |**Error code**|**Content**
131 |4085H|(s) The read address exceeds the device range
132 |408AH|(s) The length of the read string exceeds, and the continuous length of the string exceeds 400 characters
133 |408BH|(s) When reading a character string, the maximum range of the device is read, but 00H is not found and the end
134 |4084H|(N)<1 or (N)> string length
135 |4086H|(d) The write address exceeds the device range
136
137 **Example**
138
139 (% style="text-align:center" %)
140 [[image:12_html_962780efc149e8d7.png||class="img-thumbnail"]]
141
142 From the "a b c d e f" starting from D0, take out 5 characters from the left to the R0 type. The character string of R0 is "a b c d e".
143
144 (% style="text-align:center" %)
145 [[image:12_html_fdba3f85ad8d63a.png||class="img-thumbnail"]]
146
147 == **{{id name="_Toc17856"/}}{{id name="_Toc6548"/}}{{id name="_Toc31641"/}}RIGHT/Extract from the right side of the string** ==
148
149 **RIGHT(P)**
150
151 For the string data stored after the device number specified in (s), the data of (N) characters starting from the right side of the string (the end of the string) is stored in the device number specified in (d) after.
152
153 -[RIGHT (s) (d) (N)]
154
155 **Content, range and data type**
156
157 (% class="table-bordered" %)
158 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
159 |(s)|String or start number of the device storing the string|-|String|ANYSTRING_SINGLE
160 |(d)|The start number of the device that stores the (N) character string from the right of (s)|-|String|ANYSTRING_SINGLE
161 |(N)|Number of characters extracted|1 to 400|Signed BIN 16 bit|ANY16
162
163 **Device used**
164
165 (% class="table-bordered" %)
166 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="11" %)**Device**|(((
167 **Offset**
168
169 **modification**
170 )))|(((
171 **Pulse**
172
173 **expansion**
174 )))
175 |**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|(% style="width:62px" %)**K**|(% style="width:31px" %)**H**|**[D]**|**XXP**
176 |(% rowspan="3" %)RIGHT|Parameter 1|●|●|●|●|●|●|●|●|●|(% style="width:62px" %) |(% style="width:31px" %) | |
177 |Parameter 2| |●|●|●|●|●|●|●|●|(% style="width:62px" %) |(% style="width:31px" %) | |
178 |Parameter 3| |●|●|●|●|●|●|●|●|(% style="width:62px" %)●|(% style="width:31px" %)●| |
179
180 **Features**
181
182 For the string data stored after the device number specified in (s), the data of (N) characters starting from the right side of the string (the end of the string) is stored in the device number specified in (d) after.
183
184 (% style="text-align:center" %)
185 [[image:12_html_9d5972269e607737.png||class="img-thumbnail"]]
186
187 The character string specified in (s) is the data from the specified device to the position where "00H" is first detected in byte units.
188
189 (N)=5:
190
191 (% style="text-align:center" %)
192 [[image:12_html_f4911228f8c2dbe9.png||class="img-thumbnail"]]
193
194 The final NULL code (00H) representing the character string will be automatically appended to the end of the character string data.
195
196 If the number of extracted characters is an odd number, "00H" is stored in the upper byte of the device storing the final character. If the number of extracted characters is an even number, "0000H" is stored in the device after the device storing the final character.
197
198 When the number of characters specified in (N) is 0, the NULL code (00H) is stored in (d).
199
200 ✎**Note:**
201
202 When handling character codes other than ASCII codes, pay attention to the following points.
203
204 ✎The number of characters is handled in byte units (8 bits). Therefore, like the shifted JIS code, the character code of 1 character is represented by 2 bytes, and the number of characters of 1 character is "2".
205
206 ✎When extracting a character string from a character string containing a character code representing one character in 2 bytes, such as the shift JIS code, the number of characters to be extracted should be considered in the unit of the character code of one character. If only 1 byte of the 2-byte character code is extracted, it will not be the expected character code, so be careful.
207
208 **Error code**
209
210 (% class="table-bordered" %)
211 |**Error code**|**Content**
212 |4085H|(s), (N) The read address exceeds the device range
213 |408AH|(s) The length of the read string exceeds, and the continuous length of the string exceeds 400 characters
214 |408BH|(s) When reading a character string, the maximum range of the device is read, but 00H is not found and the end
215 |4084H|(N)<1 or (N)> string length
216 |4086H|(d) The write address exceeds the device range
217
218 **Example**
219
220 (% style="text-align:center" %)
221 [[image:12_html_ac9143331fbe5c33.png||class="img-thumbnail"]]
222
223 Get 3 characters “890” from the right in the string "1234567890" and store them in R0
224
225 (% style="text-align:center" %)
226 [[image:12_html_41ec2f74c80685b8.png||class="img-thumbnail"]]
227
228 == **{{id name="_Toc4373"/}}{{id name="_Toc1633"/}}{{id name="_Toc18152"/}}Any extraction from MIDR/string** ==
229
230 **MIDR(P)**
231
232 Store the data at any position in the character string data after the device number specified in (d).
233
234 -[MIDR (s1) (d) (s2)]
235
236 **Content, range and data type**
237
238 (% class="table-bordered" %)
239 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
240 |(s1)|String or start number of the device storing the string|-|String|ANYSTRING_SINGLE
241 |(d)|Start number of the device storing the character string data of the operation result|-|String|ANYSTRING_SINGLE
242 |(s2)|(((
243 The start number of the device that stores the start character position and the number of characters
244
245 (s2)+0: the position of the starting character, (s2)+1: the number of characters is signed
246 )))|-|Signed BIN 16 bit|ANY16_ARRAY
247
248 **Device used**
249
250 (% class="table-bordered" %)
251 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="9" %)**Devices**|(((
252 **Offset**
253
254 **modification**
255 )))|(((
256 **Pulse**
257
258 **extension**
259 )))
260 |**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**[D]**|**XXP**
261 |(% rowspan="3" %)MIDR|Parameter 1|●|●|●|●|●|●|●|●|●|●|●
262 |Parameter 2| |●|●|●|●|●|●|●|●|●|●
263 |Parameter 3|●|●|●|●|●|●|●|●|●|●|●
264
265 **Features**
266
267 For the character string data stored after the device number specified in (s1), the data of the character specified in (s2)+1 starting from the specified position in (s2) is stored to the device number specified in (d) and later .
268
269 (% style="text-align:center" %)
270 [[image:12_html_f20321bfd116b1a8.png||class="img-thumbnail"]]
271
272 1. : The position of the 5th character (S2).
273 1. : ASCII code (S2)+1 of the 5th character.
274
275 The character string specified in (s1) is the data from the specified device to the position where "00H" is first detected in byte units.
276
277 The final NULL code (00H) representing the character string will be automatically appended to the end of the character string data.
278
279 If the number of extracted characters "(s2)+1" is an odd number, "00H" is stored in the upper byte of the device storing the final character. If the number of extracted characters "(s2)+1" is an even number, "0000H" is stored in the device after the device storing the final character.
280
281 (s2) If the number of characters specified in +1 is 0, no processing is performed.
282
283 When the number of characters specified in (s2)+1 is -1, the data up to the final character data specified in (s1) is stored in the device specified in (d) and later.
284
285 (% style="text-align:center" %)
286 [[image:12_html_d1975a12aac01998.png||class="img-thumbnail"]]
287
288 (1): The position of the 5th character (S2).
289
290 **✎Note:**
291
292 When handling character codes other than ASCII codes, pay attention to the following points.
293
294 ✎The number of characters is handled in byte units (8 bits). Therefore, like the shifted JIS code, the character code of 1 character is represented by 2 bytes, and the number of characters of 1 character is "2".
295
296 ✎When extracting a character string from a character string containing a character code representing one character in 2 bytes, such as the shift JIS code, the number of characters to be extracted should be considered in the unit of the character code of one character. If only 1 byte of the 2-byte character code is extracted, it will not be the expected character code, so be careful.
297
298 **Error code**
299
300 (% class="table-bordered" %)
301 |**Error code**|**Content**
302 |4085H|(s1), (s2) The read address exceeds the device range
303 |408AH|(s1) The length of the read string exceeds, and the continuous length of the string exceeds 400 characters
304 |408BH|(s1) When reading a character string, the maximum range of the device is read, but 00H is not found.
305 |4084H|(((
306 (s2) When the value of +1 is -2 (including -2) or less.
307
308 When the value of (s2) exceeds the number of characters in (s1).
309
310 When the value of (s2) is negative.
311
312 When the value of (s2)+1 exceeds the number of characters of (s1).
313
314 When the value of (s2) and (s2) + 1 after the addition operation exceeds the number of characters of (s1).
315 )))
316 |4086H|(d) The write address exceeds the device range
317
318 **Example**
319
320 (% style="text-align:center" %)
321 [[image:12_html_f08fb20d06bbf205.png||class="img-thumbnail"]]
322
323 Get three characters "234" from the second character of the string "123456" into R0.
324
325 (% style="text-align:center" %)
326 [[image:12_html_9c0e1c89a16023f8.png||class="img-thumbnail"]]
327
328 == **{{id name="_Toc26645"/}}{{id name="_Toc21166"/}}{{id name="_Toc28635"/}}$MOV/ string transfer** ==
329
330 **$MOV(P)**
331
332 Transfer the character string data specified in (s) to the device number specified in (d) and later.
333
334 -[$MOV (s) (d)]
335
336 **Content, range and data type**
337
338 (% class="table-bordered" %)
339 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
340 |(s)|Transmission string (maximum 255 characters) or the start number of the device storing the string|-|String|ANYSTRING_SINGLE
341 |(d)|The start number of the device storing the transferred character string|-|String|ANYSTRING_SINGLE
342
343 **Device used**
344
345 (% class="table-bordered" %)
346 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="9" %)**Device**|(((
347 **Offset**
348
349 **modification**
350 )))|(((
351 **Pulse**
352
353 **expansion**
354 )))
355 |**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**[D]**|**XXP**
356 |(% rowspan="2" %)$MOV|Parameter 1|●|●|●|●|●|●|●|●|●|●|●
357 |Parameter 2| |●|●|●|●|●|●|●|●|●|●
358
359 **Features**
360
361 Transfer the character string data specified in (s) to the device number specified in (d) and later. In the transmission of a character string, the character string enclosed by the "" (double quotation marks) specified in (s) or the character string starting from the device number to the device number storing 00H is transmitted once.
362
363 (% style="text-align:center" %)
364 [[image:12_html_a7032fc187916cbb.png||class="img-thumbnail"]]
365
366 Even if the device range (s) to (s)+n storing the transferred character string data overlaps with the device range (d) to (d)+n storing the transferred character string data, it will be normal To process. For example, when the character string stored in D10 to D13 is transferred to D11 to D14, the situation is as follows.
367
368 (% style="text-align:center" %)
369 [[image:12_html_1e6ba98418b9bddd.png||class="img-thumbnail"]]
370
371 (1): It directly becomes the character string before transmission.
372
373 When 00H is stored in the low byte of (s)+n, both the high byte and low byte of (d)+n will store 00H.
374
375 (% style="text-align:center" %)
376 [[image:12_html_16e7ec8cd76e305d.png||class="img-thumbnail"]]
377
378 (1): The upper byte cannot be transmitted.
379
380 (2): It directly becomes the character string before transmission.
381
382 (3): The upper byte automatically stores 00H.
383
384 **Error code**
385
386 (% class="table-bordered" %)
387 |**Error code**|**Content**
388 |4085H|(s) The read address exceeds the device range
389 |408AH|(s) The length of the read string exceeds, and the continuous length of the string exceeds 400 characters
390 |408BH|(s) When reading a character string, the maximum range of the device is read, but 00H is not found and the end
391 |4086H|(d) The write address exceeds the device range
392
393 **Example**
394
395 (% style="text-align:center" %)
396 [[image:12_html_e5c7ac173fafd437.png||class="img-thumbnail"]]
397
398 Copy the string "a b c d e" in D0 to R0.
399
400 (% style="text-align:center" %)
401 [[image:12_html_d4f5be5a8a3b4c6c.png||class="img-thumbnail"]]
402
403 == **{{id name="_Toc3878"/}}{{id name="_Toc20605"/}}{{id name="_Toc2252"/}}Arbitrary replacement in MIDW/string** ==
404
405 **MIDW(P)**
406
407 For the string data stored after the device number specified in (s1), the data of the character specified in (s2)+1 is stored in the string data stored after the device number specified in (d) After the position specified in (s2).
408
409 -[MIDW (s1) (d) (s2)]
410
411 **Content, range and data type**
412
413 (% class="table-bordered" %)
414 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
415 |(s1)|String or start number of the device storing the string|-|String|ANYSTRING_SINGLE
416 |(d)|Start number of the device storing the character string data of the operation result|-|String|ANYSTRING_SINGLE
417 |(s2)|(((
418 The start number of the device that stores the start character position and the number of characters
419
420 (s2)+0: the position of the starting character, (s2)+1: the number of characters is signed
421 )))|-|Signed BIN 16 bit|ANY16_ARRAY
422
423 **Device used**
424
425 (% class="table-bordered" %)
426 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameters**|(% colspan="9" %)**Device**|(((
427 **Offset**
428
429 **modification**
430 )))|(((
431 **Pulse**
432
433 **extension**
434 )))
435 |**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**[D]**|**XXP**
436 |(% rowspan="3" %)MIDW|Parameter 1|●|●|●|●|●|●|●|●|●|●|●
437 |Parameter 2| |●|●|●|●|●|●|●|●|●|●
438 |Parameter 3|●|●|●|●|●|●|●|●|●|●|●
439
440 **Features**
441
442 For the string data stored after the device number specified in (s1), the data of the character specified in (s2)+1 is stored in the string data stored after the device number specified in (d) After the position specified in (s2).
443
444 (% style="text-align:center" %)
445 [[image:12_html_eaf06779c7008d8d.png||class="img-thumbnail"]]
446
447 * The character string specified in (s1) or (d) is the data from the specified device to the position where "00H" is first detected in byte units.
448 * The final NULL code (00H) representing the character string will be automatically appended to the end of the character string data.
449 * If the number of characters specified in (s2)+1 is 0, no processing is performed.
450 * If the number of characters specified in (s2)+1 exceeds the last character of the character string data specified in (d), the data up to the last character of (d) is stored.
451
452 (% style="text-align:center" %)
453 [[image:12_html_22b26f8331ae8bf1.png||class="img-thumbnail"]]
454
455 When the number of characters specified in (s2)+1 is -1, the data up to the final character data specified in (s1) is stored in the device specified in (d) and later.
456
457 (% style="text-align:center" %)
458 [[image:12_html_93e0c05274baf0f8.png||class="img-thumbnail"]]
459
460 **✎Note:**
461
462 * When handling character codes other than ASCII codes, pay attention to the following points.
463 * The number of characters is handled in byte units (8 bits). Therefore, like the shifted JIS code, the character code of 1 character is represented by 2 bytes, and the number of characters of 1 character is "2".
464 * When extracting a character string from a character string containing a character code representing one character in 2 bytes, such as the shift JIS code, the number of characters to be extracted should be considered in the unit of the character code of one character. If only 1 byte of the 2-byte character code is extracted, it will not be the expected character code, so be careful.
465
466 **Error code**
467
468 (% class="table-bordered" %)
469 |**Error code**|**Content**
470 |4085H|(s1) (s2) (d) The read address exceeds the device range
471 |408AH|(s1) (d) The length of the read string exceeds, and the continuous length of the string exceeds 400 characters
472 |408BH|(s1) (d) When reading a character string, the maximum range of the device is read, but 00H is not found.
473 |4084H|(((
474 (s2) When the value of +1 is -2 (including -2) or less.
475
476 When the value of (s2) exceeds the number of characters in (d).
477
478 When the value of (s2) is negative.
479
480 When the value of (s2)+1 exceeds the number of characters of (s1).
481 )))
482 |4086H|(d) The write address exceeds the device range
483
484 **Example**
485
486 (% style="text-align:center" %)
487 [[image:12_html_3ddcabdcaf657946.png||class="img-thumbnail"]]
488
489 Replace the three-character-length characters starting with the second character in the character string "q w e r y" stored in R0 with the first three characters in D20.
490
491 The result of R0 is "q123y".
492
493 (% style="text-align:center" %)
494 [[image:12_html_336d7baf1ba02b9e.png||class="img-thumbnail"]]
495
496 == **{{id name="_Toc17570"/}}{{id name="_Toc12944"/}}{{id name="_Toc7466"/}}STR/BIN 16-bit data → character string conversion** ==
497
498 **STR(P)**
499
500 The BIN 16-bit data specified in (s2) is converted into a character string after a decimal point is added to the position specified in (s1), and stored in the device number specified in (d) or later.
501
502 -[STR (s1) (s2) (d)]
503
504 **Content, range and data type**
505
506 (% class="table-bordered" %)
507 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
508 |(s1)|The start number of the device that stores the number of digits of the converted value|-|Signed BIN 16 bit|ANY16_S_ARRAY
509 |(s2)|Converted BIN data|-32768 to +32767|Signed BIN 16 bit|ANY16_S
510 |(d)|Start number of the device storing the converted character string|-|String|ANYSTRING_SINGLE
511
512 **Device used**
513
514 (% class="table-bordered" %)
515 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameters**|(% colspan="11" %)**Device**|(((
516 **Offset**
517
518 **modification**
519 )))|(((
520 **Pulse**
521
522 **extension**
523 )))
524 |**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**K**|**H**|**[D]**|**XXP**
525 |(% rowspan="3" %)STR|Parameter 1|●|●|●|●|●|●|●|●|●| | |●|●
526 |Parameter 2|●|●|●|●|●|●|●|●|●|●|●|●|●
527 |Parameter 3| | | | |●|●|●|●|●| | |●|●
528
529 **Features**
530
531 The BIN 16-bit data specified in (s2) is converted into a character string after a decimal point is added to the position specified in (s1), and stored in the device number specified in (d) or later.
532
533 (% style="text-align:center" %)
534 [[image:12_html_ab97c25bb7ec51e8.png||class="img-thumbnail"]]
535
536 All digits that can be specified in (s1) are 2 to 8 digits.
537
538 The number of decimal places that can be specified in (s1)+1 is 0 to 5 digits. However, the setting should satisfy the condition that the number of decimal places ≤ (all digits-3).
539
540 The converted character string data will be stored in the device numbers after (d) as follows.
541
542 • In the sign, BIN 16-bit data will store 20H (blank) when it is positive, and 2DH (—) when it is negative.
543
544 • When the number of decimal places is set to other than 0, 2EH(.) is automatically stored in the specified digit + 1 digit. When the decimal place is 0, 2EH(.) is not stored.
545
546 (% style="text-align:center" %)
547 [[image:12_html_ac029ec797f87912.png||class="img-thumbnail"]]
548
549 (1): Number of decimal places
550
551 (2): Automatically attach
552
553 If the value of the decimal place is greater than the number of digits of the BIN 16-bit data, 0 is automatically appended and converted to "0.~*~**" right-aligned.
554
555 (% style="text-align:center" %)
556 [[image:12_html_ab5fdaf7985c6b0f.png||class="img-thumbnail"]]
557
558 (1): Automatically attach
559
560 In the value of all digits, excluding the sign, and if the number of digits after the decimal point is greater than the number of BIN 16-bit data, 20H (blank) is stored between the sign and the value. If the digit of BIN 16-bit data is larger, it will be in error status.
561
562 (% style="text-align:center" %)
563 [[image:12_html_11ebc511ddf34975.png||class="img-thumbnail"]]
564
565 (1): Change to 20H (SP).
566
567 00H is automatically stored at the end of the converted character string.
568
569 • When the total digits are even digits, "0000H" is stored in the device after the device storing the final character. In the case of an odd number of digits, "00H" is stored in the upper byte (8 bits) of the device storing the final character.
570
571 **Error code**
572
573 (% class="table-bordered" %)
574 |**Error code**|**Content**
575 |4085H|(s1), (s2) The read address exceeds the device range
576 |4084H|(((
577 (s1) or (s1+1) parameter setting value is out of range. E.g:
578
579 ~1. The value of (s1) is not in the range of 2-8
580
581 2. The value of (s1+1) is not in the range of 0-5
582
583 3. The value of (s1+1) is greater than the value of (s1) minus 3
584
585 4. When (s1+1) is 0, the number of digits specified in (s1) is less than the number of BIN 16-bit data specified in (s2)+1.
586
587 When (s1+1) is not 0, the number of digits specified in (s1) is less than the number of BIN 16-bit data specified in (s2) + 2.
588
589 (The number of digits of (s1) <the number of BIN 16-bit data that does not contain a sign of (s2) + the number of signs (+ or -) + the number of decimal points (.))
590 )))
591 |4086H|(d) When using offset, the offset address exceeds the device range
592
593 **Example**
594
595 (% style="text-align:center" %)
596 [[image:12_html_247596356e588e50.png||class="img-thumbnail"]]
597
598 After M8 is turned ON, according to the setting of all digits, 6 decimal places and 0 digits, it is converted into a character string "12345" (with a space before 1)
599
600 .
601
602 (% style="text-align:center" %)
603 [[image:12_html_d9023eb3c8ddb67d.png||class="img-thumbnail"]]
604
605 == **{{id name="_Toc10344"/}}{{id name="_Toc22406"/}}{{id name="_Toc14678"/}}{{id name="OLE_LINK606"/}}DSTR/BIN 32-bit data → string conversion** ==
606
607 **DSTR(P)**
608
609 The BIN 32-bit data specified in (s2) is converted into a character string after a decimal point is added to the position specified in (s1), and stored in the device number specified in (d) or later.
610
611 -[DSTR (s1) (s2) (d)]
612
613 **Content, range and data type**
614
615 (% class="table-bordered" %)
616 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
617 |(s1)|The start number of the device that stores the number of digits of the converted value|-|Signed BIN 16 bit|ANY16_S_ARRAY
618 |(s2)|Converted BIN data|-2147483648 to 2147483647|Signed BIN 32 bit|ANY32_S
619 |(d)|Start number of the device storing the converted character string|-|String|ANYSTRING_SINGLE
620
621 **Device used**
622
623 (% class="table-bordered" %)
624 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameters**|(% colspan="13" %)**Device**|(((
625 **Offset**
626
627 **modification**
628 )))|(((
629 **Pulse**
630
631 **extension**
632 )))
633 |**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**[D]**|**XXP**
634 |(% rowspan="3" %)DSTR|Parameter 1|●|●|●|●|●|●|●|●|●| | | | |●|●
635 |Parameter 2|●|●|●|●|●|●|●|●|●|●|●|●|●|●|●
636 |Parameter 3| | | | |●|●|●|●|●| | | | |●|●
637
638 **Features**
639
640 The BIN 32-bit data specified in (s2) is converted into a character string after a decimal point is added to the position specified in (s1), and stored in the device number specified in (d) or later. -654.321 is specified in S2.
641
642 (% style="text-align:center" %)
643 [[image:12_html_3cca0f6ef2d0c3d9.png||class="img-thumbnail"]]
644
645 All digits that can be specified in (s1) are 2 to 13 digits.
646
647 The number of decimal places that can be specified in (s1)+1 is 0 to 10 digits. However, the setting should satisfy the condition that the number of decimal places ≤ (all digits-3).
648
649 The converted character string data will be stored in the device numbers after (d) as follows.
650
651 • In the sign, when the BIN 32-bit data is positive, 20H (blank) is stored, and when it is negative, 2DH (—) is stored.
652
653 • When the number of decimal places is set to other than 0, 2EH(.) is automatically stored in the specified digit + 1 digit. When the decimal place is 0, 2EH(.) is not stored.
654
655 (% style="text-align:center" %)
656 [[image:12_html_3f7d9df483d77cb7.png||class="img-thumbnail"]]
657
658 1. : Number of decimal places
659 1. : Automatically attach
660
661 • If the value of the decimal place is greater than the number of digits in the BIN 32-bit data, 0 is automatically added and converted to "0.~*~**" right-justified.
662
663 (% style="text-align:center" %)
664 [[image:12_html_cd46d5b63b1ebedd.png||class="img-thumbnail"]]
665
666 (1): Automatically attach
667
668 • If the sign is excluded from the value of all digits, and the number of digits after the decimal point is greater than the number of BIN 32-bit data, 20H (blank) is stored between the sign and the value. If the digit of BIN 16-bit data is larger, it will be in error status.
669
670 (% style="text-align:center" %)
671 [[image:12_html_a998daadb6fd7e64.png||class="img-thumbnail"]]
672
673 (1): Change to 20H (SP)
674
675 • 00H is automatically stored at the end of the converted character string.
676
677 • When the total digits are even digits, "0000H" is stored in the device after the device storing the final character. In the case of an odd number of digits, "00H" is stored in the upper byte (8 bits) of the device storing the final character.
678
679 **Error code**
680
681 (% class="table-bordered" %)
682 |**Error code**|**Content**
683 |4085H|(s1), (s2) The read address exceeds the device range
684 |4084H|(((
685 (s1) or (s1+1) parameter setting value is out of range. E.g:
686
687 ~1. The value of (s1) is not in the range of 2 to 13.
688
689 2. The value of (s1+1) is not in the range of 0 to 10.
690
691 3. The value of (s1+1) is greater than the value of (S1) minus 3.
692
693 4. When (s1+1) is 0, the number of digits specified in (s1) is less than the number of BIN 16-bit data specified in (s2)+1.
694
695 When (s1+1) is not 0, the number of digits specified in (s1) is less than the number of BIN 16-bit data specified in (s2) + 2.
696
697 (The number of digits of (s1) <the number of BIN 16-bit data that does not contain a sign of (s2) + the number of signs (+ or -) + the number of decimal points (.))
698 )))
699 |4086H|(d) When using offset, the offset address exceeds the device range.
700
701 **xample**
702
703 (% style="text-align:center" %)
704 [[image:12_html_5b0a20751a964e17.png||class="img-thumbnail"]]
705
706 As shown in the example
707
708 We need to convert 123456 into a floating point string with 9 lengths after the decimal point and 3 lengths,
709
710 The result of the conversion should be 123.456. The previous value will have two spaces to supplement the insufficient number.
711
712 (% style="text-align:center" %)
713 [[image:12_html_430d3795add9e0b4.png||class="img-thumbnail"]]
714
715 == **{{id name="_Toc31869"/}}{{id name="_Toc27153"/}}{{id name="_Toc8064"/}}$+/ Combination of strings** ==
716
717 **$+(P)**
718
719 Connect the string data stored after the device number specified in (s2) to the string data stored after the device number specified in (s1), and store it after the device number specified in (d).
720
721 -[$+ (s1) (s2) (d)]
722
723 **Content, range and data type**
724
725 (% class="table-bordered" %)
726 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
727 |(s1)|Connection data or the start number of the device storing the data or a directly specified character string|-|String|ANYSTRING_SINGLE
728 |(s2)|The connected data or the start number of the device storing the connected data or the directly specified character string|-|String|ANYSTRING_SINGLE
729 |(d)|Start number of the device storing the connection result|-|String|ANYSTRING_SINGLE
730
731 **Device used**
732
733 (% class="table-bordered" %)
734 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameters**|(% colspan="9" %)**Device**|(((
735 **Offset**
736
737 **modification**
738 )))|(((
739 **Pulse**
740
741 **extension**
742 )))
743 |**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**[D]**|**XXP**
744 |(% rowspan="3" %)$+|Parameter 1|●|●|●|●|●|●|●|●|●|●|●
745 |Parameter 2|●|●|●|●|●|●|●|●|●|●|●
746 |Parameter 3| |●|●|●|●|●|●|●|●|●|●
747
748 **Features**
749
750 Connect the string data stored after the device number specified in (s2) to the string data stored after the device number specified in (s1), and store it after the device number specified in (d).
751
752 The character strings of (s1) and (s2) start with the specified device number until the device number of 00H is stored.
753
754 (% style="text-align:center" %)
755 [[image:12_html_f7a3e0a5d0287093.png||class="img-thumbnail"]]
756
757 When merging character strings, 00H indicating the end of the character string specified in (s1) is ignored, and the character string specified in (s2) is connected at the final character of (s1).
758
759 If the character string is merged, 00H will be automatically appended at the end. If the number of characters after connection is an odd number, 00H is stored in the upper byte of the device that stores the final character, and if the number of characters after connection is an even number, the device after the device that stores the final character is stored 0000H will be stored.
760
761 **Error code**
762
763 (% class="table-bordered" %)
764 |**Error code**|**Content**
765 |4085H|(s1) or (s2) read address out of device range
766 |408AH|(s1) or (s2) The length of the read string exceeds, and the continuous length of the string exceeds 400 characters
767 |408BH|(s1) or (s2) When reading a character string, the maximum range of the device is read, but 00H is not found.
768 |4086H|(d) The write address exceeds the device range
769
770 **Example**
771
772 (% style="text-align:center" %)
773 [[image:12_html_ef811f595067af30.png||class="img-thumbnail"]]
774
775 The result of combining the string "12345" and the string "abcde" is "12345abcde"
776
777 (% style="text-align:center" %)
778 [[image:12_html_870490af1bec3c8c.png||class="img-thumbnail"]]
779
780 == **{{id name="_Toc5467"/}}{{id name="_Toc19876"/}}{{id name="_Toc10628"/}}INSTR/string search** ==
781
782 **INSTR(P)**
783
784 Starting from the left (s3) character of the string data stored after the device number specified in (s2), search for the string data stored after the device number specified in (s1), and store the search result in In the device specified in (d).
785
786 -[ INSTR (s1) (s2) (d) (s3)]
787
788 **Content, range and data type**
789
790 (% class="table-bordered" %)
791 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
792 |(s1)|Search string or the start number of the device storing the search string|-|String|ANYSTRING_SINGLE
793 |(s2)|The searched character string or the start number of the device storing the searched character string|-|String|ANYSTRING_SINGLE
794 |(d)|Start number of the device storing the search result|-|Signed BIN 16 bit|ANY16
795 |(s3)|Search start position|1 to 400|Signed BIN 16 bit|ANY16
796
797 **Device used**
798
799 (% class="table-bordered" %)
800 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameters**|(% colspan="11" %)**Device**|(((
801 **Offset**
802
803 **modification**
804 )))|(((
805 **Pulse**
806
807 **extension**
808 )))
809 |**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**K**|**H**|**[D]**|**XXP**
810 |(% rowspan="4" %)INSTR|Parameter 1| | | | |●|●|●|●|●| | |●|●
811 |Parameter 2| | | | |●|●|●|●|●| | |●|●
812 |Parameter 3|●|●|●|●|●|●|●|●|●| | |●|●
813 |Parameter 4|●|●|●|●|●|●|●|●|●|●|●|●|●
814
815 **Features**
816
817 Starting from the left (s3) character of the string data stored after the device number specified in (s2), search for the string data stored after the device number specified in (s1), and store the search result in In the device specified in (d). The search result will store the first character from the start character of the string data specified in (s2).
818
819 (% style="text-align:center" %)
820 [[image:12_html_fb3930cfe47ce231.png||class="img-thumbnail"]]
821
822 (1): Search start position (S3): 3rd character
823
824 (2): The fifth character from the start character
825
826 * If there is no matching character string data, 0 is stored in (d).
827 * If the search start position (s3) is "0", no processing is performed.
828 * The searched character string (s1) can be directly specified.
829
830 (% style="text-align:center" %)
831 [[image:12_html_f423f049e854194f.png||class="img-thumbnail"]]
832
833 (1): Search start position (s3): 3rd character
834
835 (2): The fifth character from the start character
836
837 **Error code**
838
839 (% class="table-bordered" %)
840 |**Error code**|**Content**
841 |4085H|(s1), (s2), (s3) The read address exceeds the device range
842 |408AH|(s1), (s2) The length of the read string exceeds, and the continuous length of the string exceeds 400 characters
843 |408BH|(s1), (s2) When reading a character string, the maximum range of the device is read, but 00H is not found.
844 |4086H|(d) The write address exceeds the device range
845 |4084H|(s3) <0 or (s3)>=string length
846
847 **Example**
848
849 (% style="text-align:center" %)
850 [[image:12_html_bd3a37e71062cac5.png||class="img-thumbnail"]]
851
852 Search for the string "ef" in the continuous string "abcdefg" from the first to the fifth position.
853
854 == **{{id name="_Toc4643"/}}{{id name="_Toc20282"/}}{{id name="_Toc13150"/}}ASC/ASCII data input** ==
855
856 **ASC**
857
858 A command to convert a character string of half-width/English numbers into ASCII code.
859
860 Used to select and display multiple messages on the external display.
861
862 -[ASC (s) (d)]
863
864 **Content, range and data type**
865
866 (% class="table-bordered" %)
867 |**Parameter**|**Content**|**Range**|**Data type**|**Data type (label)**
868 |(s)|32-character half-width English numbers input from the computer|-|String (ASCI code only)|ANY_ASC
869 |(d)|Start word device number for storing ASCII data|-|BIN16 bit|ANY16_S
870
871 **Device used**
872
873 (% class="table-bordered" %)
874 |(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameters**|(% colspan="5" %)**Device**|(((
875 **Offset modification**
876 )))|(((
877 **Pulse extension**
878 )))
879 |**T**|**C**|**D**|**R**|**SD**|**[D]**|**XXP**
880 |(% rowspan="2" %)ASC|Parameter 1| | | | | | |
881 |Parameter 2|●|●|●|●|●|●|
882
883 **Features**
884
885 ~1. 16-bit arithmetic (ASC)
886
887 After converting the half-width, English, and numeric character strings specified in (S) into ASCII codes, they are transferred to (D) in sequence.
888
889 • Process A to Z, 0 to 9, and half-width characters of Signs in (S). (Full-width character strings are not processed.)When programming with a programming tool, enter a character string.
890
891 • The converted ASCII code is stored in (D) every 2 characters/1 byte in the order of low 8 bits and high 8 bits.
892
893 **Extensions**
894
895 After SM161 is turned ON, the extended function becomes effective. At this time, the half-width/alphanumeric character string specified in S is converted into ASCII code, and then it is transmitted to the lower 8 bits (1 byte) of D in sequence.
896
897 ✎**Note:**
898
899 (1) Number of occupied points of the device
900
901 1) When the extended function is OFF
902
903 - D occupies the number of characters ÷ 2 points (if not evenly divisible, the decimal point is rounded up.)
904
905 2) When the extended function is ON
906
907 -The number of points occupied by D is the same as the number occupied by characters.
908
909 (2) When using etc.
910
911 The extended function flag SM161 is a flag bit common to other instructions.
912
913 When using the above instructions and ASC instructions, please note that the SM161 ON or OFF program is written before the ASC instruction so as not to affect it.
914
915 **Error code**
916
917 (% class="table-bordered" %)
918 |**Error code**|**Content**
919 |4085H|The output result of reading application instruction(s) exceeds the device range
920 |4086H|(D) The output result exceeds the device range in writing application instructions
921
922 **Example**
923
924 ~1. Procedure
925
926 (% style="text-align:center" %)
927 [[image:12_html_e275c447761351e0.png||class="img-thumbnail" height="34" width="400"]]
928
929 When X20 = ON, the assignment of D200 to D203:
930
931 (% style="text-align:center" %)
932 [[image:12_html_4d73a151fc88e54a.png||class="img-thumbnail"]]
933
934 If the special register SM161 is set to ON, each ASCII character occupies a 16-bit variable after conversion, as shown in the figure below, the high byte of each variable is filled with 0 (hexadecimal):
935
936 (% class="table-bordered" %)
937 |(% rowspan="2" %) |(% colspan="2" %)**D**•|**S**
938 |**High 8 bits**|**Low 8 bits**|**String**
939 |[[image:12_html_2ef48fa39ec10c22.png||class="img-thumbnail"]]|00|41|A
940 |[[image:12_html_2ef48fa39ec10c22.png||class="img-thumbnail"]] +1|00|42|B
941 |[[image:12_html_2ef48fa39ec10c22.png||class="img-thumbnail"]] +2|00|43|C
942 |[[image:12_html_2ef48fa39ec10c22.png||class="img-thumbnail"]] +3|00|44|D
943 |[[image:12_html_2ef48fa39ec10c22.png||class="img-thumbnail"]] +4|00|45|E
944 |[[image:12_html_2ef48fa39ec10c22.png||class="img-thumbnail"]] +5|00|46|F
945 |[[image:12_html_2ef48fa39ec10c22.png||class="img-thumbnail"]] +6|00|47|G
946 |[[image:12_html_2ef48fa39ec10c22.png||class="img-thumbnail"]] +7|00|48|H