1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-12-01 14:51:52 +00:00
C02/vic20/fwrite.c02
2018-01-28 13:57:49 -05:00

85 lines
1.6 KiB
Plaintext

/**************************************
* fwrite.c02 - test file.h02 Library *
* function fread() *
**************************************
load "fwrite.prg",8
*/
#include <vic20.h02>
#include <stdlib.h02>
#include <stdio.h02>
#include <string.h02>
#include <file.h02>
char fp; //File Pointer
char filnam = "BINARY.SEQ";
char buffer[255];
char i, n;
main:
//Print Banner
putchr(147); //Clear Screen
putchr(18); //Reverse On
putstr(" FWRITE TEST ");
//Initialize File System
fsinit();
//Open File
newlin();
strdst(&buffer);
strcpy(&filnam);
strcat(",S,W");
fp = fopen(8, &buffer);
if (fp) {
outstr("CHANNEL ");
ctoa(fp, &buffer);
outstr(&buffer);
putstr(" OPENED TO ");
putstr(&filnam);
}
else {
prterr();
putstr(" OPENING FILE");
putstr(&filnam);
goto exit;
}
//fill buffer
i = 0;
do {
buffer[i] = i;
i++;
} while (i);
//Print File Contents
newlin();
putstr("WRITING FILE");
fssrc(&buffer);
for (n=1; n<255; n++) {
fwrite(fp, n);
putchr('.');
}
newlin();
newlin();
//Close File
if (fclose(fp)) {
prterr();
putstr(" CLOSING FILE");
putstr(&filnam);
}
else {
outstr("FILE ");
putstr(&filnam);
putstr("CLOSED");
}
goto exit;
void prterr() {
outstr("ERROR ");
ctoa(fstat(0), &buffer);
outstr(&buffer);
}