, HomeLisp-, . , , :

  , ;

  , .

IBM () . . , .

( ). () , , . .

C - . , , ASCII, 31. ASCII 13 10. ( DOS/Windows; UNIX/LINUX 10). _INPUT, _OUTPUT _APPEND. / / . filGetLine filPutLine . . , n- , (n-1) .

BINARY_READ, BINARY_WRITE BINARY_READ_WRITE. , , . . , / . - , /. , , , .

, , . .

, HomeLisp _TEXT_ARRAY ( ). . , . . _TEXT_ARRAY .

, . FILOPEN. "" ( ). . , FILOPEN FIXED-, . - FILE. ( ).

: . . , , , , .

. , , . , nFil homelisp.ini ( ). nFil, , . FIL

HomeLisp- :


-
  FILCLOSE 1 1-FILE , . - .
  FILEOF 1 1-FILE (T) ,
  FILEXISTP 1 1-STRING , . ( HIDDEN, SYSTEM READ-ONLY ), T. Nil.
  FILGETBLO 2 1-FILE; 2-BLOB , _BINARY_READ _BINARY_READ_WRITE, BLOB,
  FILGETLINE 1 1-FILE INPUT . .
  FILGETSTRCOUNT 1 1-FILE , TEXT_ARRAY.
  FILLOC 1 1-FILE , . _BINARY_WRITE _BINARY_READ_WRITE
  FILLOF 1 1-FILE
  FILOPEN 3 1-; 2-STRING; 3-FIXED , . . - . FILE.
  FILPUTBLO 2 1-FILE; 2-BLOB , , (BLOB), . _BINARY_WRITE _BINARY_READ_WRITE
  FILPUTLINE 2 1-FILE; 2-STRING , , , . _OUTPUT _APPEND
  FILSEEK 2 1-FILE; 2-FIXED , , . _BINARY_WRITE _BINARY_READ_WRITE
FILCLOSE  

FILCLOSE FILE . - . , , . , . , T.

filClose:

(filClose 'fi)

filClose:   -  
==> ERRSTATE

(filOpen 'fi "c:\config.sys" _INPUT)

==> fi

(proplist 'fi)

==> (FILE FName "c:\config.sys" FHandle 2 FMode 0)

(filClose 'fi)

==> T

(proplist 'fi)

==> NIL

. , .

FILEOF  

FILEOF FILE , . T, Nil.

filEOF:


(prog nil (filOpen 'fi "c:\config.sys" _INPUT)

            @Beg  (cond ((filEOF 'fi) (go @Exit)))

                  (prints (filGetLine 'fi))

                  (go @Beg)

            @Exit (filClose 'fi)

                  (return 'ok) 
           
)

device=C:\WINDOWS\COMMAND\display.sys con=(ega,,1)Country=007,866,
C:\WINDOWS\COMMAND\country.sysShell=c:\command.com /P /E:4096

==> ok

: , .

_BINARY_READ, filEOF Nil , filGetBlo , BLOB. :

(filOpen 'fi "c:\config.sys" _BINARY_READ)

==> fi

(filLOF 'fi)

==> 133

(bloCreate 'buf 100)

==> buf

(filGetBlo 'fi 'buf)

==> T

(filEOF 'fi)

==> NIL

(filGetBlo 'fi 'buf)

==> T

(filEOF 'fi)

==> T

(bloDump* 'buf)

00000001 | 53 68 65 6C 6C 3D 63 3A | 5C 63 6F 6D 6D 61 6E 64 | Shell=c:\command |
00000017 | 2E 63 6F 6D 20 2F 50 20 | 2F 45 3A 34 30 39 36 0D | .com /P /E:4096. |
00000033 | 0A 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 | ................ |
00000049 | 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 | ................ |
00000065 | 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 | ................ |
00000081 | 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 | ................ |
00000097 | 00 00 00                |                         | ...              |

==> T

Config.sys . (133 ). 100- 100 , filEOF. Nil, . 100 . , filGetBlo, filEOF T. , , 33 . . filLOF filLO.

, , (_OUTPUT, _APPEND) filEOF T.

FILEXISTP  

FILEXISTP STRING , . : HIDDEN, SYSTEM, READ-ONLY. , T, Nil.

filExistp:


(filExistp "c:\aaa.aaa")

==> NIL

(filExistp "c:\IO.SYS")

==> T

aaa.aaa C:, IO.SYS - . filExistp . .

FILGETBLO  

FILGETBLO - BLOBa. , , BLOB, . , T, Nil.

, , : _BINARY_READ _BINARY_READ_WRITE. - .

FILGETBLO:

(bloCreate 'buf 250)

==> buf

(filOpen 'fi "homelispide.exe" _BINARY_READ)

==> fi

(filGetBlo 'fi 'buf)

==> T

(bloDump* 'buf)

00000001 | 4D 5A 90 00 03 00 00 00 | 04 00 00 00 FF FF 00 00 | MZ........... |
00000017 | B8 00 00 00 00 00 00 00 | 40 00 00 00 00 00 00 00 | .......@....... |
00000033 | 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 | ................ |
00000049 | 00 00 00 00 00 00 00 00 | 00 00 00 00 C8 00 00 00 | ............... |
00000065 | 0E 1F BA 0E 00 B4 09 CD | 21 B8 01 4C CD 21 54 68 | ....!.L!Th |
00000081 | 69 73 20 70 72 6F 67 72 | 61 6D 20 63 61 6E 6E 6F | is program canno |
00000097 | 74 20 62 65 20 72 75 6E | 20 69 6E 20 44 4F 53 20 | t be run in DOS  |
00000113 | 6D 6F 64 65 2E 0D 0D 0A | 24 00 00 00 00 00 00 00 | mode....$....... |
00000129 | 4B 9C C7 DA 0F FD A9 89 | 0F FD A9 89 0F FD A9 89 | K... |
00000145 | 8C E1 A7 89 0E FD A9 89 | 40 DF A0 89 2A FD A9 89 | ᧉ.@ߠ* |
00000161 | 0B DE A4 89 0E FD A9 89 | 52 69 63 68 0F FD A9 89 | .ޤ.Rich. |
00000177 | 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 | ................ |
00000193 | 00 00 00 00 00 00 00 00 | 50 45 00 00 4C 01 03 00 | ........PE..L... |
00000209 | 73 DD 3C 49 00 00 00 00 | 00 00 00 00 E0 00 0F 01 | s T

BLOB 250 , "homelispide.exe" , BLOB 250 . BLOB . EXE- .

FILGETLINE  

FILGETLINE - , _INPUT _TEXT_ARRAY . " " - Nil.

_TEXT_ARRAY, - . - Nil. , , . , FILGETLINE , _TEXT_ARRAY, , , , .

FILGETLINE :

(filOpen 'fi "c:\config.sys" _INPUT)

==> fi

(filGetLine 'fi)

==>  "device=C:\WINDOWS\COMMAND\display.sys con=(ega,,1)"

(filGetLine 'fi)

==>  "Country=007,866,C:\WINDOWS\COMMAND\country.sys"

(filGetLine 'fi)

==>  "Shell=c:\command.com /P /E:4096"

(filGetLine 'fi)

==>  "Files=120"

(filGetLine 'fi)

==>  "Buffers=120"

(filGetLine 'fi)

==>  NIL

(filGetLine 'fi)

==>  NIL

(filEOF 'fi)

==>  T

, "c:\config.sys" _INPUT. . , Nil. filEOF , .

, _TEXT_ARRAY:

(filOpen 'fi "c:\config.sys" _TEXT_ARRAY)

==>  fi

(filGetLine 'fi 3)

==>  "Shell=c:\command.com /P /E:4096"

(filGetLine 'fi)

==>  "Files=120"

(filGetLine 'fi)

==>  "Buffers=12"

(filGetLine 'fi)

==>  NIL

(filGetLine 'fi 1)

==>  "device=C:\WINDOWS\COMMAND\display.sys con=(ega,,1)"

. . ( ). Nil, . .

FILGETSTRCOUNT  

FILGETSTRCOUNT - , _TEXT_ARRAY. ( ). FILGETSTRCOUNT:

(filOpen 'fi "c:\config.sys" _TEXT_ARRAY)

==>  fi

(filGetStrCount 'fi 3)

==>  5
FILLOC  

FILLOC - , _BINARY_READ _BINARY_READ_WRITE. ( , c ).

FILLOC:

(filOpen 'fi "c:\config.sys" _BINARY_READ)

==>  fi

(filLoc 'fi)

==>  1

(bloCreate 'buf 6)

==>  buf

(filGetBlo 'fi 'buf)

==>  T

(filLoc 'fi)

==>  7

, . , .

FILLOF  

FILLOF - . .

FILLOF:

(filOpen 'fi "c:\config.sys" _INPUT)

==>  fi

(filLof 'fi)

==>  155

, .

, filLof .

(filOpen 'fo "o.o" _OUTPUT)

==>  fo

(filLof 'fo)

==>  0

(filPutLine 'fo "QWERTY")

==>  T

(filPutLine 'fo "QWERTY")

==>  T

(filLof 'fo)

==>  16

6 . &H0D, &H0A, 16 .

FILOPEN  

FILOPEN : , FIXED - . "" (.. ). - STRING. : , , . .\, ..\.

, :

( )
0 _INPUT , . , 53.
1 _OUTPUT , . , . , .
2 _APPEND , . , . , . .
3 _BINARY_READ , . , .
4 _BINARY_WRITE , . , .
5 _BINARY_READ_WRITE , . , .
6 _TEXT_ARRAY . , .

autoexec.bat:

(filOpen 'fi "c:\autoexec.bat" _INPUT)

==> fi

(filGetLine 'fi)

==> "set TEMP=C:\TEMP"

(filGetLine 'fi)

==> "set TMP=C:\TEMP"

(proplist 'fi)

==> (FILE FName "c:\autoexec.bat" FHandle 2 FMode 0)

(filClose 'fi)

==> T

(proplist 'fi)

==> NIL

fi autoexec.bat. . fi. FILE, (FMODE). . fi .

, :


(filOpen 'fi "c:\autoexec.bat" _BINARY_READ)

==> fi

(proplist 'fi)

==> (FILE FName "c:\autoexec.bat" FHandle 2 FMode 3)

(filLOF 'fi)

==> 874

(bloCreate 'buf 874)

==> buf

(filGetBlob 'fi 'buf)

==> T

(bloDump* 'buf)

00000001 | 0D 0A 73 65 74 20 54 45 | 4D 50 3D 43 3A 5C 54 45 | ..set TEMP=C:\TE |
00000017 | 4D 50 0D 0A 0D 0A 73 65 | 74 20 54 4D 50 3D 43 3A | MP....set TMP=C: |
00000033 | 5C 54 45 4D 50 0D 0A 0D | 0A 53 45 54 20 50 41 54 | \TEMP....SET PAT |
00000049 | 48 3D 43 3A 5C 57 49 4E | 44 4F 57 53 3B 43 3A 5C | H=C:\WINDOWS;C:\ |
00000065 | 57 49 4E 44 4F 57 53 5C | 43 4F 4D 4D 41 4E 44 3B | WINDOWS\COMMAND; |
00000081 | 22 44 3A 5C 50 79 74 68 | 6F 6E 32 34 5C 2E 22 3B | "D:\Python24\."; |
00000097 | 45 3A 5C 41 52 43 48 3B | 45 3A 5C 44 4E 3B 44 3A | E:\ARCH;E:\DN;D: |
00000113 | 5C 53 45 52 56 3B 44 3A | 5C 53 59 53 3B 45 3A 5C | \SERV;D:\SYS;E:\ |
00000129 | 54 42 3B 45 3A 5C 42 50 | 5C 42 49 4E 3B 43 3A 5C | TB;E:\BP\BIN;C:\ |
00000145 | 50 52 4F 47 52 41 7E 31 | 5C 42 4F 52 4C 41 4E 44 | PROGRA~1\BORLAND |
00000161 | 5C 44 45 4C 50 48 49 34 | 5C 42 49 4E 3B 43 3A 5C | \DELPHI4\BIN;C:\ |
00000177 | 50 52 4F 47 52 41 7E 31 | 5C 42 4F 52 4C 41 4E 44 | PROGRA~1\BORLAND |
00000193 | 5C 56 42 52 4F 4B 45 52 | 5C 42 49 4E 3B 43 3A 5C | \VBROKER\BIN;C:\ |
00000209 | 50 52 4F 47 52 41 7E 31 | 5C 42 4F 52 4C 41 4E 44 | PROGRA~1\BORLAND |
00000225 | 5C 56 42 52 4F 4B 45 52 | 5C 4A 52 45 5C 42 49 4E | \VBROKER\JRE\BIN |
00000241 | 3B 43 3A 5C 50 42 57 49 | 4E 37 30 5C 42 49 4E 3B | ;C:\PBWIN70\BIN; |
00000257 | 22 43 3A 5C 50 72 6F 67 | 72 61 6D 20 46 69 6C 65 | "C:\Program File |
00000273 | 73 5C 53 74 65 65 6C 20 | 42 61 6E 6B 20 43 6F 6D | s\Steel Bank Com |
00000289 | 6D 6F 6E 20 4C 69 73 70 | 5C 31 2E 30 5C 22 0D 0A | mon Lisp\1.0\".. |
00000305 | 0D 0A 72 65 6D 20 53 45 | 54 20 50 41 54 48 3D 25 | ..rem SET PATH=% |
00000321 | 50 41 54 48 25 3B 22 43 | 3A 5C 50 52 4F 47 52 41 | PATH%;"C:\PROGRA |
00000337 | 4D 46 49 4C 45 53 5C 4D | 54 53 22 3B 43 3A 5C 50 | MFILES\MTS";C:\P |
00000353 | 52 4F 47 52 41 7E 31 5C | 42 4F 52 4C 41 4E 44 5C | ROGRA~1\BORLAND\ |
00000369 | 43 42 55 49 4C 44 7E 31 | 5C 42 49 4E 3B 0D 0A 0D | CBUILD~1\BIN;... |
00000385 | 0A 53 45 54 20 43 4C 41 | 53 53 50 41 54 48 3D 43 | .SET CLASSPATH=C |
00000401 | 3A 5C 50 52 4F 47 52 41 | 7E 31 5C 42 4F 52 4C 41 | :\PROGRA~1\BORLA |
00000417 | 4E 44 5C 56 42 52 4F 4B | 45 52 5C 6C 69 62 5C 76 | ND\VBROKER\lib\v |
00000433 | 62 63 70 70 2E 6A 61 72 | 0D 0A 0D 0A 72 65 6D 20 | bcpp.jar....rem  |
00000449 | 2D 20 42 79 20 57 69 6E | 64 6F 77 73 20 53 65 74 | - By Windows Set |
00000465 | 75 70 20 2D 20 65 72 61 | 73 65 20 63 3A 5C 77 69 | up - erase c:\wi |
00000481 | 6E 64 6F 77 73 5C 2A 2E | 74 6D 70 20 3E 20 6E 75 | ndows\*.tmp > nu |
00000497 | 6C 0D 0A 0D 0A 72 65 6D | 20 2D 20 4C 69 6E 65 73 | l....rem - Lines |
00000513 | 20 61 64 64 65 64 20 62 | 79 20 56 69 73 75 61 6C |  added by Visual |
00000529 | 20 46 6F 72 74 72 61 6E | 20 36 2E 30 2E 30 20 53 |  Fortran 6.0.0 S |
00000545 | 65 74 75 70 20 6F 6E 20 | 35 2D 31 30 2D 32 30 30 | etup on 5-10-200 |
00000561 | 35 0D 0A 43 41 4C 4C 20 | 43 3A 5C 50 52 4F 47 52 | 5..CALL C:\PROGR |
00000577 | 41 7E 31 5C 4D 49 43 52 | 4F 53 7E 31 5C 44 46 39 | A~1\MICROS~1\DF9 |
00000593 | 38 5C 42 49 4E 5C 44 46 | 56 41 52 53 2E 42 41 54 | 8\BIN\DFVARS.BAT |
00000609 | 20 41 55 54 4F 45 58 45 | 43 0D 0A 72 65 6D 20 2D |  AUTOEXEC..rem - |
00000625 | 20 45 6E 64 20 6F 66 20 | 6C 69 6E 65 73 20 61 64 |  End of lines ad |
00000641 | 64 65 64 20 62 79 20 56 | 69 73 75 61 6C 20 46 6F | ded by Visual Fo |
00000657 | 72 74 72 61 6E 20 36 2E | 30 2E 30 20 53 65 74 75 | rtran 6.0.0 Setu |
00000673 | 70 0D 0A 20 0D 0A 72 65 | 6D 20 50 41 54 48 3D 25 | p.. ..rem PATH=% |
00000689 | 50 41 54 48 25 3B 22 43 | 3A 5C 50 72 6F 67 72 61 | PATH%;"C:\Progra |
00000705 | 6D 46 69 6C 65 73 5C 4D | 74 73 22 0D 0A 0D 0A 6D | mFiles\Mts"....m |
00000721 | 6F 64 65 20 63 6F 6E 20 | 63 6F 64 65 70 61 67 65 | ode con codepage |
00000737 | 20 70 72 65 70 61 72 65 | 3D 28 28 38 36 36 29 20 |  prepare=((866)  |
00000753 | 43 3A 5C 57 49 4E 44 4F | 57 53 5C 43 4F 4D 4D 41 | C:\WINDOWS\COMMA |
00000769 | 4E 44 5C 65 67 61 33 2E | 63 70 69 29 0D 0A 0D 0A | ND\ega3.cpi).... |
00000785 | 6D 6F 64 65 20 63 6F 6E | 20 63 6F 64 65 70 61 67 | mode con codepag |
00000801 | 65 20 73 65 6C 65 63 74 | 3D 38 36 36 0D 0A 53 45 | e select=866..SE |
00000817 | 54 20 53 42 43 4C 5F 48 | 4F 4D 45 3D 43 3A 5C 50 | T SBCL_HOME=C:\P |
00000833 | 72 6F 67 72 61 6D 20 46 | 69 6C 65 73 5C 53 74 65 | rogram Files\Ste |
00000849 | 65 6C 20 42 61 6E 6B 20 | 43 6F 6D 6D 6F 6E 20 4C | el Bank Common L |
00000865 | 69 73 70 5C 31 2E 30 5C | 0D 0A                   | isp\1.0\..       |

==> T

(filClose 'fi)

==> T

(bloDestroy 'buf)

==> T

. fi _BINARY_READ. filLOF . , . . , , .

FILPUTBLO  

FILPUTBLO - ( _BINARY_WRITE _BINARY_READ_WRITE BLOB. BLOB .

FILPUTBLO:

(filOpen 'fo "o.o" _BINARY_WRITE)

==>  fo

(bloCreate 'buf 256)

==>  buf

(for i 0 255 (
              (fix2blo 'buf    // BLOB
                       i       //  
                       (+ i 1) //  
                       1       //  
              ) 
             ) 
)

==>  255

(filPutBlo 'fo 'buf)

==>  T

(bloDestroy 'buf)

==>  T

(filClose 'fo)

==>  T

(filOpen 'fi "o.o" _BINARY_READ)

==>  fi

(bloCreate 'buf 256)

==>  buf

(filGetBlo 'fi 'buf)

==>  T

(bloDump* 'buf)

00000001 | 00 01 02 03 04 05 06 07 | 08 09 0A 0B 0C 0D 0E 0F | ................ |
00000017 | 10 11 12 13 14 15 16 17 | 18 19 1A 1B 1C 1D 1E 1F | ............... |
00000033 | 20 21 22 23 24 25 26 27 | 28 29 2A 2B 2C 2D 2E 2F |  !"#$%&'()*+,-./ |
00000049 | 30 31 32 33 34 35 36 37 | 38 39 3A 3B 3C 3D 3E 3F | 0123456789:;<=>? |
00000065 | 40 41 42 43 44 45 46 47 | 48 49 4A 4B 4C 4D 4E 4F | @ABCDEFGHIJKLMNO |
00000081 | 50 51 52 53 54 55 56 57 | 58 59 5A 5B 5C 5D 5E 5F | PQRSTUVWXYZ[\]^_ |
00000097 | 60 61 62 63 64 65 66 67 | 68 69 6A 6B 6C 6D 6E 6F | `abcdefghijklmno |
00000113 | 70 71 72 73 74 75 76 77 | 78 79 7A 7B 7C 7D 7E 7F | pqrstuvwxyz{|}~ |
00000129 | 80 81 82 83 84 85 86 87 | 88 89 8A 8B 8C 8D 8E 8F |  |
00000145 | 90 91 92 93 94 95 96 97 | 98 99 9A 9B 9C 9D 9E 9F |  |
00000161 | A0 A1 A2 A3 A4 A5 A6 A7 | A8 A9 AA AB AC AD AE AF |  |
00000177 | B0 B1 B2 B3 B4 B5 B6 B7 | B8 B9 BA BB BC BD BE BF |  |
00000193 | C0 C1 C2 C3 C4 C5 C6 C7 | C8 C9 CA CB CC CD CE CF |  |
00000209 | D0 D1 D2 D3 D4 D5 D6 D7 | D8 D9 DA DB DC DD DE DF |  |
00000225 | E0 E1 E2 E3 E4 E5 E6 E7 | E8 E9 EA EB EC ED EE EF |  |
00000241 | F0 F1 F2 F3 F4 F5 F6 F7 | F8 F9 FA FB FC FD FE FF |  |

==>  T

. 256 00 255. . , . , , , . .

FILPUTLINE  

FILPUTLINE - , _OUTPUT _APPEND, - . , .

FILPUTLINE:

(filOpen 'fo "o.o" _OUTPUT)

==>  fo

(for i 1 10 ((filPutLine 'fo (strCat "i=" (fix2str i)))))

==>  10

(filClose 'fo)

==>  T

(filOpen 'fi "o.o" _TEXT_ARRAY)

==>  fi

(for i 1 10 ((printsline (filGetLine 'fi))))
i=1
i=2
i=3
i=4
i=5
i=6
i=7
i=8
i=9
i=10

==>  10

(filClose 'fi)

==>  T

(gc)

 : 0; : 40.

"o.o" . "i=...". . , ( _TEXT_ARRAY) "o.o".

, _APPEND, ( ) .

FILSEEK  

FILSEEK - , _BINARY_READ _BINARY_READ_WRITE, - FIXED. , . / .

FILSEEK:

(bloCreate 'buf 100)

==>  buf

(filOpen 'fo "ooo.ooo" _BINARY_READ_WRITE)

==>  fo

(str2blo 'buf "QWERTYUIOP{}" 10)

==>  T

(bloDump* 'buf)

00000001 | 00 00 00 00 00 00 00 00 | 00 51 57 45 52 54 59 55 | .........QWERTYU |
00000017 | 49 4F 50 7B 7D 00 00 00 | 00 00 00 00 00 00 00 00 | IOP{}........... |
00000033 | 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 | ................ |
00000049 | 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 | ................ |
00000065 | 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 | ................ |
00000081 | 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 | ................ |
00000097 | 00 00 00 00             |                         | ....             |

==>  T

(filPutBlo 'fo 'buf)

==>  T

(filloc 'fo)

==>  101

(filSeek 'fo 15)

==>  T

(filLoc 'fo)

==>  15

(bloCreate 'buf2 5)

==>  buf2


(filGetBlo 'fo 'buf2)

==>  T

(bloDump* 'buf2)

00000001 | 59 55 49 4F 50          |                         | YUIOP            |

==>  T

(filClose 'fo)

==>  T

(bloDestroy 'buf)

==>  T

(bloDestroy 'buf2)

==>  T

(gc)

 : 0; : 15.

BLOB () 100 . _BINARY_READ_WRITE. , , , . 101. FILSEEK 15- . 5 , 15- . .

Сайт создан в системе uCoz