Home » CEEFAX disks » telesoftware14.adl » 18-03-89/IType\DOC
18-03-89/IType\DOC
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » CEEFAX disks » telesoftware14.adl |
Filename: | 18-03-89/IType\DOC |
Read OK: | ✔ |
File size: | 0461 bytes |
Load address: | 0000 |
Exec address: | FFFFFFFF |
File contents
We needed a file typer which would pause every screenful without the need for MORE to be present. Having put it on the disc to show the text files, we thought we might as well document it. Just use: ITYPE filename and you'll be prompted to press a key after every screen of text. Here's the source code: /* File typer - a screenfull at a time without the need for MORE, by Barry Wood Returns ERRORLEVEL=1 if wrong number of arguments 2 if couldn't open file */ #include <stdio.h> #define NULL 0 #define WRONGARG 1 #define NOFILE 2 main(argc,argv) int argc; char *argv[]; { FILE *fp; int lcount; int c; if(argc != 2) { puts("\n\nUse ITYPE <filename>\n\n"); exit(WRONGARG); } if( ( fp=fopen(argv[1],"r") ) == NULL ) { puts("\n\nCan't open the file!\n\n"); exit(NOFILE); } lcount=1; while( (c=getc(fp)) != EOF ) { if (c == '\n') { if (lcount++ == 20) { puts("\n\nPress a key ..."); getch(); lcount=1; } } putchar(c); } putchar('\n'); fclose(fp); }
00000000 57 65 20 6e 65 65 64 65 64 20 61 20 66 69 6c 65 |We needed a file| 00000010 20 74 79 70 65 72 20 77 68 69 63 68 20 77 6f 75 | typer which wou| 00000020 6c 64 20 70 61 75 73 65 20 65 76 65 72 79 20 73 |ld pause every s| 00000030 63 72 65 65 6e 66 75 6c 0d 0a 77 69 74 68 6f 75 |creenful..withou| 00000040 74 20 74 68 65 20 6e 65 65 64 20 66 6f 72 20 4d |t the need for M| 00000050 4f 52 45 20 74 6f 20 62 65 20 70 72 65 73 65 6e |ORE to be presen| 00000060 74 2e 20 48 61 76 69 6e 67 20 70 75 74 20 69 74 |t. Having put it| 00000070 0d 0a 6f 6e 20 74 68 65 20 64 69 73 63 20 74 6f |..on the disc to| 00000080 20 73 68 6f 77 20 74 68 65 20 74 65 78 74 20 66 | show the text f| 00000090 69 6c 65 73 2c 20 77 65 20 74 68 6f 75 67 68 74 |iles, we thought| 000000a0 20 77 65 20 6d 69 67 68 74 0d 0a 61 73 20 77 65 | we might..as we| 000000b0 6c 6c 20 64 6f 63 75 6d 65 6e 74 20 69 74 2e 0d |ll document it..| 000000c0 0a 0d 0a 4a 75 73 74 20 75 73 65 3a 0d 0a 0d 0a |...Just use:....| 000000d0 49 54 59 50 45 20 66 69 6c 65 6e 61 6d 65 0d 0a |ITYPE filename..| 000000e0 0d 0a 61 6e 64 20 79 6f 75 27 6c 6c 20 62 65 20 |..and you'll be | 000000f0 70 72 6f 6d 70 74 65 64 20 74 6f 20 70 72 65 73 |prompted to pres| 00000100 73 20 61 20 6b 65 79 20 61 66 74 65 72 20 65 76 |s a key after ev| 00000110 65 72 79 0d 0a 73 63 72 65 65 6e 20 6f 66 20 74 |ery..screen of t| 00000120 65 78 74 2e 0d 0a 0d 0a 48 65 72 65 27 73 20 74 |ext.....Here's t| 00000130 68 65 20 73 6f 75 72 63 65 20 63 6f 64 65 3a 0d |he source code:.| 00000140 0a 0d 0a 0d 0a 2f 2a 0d 0a 0d 0a 46 69 6c 65 20 |...../*....File | 00000150 74 79 70 65 72 20 2d 20 61 20 73 63 72 65 65 6e |typer - a screen| 00000160 66 75 6c 6c 20 61 74 20 61 20 74 69 6d 65 20 77 |full at a time w| 00000170 69 74 68 6f 75 74 0d 0a 0d 0a 74 68 65 20 6e 65 |ithout....the ne| 00000180 65 64 20 66 6f 72 20 4d 4f 52 45 2c 20 62 79 20 |ed for MORE, by | 00000190 42 61 72 72 79 20 57 6f 6f 64 0d 0a 0d 0a 52 65 |Barry Wood....Re| 000001a0 74 75 72 6e 73 20 45 52 52 4f 52 4c 45 56 45 4c |turns ERRORLEVEL| 000001b0 3d 31 20 69 66 20 77 72 6f 6e 67 20 6e 75 6d 62 |=1 if wrong numb| 000001c0 65 72 20 6f 66 20 61 72 67 75 6d 65 6e 74 73 0d |er of arguments.| 000001d0 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 |... | 000001e0 20 20 20 20 20 20 32 20 69 66 20 63 6f 75 6c 64 | 2 if could| 000001f0 6e 27 74 20 6f 70 65 6e 20 66 69 6c 65 0d 0a 0d |n't open file...| 00000200 0a 2a 2f 0d 0a 0d 0a 0d 0a 23 69 6e 63 6c 75 64 |.*/......#includ| 00000210 65 20 3c 73 74 64 69 6f 2e 68 3e 0d 0a 0d 0a 23 |e <stdio.h>....#| 00000220 64 65 66 69 6e 65 20 4e 55 4c 4c 20 20 20 20 20 |define NULL | 00000230 30 0d 0a 23 64 65 66 69 6e 65 20 57 52 4f 4e 47 |0..#define WRONG| 00000240 41 52 47 20 31 0d 0a 23 64 65 66 69 6e 65 20 4e |ARG 1..#define N| 00000250 4f 46 49 4c 45 20 20 20 32 0d 0a 0d 0a 6d 61 69 |OFILE 2....mai| 00000260 6e 28 61 72 67 63 2c 61 72 67 76 29 0d 0a 69 6e |n(argc,argv)..in| 00000270 74 20 61 72 67 63 3b 0d 0a 63 68 61 72 20 2a 61 |t argc;..char *a| 00000280 72 67 76 5b 5d 3b 0d 0a 7b 0d 0a 46 49 4c 45 20 |rgv[];..{..FILE | 00000290 2a 66 70 3b 0d 0a 69 6e 74 20 6c 63 6f 75 6e 74 |*fp;..int lcount| 000002a0 3b 0d 0a 69 6e 74 20 63 3b 0d 0a 0d 0a 09 69 66 |;..int c;.....if| 000002b0 28 61 72 67 63 20 21 3d 20 32 29 0d 0a 09 09 7b |(argc != 2)....{| 000002c0 0d 0a 09 09 70 75 74 73 28 22 5c 6e 5c 6e 55 73 |....puts("\n\nUs| 000002d0 65 20 49 54 59 50 45 20 3c 66 69 6c 65 6e 61 6d |e ITYPE <filenam| 000002e0 65 3e 5c 6e 5c 6e 22 29 3b 0d 0a 09 09 65 78 69 |e>\n\n");....exi| 000002f0 74 28 57 52 4f 4e 47 41 52 47 29 3b 0d 0a 09 09 |t(WRONGARG);....| 00000300 7d 0d 0a 09 0d 0a 09 69 66 28 20 28 20 66 70 3d |}......if( ( fp=| 00000310 66 6f 70 65 6e 28 61 72 67 76 5b 31 5d 2c 22 72 |fopen(argv[1],"r| 00000320 22 29 20 29 20 3d 3d 20 4e 55 4c 4c 20 29 0d 0a |") ) == NULL )..| 00000330 09 09 7b 0d 0a 09 09 70 75 74 73 28 22 5c 6e 5c |..{....puts("\n\| 00000340 6e 43 61 6e 27 74 20 6f 70 65 6e 20 74 68 65 20 |nCan't open the | 00000350 66 69 6c 65 21 5c 6e 5c 6e 22 29 3b 0d 0a 09 09 |file!\n\n");....| 00000360 65 78 69 74 28 4e 4f 46 49 4c 45 29 3b 0d 0a 09 |exit(NOFILE);...| 00000370 09 7d 0d 0a 0d 0a 09 6c 63 6f 75 6e 74 3d 31 3b |.}.....lcount=1;| 00000380 0d 0a 09 77 68 69 6c 65 28 20 28 63 3d 67 65 74 |...while( (c=get| 00000390 63 28 66 70 29 29 20 21 3d 20 45 4f 46 20 29 0d |c(fp)) != EOF ).| 000003a0 0a 09 09 7b 0d 0a 09 09 69 66 20 28 63 20 3d 3d |...{....if (c ==| 000003b0 20 27 5c 6e 27 29 0d 0a 09 09 09 7b 0d 0a 09 09 | '\n').....{....| 000003c0 09 69 66 20 28 6c 63 6f 75 6e 74 2b 2b 20 3d 3d |.if (lcount++ ==| 000003d0 20 32 30 29 0d 0a 09 09 09 09 7b 0d 0a 09 09 09 | 20)......{.....| 000003e0 09 70 75 74 73 28 22 5c 6e 5c 6e 50 72 65 73 73 |.puts("\n\nPress| 000003f0 20 61 20 6b 65 79 20 2e 2e 2e 22 29 3b 0d 0a 09 | a key ...");...| 00000400 09 09 09 67 65 74 63 68 28 29 3b 0d 0a 09 09 09 |...getch();.....| 00000410 09 6c 63 6f 75 6e 74 3d 31 3b 0d 0a 09 09 09 09 |.lcount=1;......| 00000420 7d 0d 0a 09 09 09 7d 0d 0a 09 09 70 75 74 63 68 |}.....}....putch| 00000430 61 72 28 63 29 3b 0d 0a 09 09 7d 0d 0a 09 70 75 |ar(c);....}...pu| 00000440 74 63 68 61 72 28 27 5c 6e 27 29 3b 0d 0a 09 66 |tchar('\n');...f| 00000450 63 6c 6f 73 65 28 66 70 29 3b 0d 0a 7d 0d 0a 0d |close(fp);..}...| 00000460 0a |.| 00000461