Re: [cc65] Reading a string from an open file under cc65?

From: Marc 'BlackJack Rintsch <marc1rintsch.de>
Date: 2008-12-28 09:51:51
On Saturday 27 December 2008, Maspethrose7@aol.com wrote:
> unsigned char diskerror ()
> {
> unsigned char i=0;  /*  Loc. in channel. */
> char errch [32];  /* Returned error.  */
> /* Read error channel from drive 8. */
> printf ("Open  returns:  %d.\n", (unsigned) cbm_open (15,8,15,0));
> printf ("Chkin  returns: %d.\n", (unsigned) cbm_k_chkin (15));
> //for (/*i=0*/;  (errch[i]=cbm_k_basin())!=13; ++i);
> //errch[i]=0;
> gets  (errch);
> cbm_k_clrch();
> cbm_k_close (15);
> /* Display  error on screen. */
> /* User: define display of error here.   Defaults to displaying
> * in reverse-video on bottom of  screen.
> * You need to reset the color after routine.  */
> textcolor (10); revers(1);
> cputsxy (0, 24,  errch);
> revers (0);
> cgetc();
>  
>  /* Return error #. */
> i=atoi(errch);
> return  i;
> }

You are mixing I/O functions from very different levels here, namely 
kernel, BASIC-like, C stdio, and conio.  That's no good idea.

If you use the kernel level functions (`cbm_k_*()`) you'll need to check 
the status after every read byte.  See the source of `cbm_read.s` for a 
C version of that function in the comments.

Try to stick to the BASIC-like functions for reading the error channel, 
so you will need just `cbm_open()`, `cbm_read()`, and `cbm_close()`.

Ciao,
	Marc 'BlackJack' Rintsch
-- 
Do you trust one company to decide the future? Chose Linux!

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sun Dec 28 09:51:18 2008

This archive was generated by hypermail 2.1.8 : 2008-12-28 09:51:20 CET