Re: A89: Re: Please help with C


[Prev][Next][Index][Thread]

Re: A89: Re: Please help with C






 / Niklas Brunlid
Check out Prosit for the TI-89 / TI-92+ at http://prosit.ticalc.org
Random PQF Quote follows:

Thud. Thud. Thud. Splat.
        -- (Terry Pratchett & Neil Gaiman, Good Omens)

----- Original Message -----
From: "Brady Simon" <bradys9@yahoo.com>
To: <assembly-89@lists.ticalc.org>
Sent: Tuesday, April 04, 2000 10:32 PM
Subject: RE: A89: Re: Please help with C


>
> Hey thanks a ton but I am still getting an error, I  changed my code and put
> it below. I am getting a parse error with the line that loads the buffer.
> I also tried using the labeling and goto like you said but I got a ton of
> error from everything inside that label. I did..  main2:
> I don't know if that is what you meant but that is how it is done in Java (I
> think if I remember right.) so I assumed so.
> Well thanks again for putting up with my not knowing C.
>
>
> file://My code, yet again
> #include <doors.h>
> #include <graph.h>
> #include <kbd.h>
>
> int _ti89,_ti92plus;      // compile for both calcs
> int font;
> int kbkey;
> void _main(void)
> {
>   LCD_BUFFER buffer;
>   LCD_save(buffer);
>   font = 2;
>   FontSetSys(F_6x8);
> }
> int main2(void)
>

>   ClrScr();
>   DrawStr(3,3,"Move Me",A_NORMAL);
>   kbkey = ngetchx();
>   if(kbkey == 43)
>   { if(font == 2)
>     { font += 1;
>       FontSetSys(F_8x10);
> }
> if(font == 1)
> { font += 1;
>       FontSetSys(F_6x8);
>     }
>   }
>   if(kbkey == 45)
>   { if(font == 2)
>     { font -= 1;
>       FontSetSys(F_4x6);
>     }
>   if(font == 3)
>     { font -= 1;
>       FontSetSys(F_6x8);
>     }
>   }
>   if(kbkey != 264)
>   { main2();
>   }
>  }
> int emd(void)
> { LCD_restore(buffer);
> }

The only problem I see without compiling and testing the code myself is that you
have three separate functions, and none of them calls the others. So if your
code would work it would execute the four lines in _main() and then exit.

I think you're confusing functions in C with labels in ASM. When you do this
call:
  main2();
..then the asm code will be:
  jsr main2
...which in this case means that main2() will be recursive.

Also, a variable declared in one function can't be used in another (unless it's
passed as a parameter, or the functions is a function-within-a-function,
something not generally used. I use it though =)  ).

I recommend taking one of the many excellent online C tutorials. Try these:
http://dir.yahoo.com/Computers_and_Internet/Programming_Languages/C_and_C__/Cour
ses/
http://dir.altavista.com/Computers/Programming/Languages/C/Tutorials.shtml





References: