Google

Go to the first, previous, next, last section, table of contents.


open_file, close_file, get_line, get_byte, put_byte, purge_stdin

open_file("filename"[,"mode"])
:: filename ¤ò¥ª¡¼¥×¥ó¤¹¤ë.
close_file(num)
:: ¼±ÊÌ»Ò num ¤Î¥Õ¥¡¥¤¥ë¤ò¥¯¥í¡¼¥º¤¹¤ë.
get_line([num])
:: ¼±ÊÌ»Ò num ¤Î¥Õ¥¡¥¤¥ë¤«¤é 1 ¹ÔÆÉ¤à.
get_byte(num)
:: ¼±ÊÌ»Ò num ¤Î¥Õ¥¡¥¤¥ë¤«¤é 1 ¥Ð¥¤¥ÈÆÉ¤à.
put_byte(num,c)
:: ¼±ÊÌ»Ò num ¤Î¥Õ¥¡¥¤¥ë¤Ë 1 ¥Ð¥¤¥È c ¤ò½ñ¤¯.
purge_stdin()
purge_stdin()
:: ɸ½àÆþÎϤΥХåե¡¤ò¥¯¥ê¥¢¤¹¤ë.
return
open_file() : À°¿ô (¼±ÊÌ»Ò); close_file() : 1; get_line() : ʸ»úÎó; get_byte(), put_byte() : À°¿ô
filename
¥Õ¥¡¥¤¥ë̾ (¥Ñ¥¹Ì¾)
mode
ʸ»úÎó
num
ÈóÉéÀ°¿ô (¥Õ¥¡¥¤¥ë¼±ÊÌ»Ò)
  • open_file() ¤Ï¥Õ¥¡¥¤¥ë¤ò¥ª¡¼¥×¥ó¤¹¤ë. mode »ØÄ꤬ ¤Ê¤¤¾ì¹çÆÉ¤ß½Ð¤·ÍÑ, mode »ØÄ꤬¤¢¤ë¾ì¹ç¤Ë¤Ï, C ¤Îɸ½àÆþ½ÐÎÏ ´Ø¿ô fopen() ¤ËÂФ¹¤ë¥â¡¼¥É»ØÄê¤È¤ß¤Ê¤¹. ¤¿¤È¤¨¤Ð¿·µ¬½ñ¤­¹þ¤ß ÍѤξì¹ç "w", ËöÈøÄɲäξì¹ç "a" ¤Ê¤É. À®¸ù¤·¤¿¾ì¹ç, ¥Õ¥¡¥¤¥ë¼±Ê̻ҤȤ·¤ÆÈóÉéÀ°¿ô¤òÊÖ¤¹. ¼ºÇԤξì¹ç¥¨¥é¡¼¤È¤Ê¤ë. ÉÔÍפˤʤä¿¥Õ¥¡¥¤¥ë¤Ï close_file() ¤Ç¥¯¥í¡¼¥º¤¹¤ë.
  • get_line() ¤Ï¸½ºß¥ª¡¼¥×¥ó¤·¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¤«¤é 1 ¹ÔÆÉ¤ß, ʸ»úÎó¤È¤·¤ÆÊÖ¤¹. °ú¿ô¤¬¤Ê¤¤¾ì¹ç, ɸ½àÆþÎϤ«¤é 1 ¹ÔÆÉ¤à.
  • get_byte() ¤Ï¸½ºß¥ª¡¼¥×¥ó¤·¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¤«¤é 1 ¥Ð¥¤¥ÈÆÉ¤ß À°¿ô¤È¤·¤ÆÊÖ¤¹.
  • put_byte() ¤Ï¸½ºß¥ª¡¼¥×¥ó¤·¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¤Ë 1 ¥Ð¥¤¥È½ñ¤­, ¤½¤Î¥Ð¥¤¥È¤òÀ°¿ô¤È¤·¤ÆÊÖ¤¹.
  • ¥Õ¥¡¥¤¥ë¤Î½ª¤ê¤Þ¤ÇÆÉ¤ó¤À¸å¤Ë get_line() ¤¬¸Æ¤Ð¤ì¤¿¾ì¹ç, À°¿ô¤Î 0 ¤òÊÖ¤¹.
  • ÆÉ¤ß½Ð¤·¤¿Ê¸»úÎó¤Ï, ɬÍפ¬¤¢¤ì¤Ð sub_str() ¤Ê¤É¤Îʸ»úÎó½èÍý ´Ø¿ô¤Ç²Ã¹©¤·¤¿¤Î¤Á eval_str() ¤Ë¤è¤êÆâÉô·Á¼°¤ËÊÑ´¹¤Ç¤­¤ë.
  • purge_stdin() ¤Ï, ɸ½àÆþÎϥХåե¡¤ò¶õ¤Ë¤¹¤ë. ´Ø¿ôÆâ¤Ç get_line() ¤Ë¤è¤êɸ½àÆþÎϤ«¤éʸ»úÎó¤ò¼õ¤±¼è¤ë¾ì¹ç, ´û¤Ë¥Ð¥Ã¥Õ¥¡Æâ¤Ë¸ºß¤¹¤ëʸ»úÎó¤Ë¤è¤ë¸íưºî¤òËɤ°¤¿¤á¤Ë¤¢¤é¤«¤¸¤á ¸Æ¤Ó½Ð¤¹.
[185] Id = open_file("test");
0
[186] get_line(Id);
12345

[187] get_line(Id);
67890

[188] get_line(Id);
0
[189] type(@@);
0
[190] close_file(Id);
1
[191] open_file("test");
1
[192] get_line(1);   
12345

[193] get_byte(1);
54                   /* the ASCII code of '6' */
[194] get_line(1);
7890                 /* the rest of the last line */
[195] def test() { return get_line(); }
[196] def test1() { purge_stdin(); return get_line(); }
[197] test();
                     /* a remaining newline character has been read */
                     /* returns immediately */
[198] test1();
123;                 /* input from a keyboard */
123;                 /* returned value */

[199] 

»²¾È
section eval_str, section str_len, str_chr, sub_str.


Go to the first, previous, next, last section, table of contents.