/*======================================================================* * DOSshell program to convert an ASCII file to ATASCII format. * *======================================================================*/ #version $50 #reserve 6 #copyright "Toatari.cmd Copyright 1995 K-Products" #address $7000 #include runtime.h #include bbs_pro.h #define MAXBUFF 16384 #define DISK2 2 #define DISK4 4 char buffer [MAXBUFF]; main() { heading(); if (length (parm1) == 0) { echose("Usage: TOATARI filename.ext"); return; } convert_file(); } heading() { cr_lf(); echose("BBS Express! Pro Toatari v5.0"); echose(" ASCII --> ATASCII converter"); cr_lf(); } convert_file() { byte rc1, rc2; int x, bytesin, bytesout; MIOsuspend(); if (open (DISK2, parm1, 4, 0) != OK) { /* open input file? */ MIOresume(); echose("Unable to open input file!"); return; } if (open (DISK4, parm1, 12, 0) != OK) { /* bind to both channels */ close (DISK2); MIOresume(); echose("Unable to bind output channel!"); return; } MIOresume(); echos ("Converting..."); MIOsuspend(); do { bytesin = blockread (DISK2, buffer, sizeof(buffer)); if (IOresult (DISK2) == OK || IOresult (DISK2) == 136) { for (x=0; x < bytesin; ++x) case (buffer [x]) { 127: buffer [x] = '-'; 9: buffer [x] = 127;/* tab conversion */ 13: buffer [x] = ' '; 10: buffer [x] = 155; } blockwrite (DISK4, buffer, bytesin); } } while (IOresult (DISK2) == OK && IOresult (DISK4) == OK); rc1 = IOresult (DISK2); rc2 = IOresult (DISK4); close (DISK2); close (DISK4); MIOresume(); cr_lf(); cr_lf(); if (rc1 != 136) echose ("Error reading file!"); else if (rc2 != OK) echose ("Error writing file!"); else echose ("File converted!"); }