[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference hydra::amiga_v1

Title:AMIGA NOTES
Notice:Join us in the *NEW* conference - HYDRA::AMIGA_V2
Moderator:HYDRA::MOORE
Created:Sat Apr 26 1986
Last Modified:Wed Feb 05 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:5378
Total number of notes:38326

1307.0. "Printing with Lattice C" by STKEIS::LJONSSON () Wed Apr 06 1988 19:14

    Hi!
    
      I've got a few questions concerning printing through the serial port.
    My first question is how do I write to 'PRT:' in (Lattice) C. In AmigaBasic
    it wasn't a problem, I just opened it just like any other output file, but
    in C he kept telling me that he couldn't find the file or directory.

      If I do manage to open 'PRT:', would I use the same method in opening
    'SER:'?

      Would I be right in assuming that writing to 'SER:' and 'PRT:' will
    produce the same results except that the output to 'SER:' will not go
    through a driver that translates escape sequences and there will be a
    problem with carriage return and line feed (on 'SER:')?

      I want to my LA100 without a silly printer driver getting in the way.
    Would outputing to 'SER:' solve all my problems?

                                 /Lars
T.RTitleUserPersonal
Name
DateLines
1307.1WJG::GUINEAUWed Apr 06 1988 22:3321
>      If I do manage to open 'PRT:', would I use the same method in opening
>    'SER:'?

Yup!


>      Would I be right in assuming that writing to 'SER:' and 'PRT:' will
>    produce the same results except that the output to 'SER:' will not go
>    through a driver that translates escape sequences and there will be a
>    problem with carriage return and line feed (on 'SER:')?

Your on a roll :-)

>      I want to my LA100 without a silly printer driver getting in the way.
>    Would outputing to 'SER:' solve all my problems?

Thats how..


John
1307.2Yes but ...STKEIS::LJONSSONThu Apr 07 1988 08:335
      That answers all my questions except the first and most important
    one - How do I open 'PRT:' or 'SER:' and write to them?
    
                                        /Lars
1307.3WJG::GUINEAUThu Apr 07 1988 11:4320
something like:


main()
{
FILE	*fopen(),fp;

 fp = fopen("PRT:","w");		/* Open channel to PRT: device */
					/* fp is now a "pointer to a file" */
 putc(c, fp);				/* Send character in c to PRT */

 fclose(fp);

}
 


John

1307.4C Coding WarningTLE::RMEYERSRandy MeyersThu Apr 07 1988 22:1734
Re: .3

You hit a sort point with me!

Never declare fopen or any other standard C routine in your programs.
Always include the appropriate include file that contains the definition.

#include <stdio.h>
main()
{
FILE	*fp;
char	c = '\n';

 fp = fopen("PRT:","w");		/* Open channel to PRT: device */
					/* fp is now a "pointer to a file" */
 putc(c, fp);				/* Send character in c to PRT */

 fclose(fp);

}


I realize that the author of .3 was quickly dashing off an example
and is blameless.  However, providing your own declarations for
standard C functions and failing to include the proper include file
are common mistakes for beginning C programmers.  I just want to
warn people away from those mistakes.

If my tone sounds shrill, please forgive me.  I have been heavily
involved with writing the C guidelines for the new Software
Engineering Manual, and I'm afraid it has made me a bit overly
critical.

Sorry.
1307.5more info on proper guidelines, etc.MVCAD3::BAEDERD. Scott DTN 237-2961 SHR1-3/E19Fri Apr 08 1988 01:389
    this may not be the right place, BUT...I for one would like to hear
    A LOT more about this manual...I'm a firm believer in standards,
    etc. BUT after joining dec last summer was surprised to see not
    a lot of visibility in this area, and really haven't heard a lot
    about anything like this...(other than refs to something about 10
    yrs old)...MORE INFO   P L E A S E   !   !   !
    
    thanks....scott
    
1307.6RMS is the wayWJG::GUINEAUFri Apr 08 1988 03:0013

Re .4, .5

I agree with Scott - Standardize us!!

My reply on using fopen was purely academic... I have only just begun
to use C on PC type computers (shame to call Amiga a *PC*. How about
"Home SuperMini"? :-)

Anyway, I'm used to FAB's and RAB's !

John
1307.7Software Engineering ManualTLE::RMEYERSRandy MeyersFri Apr 08 1988 05:2137
Re: .4, .5, .6

Sigh, this isn't the place to discuss it, but I started the whole thing
so I guess I owe an explanation.

The new Software Engineering Manual is indeed an update (major rewrite)
of the old Software Engineering Manual.  This manual gets updated
every ten years whether it needs it or not. :-)

In general, the manual has been reorganized.  The old SEM was broken
down by language with huge sections on BLISS and MACRO and not much
on anything else.  Now, the bulk of the manual is in a language
independent section that tries to be a more high level discussion
of the engineering process.  Individual language guidelines appear
as appendixes.

In general, I suspect that there is less dogma and more meat in the
new SEM.  In the C appendix we have tried to avoid religious issues
and stick to describing engineering practices that actually impact
the maintainability of the software.  For example, which of the
many indentation styles you choose, as long as used consistently,
does not really impact the quality of your code.  However, failing
to use the type checking abilities of the language or failing to
divide the program into proper modules has a great impact.

We haven't completely succeeded in eliminating subjective from the
objective in the C appendix.  I suspect that if we had more time
we could do a better job.

How do you get a copy?  I believe the current plan is that everyone
will get a copy.  Just sit tight for another couple of months.

If you are new to C and dying for help with your style, I recommend
the book "C Programming Guidelines" by Tom Plum (vice chair of the ANSI
C committee).

With those words, we should probably return to the original discussion.