File Handle routine, EOF halts execution... - 26/11/10 07:20 AM
I've done some testing and when using $fread and it encounters the end of file, the entire execution of the script terminates w/o warning.
alias eoftest { /timer.fclose 1 1 /fclose mirc.ini /fopen mirc.ini mirc.ini while (!$feof && !$ferr) { var %line = $fread(mirc.ini) } /fclose mirc.ini /timer.fclose off }
alias eoftest { /timer.fclose 1 1 /fclose mirc.ini /fopen mirc.ini sjis-0208-1997-std.txt var %i = 0 while (!$feof && !$ferr) { var %line = $fread(mirc.ini) inc %i } echo -s ~ Line: %i || Lines: $lines(sjis-0208-1997-std.txt) /fclose mirc.ini /timer.fclose off }
//echo -a $os $version $md5($mircexe,2) $file($mircexe).sig $script(0) $dll(0) $com(0)
#_DEFAULT.PROPERTIES OFF [start] [CONST] SJISSPEC=$mircdir $+ sjis-0208-1997-std.txt #_DEFAULT.PROPERTIES END ALIAS __SJISspec { return $readini($script,CONST,SJISSPEC) } ALIAS DEC2HEX { var %pad = $len($base($$1,10,16)) if (2 \\ %pad) { %pad = %pad + 1 } if ($isid) { return $base($$1,10,16,%pad) } elseif ($1 isnum) { echo -aspe 0x $+ $base($$1,10,16,%pad) } } ALIAS HEX2DEC { if ($left($1,2) == 0x) || ($left($1,2) == U+) { tokenize 32 $right($1,-2) } if ($isid) { return $base($$1,16,10,1) } else { echo -aspe $base($$1,16,10,1) } } alias import_sjis { if ($hget(sjis)) { /.hfree sjis } /hmake sjis 10000 /.fopen sjis $qt($__SJISspec) while (!$fopen(sjis).eof && !$ferr) { tokenize 09 $fread(sjis) if ($0 > 2) { var %sjis = $1, %utfc = $2, %desc = $3- } else { var %sjis = $1, %utfc, %desc = $2- } if ($+($#,*) iswm %sjis) continue if ($hex2dec(%sjis) < 128) continue if (<doublebytes> isin %desc) { /hadd sjis $hex2dec(%sjis) <doublebytes> } elseif (<cjk> isin %desc) { /hadd sjis $hex2dec(%sjis) $hex2dec(%utfc) $chr($hex2dec(%utfc)) } elseif ($left(%utfc,2) == U+) { /hadd sjis $hex2dec(%sjis) $hex2dec(%utfc) $chr($hex2dec(%utfc)) } } :error /fclose sjis }
alias $myalias { echo -a $!MyAlias Triggered return $!MyAlias Triggered } alias MyAliasTest { echo -a $!MyAlias: $MyAlias echo -a Trying /$MyAlias: $myAlias echo -a Trying /$$MyAlias: $$MyAlias echo -a $!$MyAlias: $$MyAlias }
alias t1 { echo -a 1 t2 $1- echo -a 3 } alias t2 { echo -a 2 echo -a $$1- }
alias t1 { echo -a 1 echo -a : $t2($1-) echo -a 3 } alias t2 { if ($1) { return $1- } }
alias t1 { echo -a 1 echo -a 1- $t2($1-) echo -a 3 } alias t2 { if (!$1) { halt } return $1- }
#_DEFAULT.PROPERTIES OFF [start] [CONST] SJISSPEC=$mircdir $+ sjis-0208-1997-std.txt #_DEFAULT.PROPERTIES END ALIAS __SJISspec { return $readini($script,CONST,SJISSPEC) } ALIAS DEC2HEX { var %pad = $len($base($$1,10,16)) if (2 \\ %pad) { %pad = %pad + 1 } if ($isid) { return $base($$1,10,16,%pad) } elseif ($1 isnum) { echo -aspe 0x $+ $base($$1,10,16,%pad) } } ALIAS HEX2DEC { if ($left($1,2) == 0x) || ($left($1,2) == U+) { tokenize 32 $right($1,-2) } if ($isid) { return $base($$1,16,10,1) } else { echo -aspe $base($$1,16,10,1) } } alias import_sjis { if ($hget(sjis)) hfree sjis hmake sjis 10000 fopen sjis $qt($__SJISspec) var %z while (!$fopen(sjis).eof && !$ferr) { tokenize 09 $fread(sjis) inc -s %z if ($0 > 2) { var %sjis = $1, %utfc = $2, %desc = $3- } else { var %sjis = $1, %utfc, %desc = $2- } ; if ($+($#,*) iswm %sjis) continue if ($hex2dec(%sjis) < 128) continue echo -s %desc - %sjis - %utfc - $feof - $ferr - if (<doublebytes> isin %desc) { /hadd sjis $hex2dec(%sjis) <doublebytes> } elseif (<cjk> isin %desc) { /hadd sjis $hex2dec(%sjis) $hex2dec(%utfc) $chr($hex2dec(%utfc)) } elseif ($left(%utfc,2) == U+) { /hadd sjis $hex2dec(%sjis) $hex2dec(%utfc) $chr($hex2dec(%utfc)) } } :error if ($error) echo -s Error : $error fclose sjis }
/o mode # +o $$1
/kb ialban $1 | kick # $1 /ialban mode # +b $$address($1, 2)
//echo -a 1 ; $$+($$chr(32),$$str($chr(32),5)) ; | /echo -a 2 ; $null ; | /echo -a ; $$null ;
1 ; ; 2 ; ;