OSDN Git Service

...。
[ring-lang-081/ring.git] / docs / ja-jp / build / html / _sources / checkandconvert.txt
1 .. index:: 
2         single: データ型; はじめに
3
4 ====================
5 データ型の検査と変換
6 ====================
7
8 この用途の関数を学びます。
9
10 * データ型の検査
11 * 文字の検査
12 * 変換
13
14 .. index:: 
15         pair: データ型; データ型の検査
16
17 データ型の検査
18 ==============
19
20 データ型の検査用関数です
21
22 * isstring()
23 * isnumber()
24 * islist()
25 * type()
26 * isnull()
27
28 .. index:: 
29         pair: データ型; IsString()
30
31 IsString() 関数
32 ===============
33
34 IsString() 関数は値が文字列であるかどうか検査します。
35
36 文法:
37
38 .. code-block:: ring
39
40         IsString(値) ---> 値が文字列ならば 1 を、そうでなければ 0 です。
41
42 用例:
43
44 .. code-block:: ring
45
46         see isstring(5) + nl +          # 0 を表示
47             isstring("hello") + nl      # 1 を表示
48
49 .. index:: 
50         pair: データ型; IsNumber()
51
52 IsNumber() 関数
53 ===============
54
55 IsNumber() 関数は値が数値であるかどうか検査します。
56
57 文法:
58
59 .. code-block:: ring
60
61         IsNumber(値) ---> 値が数値ならば 1 を、そうでなければ 0 です。
62
63 用例:
64
65 .. code-block:: ring
66
67         see isnumber(5) + nl +          # 1 を表示
68             isnumber("hello") + nl      # 0 を表示
69
70 .. index:: 
71         pair: データ型; IsList()
72
73 IsList() 関数
74 =============
75
76 IsList() 関数は値がリストであるかどうか検査します。
77
78 文法:
79
80 .. code-block:: ring
81
82         IsList(値) ---> 値がリストならば 1 を、そうでなければ 0 です。
83
84 用例:
85
86 .. code-block:: ring
87
88         see islist(5) + nl +            # 0 を表示
89             islist("hello") + nl +      # 0 を表示
90             islist([1,3,5])             # 1 を表示
91         
92 .. index:: 
93         pair: データ型; Type()
94
95 Type() 関数
96 ===========
97
98 Type() 関数は値の型を検査します。
99
100
101 文法:
102
103 .. code-block:: ring
104
105         Type(値) ---> 型を文字列で返します。
106
107 用例:
108
109 .. code-block:: ring
110
111             see Type(5) + nl +          # NUMBER を表示
112             Type("hello") + nl +        # STRING を表示
113             Type([1,3,5])               # LIST を表示
114
115 .. index:: 
116         pair: データ型; isNULL()
117
118 IsNULL() 関数
119 =============
120
121 IsNULL() 関数は値が null であるかどうか検査します。 
122
123 文法:
124
125 .. code-block:: ring
126
127         IsNULL(値) ---> 値が NULL ならば 1 を、そうでなければ 0 です。
128
129 用例:
130
131 .. code-block:: ring
132
133             see isnull(5) + nl +        # 0 を表示
134             isnull("hello") + nl +      # 0 を表示
135             isnull([1,3,5]) + nl +      # 0 を表示
136             isnull("") + nl +           # 1 を表示
137             isnull("NULL")              # 1 を表示
138
139 .. index:: 
140         pair: データ型; 文字の検査
141
142 文字の検査
143 ==========
144
145 この関数は文字を検査します。
146
147 * isalnum()
148 * isalpha()
149 * iscntrl()
150 * isdigit()
151 * isgraph()
152 * islower()
153 * isprint()
154 * ispunct()
155 * isspace()
156 * isupper()
157 * isxdigit()
158
159 .. index:: 
160         pair: データ型; IsAlNum()
161
162 IsAlNum() 関数
163 ==============
164
165 IsAlNum() 関数は文字または文字列であるかどうか検査します。
166
167 文法:
168
169 .. code-block:: ring
170
171         IsAlNum(値) ---> 値が数字または文字ならば 1 を、そうでなければ 0 です。
172
173 用例:
174
175 .. code-block:: ring
176
177         see isalnum("Hello") + nl +     # 1 を表示
178             isalnum("123456") + nl +    # 1 を表示
179             isalnum("ABCabc123") + nl + # 1 を表示
180             isalnum("How are you")      # 空白のため 0 を表示
181
182 .. index:: 
183         pair: データ型; IsAlpha()
184
185 IsAlpha() 関数
186 ==============
187
188 IsAlpha() 関数は文字または文字列であるかどうか検査します。
189
190 文法:
191
192 .. code-block:: ring
193
194         IsAlpha(値) ---> 値が文字ならば 1 を、そうでなければ 0 です。
195
196 用例:
197
198 .. code-block:: ring
199
200         see isalpha("Hello") + nl +     # 1 を表示
201             isalpha("123456") + nl +    # 0 を表示
202             isalpha("ABCabc123") + nl + # 0 を表示
203             isalpha("How are you")      # 0 を表示
204
205 .. index:: 
206         pair: データ型; IsCntrl()
207
208 IsCntrl() 関数
209 ==============
210
211 IsCntrl() 関数は文字または文字列であるかどうか検査します。
212
213 文法:
214
215 .. code-block:: ring
216
217         IsCntrl(値) ---> 値が制御文字 (表示不能) ならば 1 を、
218                             そうでなければ 0 です。
219
220 用例:
221
222 .. code-block:: ring
223
224         See iscntrl("hello") + nl +     # 0 を表示 
225             iscntrl(nl)                 # 1 を表示
226
227 .. index:: 
228         pair: データ型; IsDigit()
229
230 IsDigit() 関数
231 ==============
232
233 IsDigit() 関数は文字または文字列であるかどうか検査します。
234
235 文法:
236
237 .. code-block:: ring
238
239         IsDigit(値) ---> 値が数字ならば 1 を、そうでなければ 0 です。
240
241 用例:
242
243 .. code-block:: ring
244
245         see isdigit("0123456789") + nl +        # 1 を表示
246             isdigit("0123a")                    # 0 を表示
247
248 .. index:: 
249         pair: データ型; IsGraph()
250
251 IsGraph() 関数
252 ==============
253
254 IsGraph() 関数は文字または文字列であるかどうか検査します。
255
256 文法:
257
258 .. code-block:: ring
259
260         IsGraph(値)
261                 ---> 値が表示可能 (空白文字を除く) であれば 1 を、そうでなければ 0 を返します。
262
263 用例:
264
265 .. code-block:: ring
266
267         see isgraph("abcdef") + nl +    # 1 を表示
268             isgraph("abc def")          # 0 を表示
269
270
271 .. index:: 
272         pair: データ型; IsLower()
273
274 IsLower() 関数
275 ==============
276
277 IsLower() 関数は文字または文字列であるかどうか検査します。
278
279 文法:
280
281 .. code-block:: ring
282
283         IsLower(値) ---> 値が英数小文字ならば 1 を、そうでなければ 0 です。
284
285 用例:
286
287 .. code-block:: ring
288
289         see islower("abcDEF") + nl +    # 0 を表示
290             islower("ghi")              # 1 を表示
291
292
293 .. index:: 
294         pair: データ型; IsPrint()
295
296 IsPrint() 関数
297 ==============
298
299 IsPrint() 関数は文字または文字列であるかどうか検査します。
300
301 文法:
302
303 .. code-block:: ring
304
305         IsPrint(値) ---> 値が表示可能であれば 1 を、そうでなければ 0 です。
306
307 用例:
308
309 .. code-block:: ring
310
311         see isprint("Hello") + nl +             # 1 を表示
312             isprint("Nice to see you") + nl +   # 1 を表示
313             isprint(nl)                         # 0 を表示
314
315 .. index:: 
316         pair: データ型; IsPunct()
317
318 IsPunct() 関数
319 ==============
320
321 IsPunct() 関数は文字または文字列であるかどうか検査します。
322
323 文法:
324
325 .. code-block:: ring
326
327         IsPunct(値) ---> 値が句読記号文字ならば 1 を、そうでなければ 0 です。
328
329 用例:
330
331 .. code-block:: ring
332
333         see ispunct("hello") + nl +     # 0 を表示
334             ispunct(",")                # 1 を表示
335
336 .. index:: 
337         pair: データ型; IsSpace()
338
339 IsSpace() 関数
340 ==============
341
342 IsSpace() 関数は文字または文字列であるかどうか検査します。 
343
344 文法:
345
346 .. code-block:: ring
347
348         IsSpace(値) ---> 値が空白文字ならば 1 を、そうでなければ 0 です。
349
350 用例:
351
352 .. code-block:: ring
353
354         see isspace("   ") + nl +       # 1 を表示
355             isspace("test")             # 0 を表示
356
357
358 .. index:: 
359         pair: データ型; IsUpper()
360
361 IsUpper() 関数
362 ==============
363
364 IsUpper() 関数は文字または文字列であるかどうか検査します。
365
366 文法:
367
368 .. code-block:: ring
369
370         IsUpper(値) ---> 値が英数大文字ならば 1 を、そうでなければ 0 です。
371
372 用例:
373
374 .. code-block:: ring
375
376         see isupper("welcome") + nl +    # 0 を表示 
377             isupper("WELCOME")           # 1 を表示
378
379
380 .. index:: 
381         pair: データ型; IsXdigit()
382
383 IsXdigit() 関数
384 ===============
385
386 IsXdigit() 関数は文字または文字列であるかどうか検査します。
387
388 文法:
389
390 .. code-block:: ring
391
392         IsXdigit(値) ---> 値が十六進数文字ならば 1 をそうでなければ 0 です。
393
394 用例:
395
396 .. code-block:: ring
397
398         see isxdigit("0123456789abcdef") + nl +  # 1 を表示
399             isxdigit("123z")                     # 0 を表示
400
401
402 .. index:: 
403         pair: データ型; 変換
404
405 変換
406 ====
407
408 文字列と数値間の変換用関数です。
409
410 * number()
411 * string()
412 * ascii()
413 * char()
414 * hex()
415 * dec()
416 * str2hex()
417 * hex2str()
418
419 .. index:: 
420         pair: データ型; Number()
421
422 Number() 関数
423 =============
424
425 Number() 関数または + 演算子は文字列を数値へ変換します。
426
427 文法:
428
429 .. code-block:: ring
430
431         Number(文字列) ---> 数値
432         0 + 文字列     ---> 数値
433
434 用例:
435
436 .. code-block:: ring
437
438         see number("5") + 5 + nl        # 1 を表示0
439         see 0 + "10" + 2                # 12 を表示  
440
441 .. index:: 
442         pair: データ型; String()
443
444 String() 関数
445 =============
446
447 String() 関数または + 演算子は数値を文字列へ変換します。
448
449 文法:
450
451 .. code-block:: ring
452
453         String(数値) ---> 文字列
454         "" + 数値    ---> 文字列
455
456 用例:
457
458 .. code-block:: ring
459
460         see string(5) + 5 + nl          # 55 を表示
461         see "" + 10 + 2                 # 102 を表示
462
463 .. index:: 
464         pair: データ型; Ascii()
465
466 Ascii() 関数
467 ============
468
469 Ascii() 関数は文字から ASCII コードを取得します。
470
471 文法:
472
473 .. code-block:: ring
474
475         Ascii(文字) ---> ASCII コード
476
477 用例:
478
479 .. code-block:: ring
480
481         See ascii("m") + nl +   # 109 を表示
482             ascii("M")          # 77 を表示
483
484 .. index:: 
485         pair: データ型; Char()
486
487 Char() 関数
488 ===========
489
490 Char() 関数は ASCII コードを文字へ変換できます
491
492 文法:
493
494 .. code-block:: ring
495
496         Char(ASCII コード) ---> 文字
497
498 用例:
499
500 .. code-block:: ring
501
502         See char(109) + nl +    # m を表示
503             char(77)            # M を表示
504
505
506 .. index:: 
507         pair: データ型; Hex()
508
509 Hex() 関数
510 ==========
511
512 Hex() 関数は十進数から十六進数へ変換します。
513
514 文法:
515
516 .. code-block:: ring
517
518         Hex(十進数) ---> 十六進数
519
520 用例:
521
522 .. code-block:: ring
523
524         See hex(10) + nl +      # a を表示
525             hex(200)            # c8 を表示
526
527 .. index:: 
528         pair: データ型; Dec()
529
530 Dec() 関数
531 ==========
532
533 Dec() 関数は十六進数から十進数へ変換します。
534
535 文法:
536
537 .. code-block:: ring
538
539         Dec(十六進数) ---> 十進数
540
541 用例:
542
543 .. code-block:: ring
544
545         See dec("a") + nl +     # 10 を表示
546             dec("c8")           # 200 を表示
547
548 .. index:: 
549         pair: データ型; Str2Hex()
550
551 Str2hex() 関数
552 ==============
553
554 Str2hex() 関数は文字列の文字を十六進数文字へ変換します。
555
556 文法:
557
558 .. code-block:: ring
559
560         Str2hex(文字列) ---> 十六進数文字列
561
562 用例:
563
564 .. code-block:: ring
565
566         See str2hex("hello")    # 68656c6c6f を表示
567
568 .. index:: 
569         pair: データ型; Hex2str()
570
571 Hex2str() 関数
572 ==============
573
574 Hex2str() 関数は十六進数文字を文字列へ変換します。
575
576 文法:
577
578 .. code-block:: ring
579
580         Hex2Str(十六進数文字列) ---> 文字列
581
582 用例:
583
584 .. code-block:: ring
585
586         See hex2str("68656c6c6f")       # hello を表示