File size: Difference between revisions
Content added Content deleted
Alextretyak (talk | contribs) (Added 11l) |
(Added solution for Action!) |
||
Line 104: | Line 104: | ||
INPUT.TXT: 10 bytes |
INPUT.TXT: 10 bytes |
||
\INPUT.TXT: 8 bytes</pre> |
\INPUT.TXT: 8 bytes</pre> |
||
=={{header|Action!}}== |
|||
DOS 2.5 returns file size in number of sectors. It is required to read the whole file to calculate its size in bytes. |
|||
{{libheader|Action! Tool Kit}} |
|||
<lang Action!>INCLUDE "D2:IO.ACT" ;from the Action! Tool Kit |
|||
PROC Dir(CHAR ARRAY filter) |
|||
BYTE dev=[1] |
|||
CHAR ARRAY line(255) |
|||
Close(dev) |
|||
Open(dev,filter,6) |
|||
DO |
|||
InputSD(dev,line) |
|||
PrintE(line) |
|||
IF line(0)=0 THEN |
|||
EXIT |
|||
FI |
|||
OD |
|||
Close(dev) |
|||
RETURN |
|||
CARD FUNC FileSize(CHAR ARRAY src,dst) |
|||
DEFINE BUF_LEN="100" |
|||
BYTE dev=[1] |
|||
BYTE ARRAY buff(BUF_LEN) |
|||
CARD len,size |
|||
size=0 |
|||
Close(dev) |
|||
Open(dev,src,4) |
|||
DO |
|||
len=Bget(dev,buff,BUF_LEN) |
|||
size==+len |
|||
UNTIL len#BUF_LEN |
|||
OD |
|||
Close(dev) |
|||
RETURN (size) |
|||
PROC Main() |
|||
CHAR ARRAY filter="D:*.*", fname="D:INPUT.TXT" |
|||
CARD size |
|||
Put(125) PutE() ;clear screen |
|||
PrintF("Dir ""%S""%E",filter) |
|||
Dir(filter) |
|||
size=FileSize(fname) |
|||
PrintF("Size of ""%S"" is %U bytes%E",fname,size) |
|||
RETURN</lang> |
|||
{{out}} |
|||
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/File_size.png Screenshot from Atari 8-bit computer] |
|||
<pre> |
|||
Dir "D:*.*" |
|||
DOS SYS 037 |
|||
DUP SYS 042 |
|||
INPUT TXT 011 |
|||
617 FREE SECTORS |
|||
Size of "D:INPUT.TXT" is 1274 bytes |
|||
</pre> |
|||
=={{header|Ada}}== |
=={{header|Ada}}== |