1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-25 06:31:25 +00:00
C02/vic20/fputc.c02

70 lines
1.3 KiB
Plaintext
Raw Normal View History

2018-01-28 18:57:49 +00:00
/*************************************
* fputc.c02 - test file.h02 Library *
* function fgetc() *
*************************************
load "fputc.prg",8
*/
#include <vic20.h02>
#include <stdlib.h02>
#include <stdio.h02>
#include <string.h02>
#include <file.h02>
char fp; //File Pointer
char filnam = "PETSCII.SEQ";
char buffer[128];
char c;
main:
//Print Banner
putchr(147); //Clear Screen
putchr(18); //Reverse On
putstr(" TEST FGETC ");
//Initialize File System
fsinit();
//Open File
newlin();
strdst(&filnam);
strcat(",S,W");
fp = fopen(8, &filnam);
if (fp) {
outstr("CHANNEL ");
ctoa(fp, &buffer);
outstr(&buffer);
putstr(" OPENED TO ");
putstr(&filnam);
putstr("FOR WRITING");
}
else {
prterr();
putstr(" OPENING FILE");
putstr(&filnam);
goto exit;
}
//Write to File
newlin();
putstr("WRITING FILE");
for (c=32; c<127; c++) {
fputc(fp,c);
}
newlin();
//Close File
if (fclose(fp)) {
prterr();
putstr(" CLOSING FILE");
putstr(&filnam);
}
goto exit;
void prterr() {
outstr("ERROR ");
ctoa(fstat(0), &buffer);
outstr(&buffer);
}