Re: First C program

Jevgeni Astanovski <[email protected]>
Newsgroups gmane.comp.lang.as400.c
Message-ID <[email protected]>
Frank,

read your code and found something new for myself.
You write:
  if ((pf = _Ropen(PFILENAME, "rr")) EQ NULL)
I would write it:
  if ((pf = _Ropen(PFILENAME, "rr")) == NULL)

At the same time you write:
  for (i = 1; i <= *n ; i++)
and not
  for (i = 1; i LT *n ; i++)

Why?

I even did not imagine that EQ is allowed...



And there is at least one thing unclear after reading your code: where (how) the types S01_o_t, S01_i_t and C01_o_t are defined?

Jevgeni.


-----Original Message-----
From: c400-l-bounces-Zwy7GipZuJhWk0Htik3J/[email protected] [mailto:c400-l-bounces-Zwy7GipZuJhWk0Htik3J/[email protected]] On Behalf Of frank kolmann
Sent: Tuesday, April 01, 2014 11:47 AM
To: c400-l
Subject: [C400-L] First C program

I have coded my first C program. I put it here.
http://wiki.midrange.com/index.php/C_version_of_DISPR

It is a conversion on an RPGLE program I posted here (slightly different) http://wiki.midrange.com/index.php/UDDS_File_Displayer#DISPR_RPG

The resultant C code is a mass of function calls developed by others, thank GOD, so I dont think what I did is 'close to the metal' at all.
IMO the function calls make the resultant C code as abstract as RPG but still with the added myriad C pitfalls still waiting to get you.

Also I found the C version needed more code than RPG and I can now relate to the comment that RPGLE is a wannbe C, I pray that RPGLE never becomes a C but that it evolves on its own part , as it has, with the power of C but none of the convolutedness.

I believe the problem with C is that every function and statement can return a single value and can be treated as a variable which then enables coders to go on a involuted embedding spree that is impossible to untangle.

I found that Notepad++ (with C addon) is really useful to get the {} aligned.

When coding C I found it best to code a simple minimal shell that compiles.
Then add a few lines and compile that and so on.
It means an order of magnitude increase in compiles vs RPG.
It means I know which lines are in error. I cant remember who told me of this technique, but many thanks.

I found the C fancy coding constructs IMO dont achieve much, apart from looking pretty and confusing the heck out of non C coders.

If anyone can find a few moments I would like some feedback please on what I could have done better. Riducule is welcome.

My next goal is to learn C++ and classes with the objective of setting up a Class to process subfiles, or is this a really lame object.

Thanks.
Frank Kolmann
--
This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L) mailing list To post a message email: C400-L-Zwy7GipZuJhWk0Htik3J/[email protected] To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/c400-l
or email: C400-L-request-Zwy7GipZuJhWk0Htik3J/[email protected]
Before posting, please take a moment to review the archives at http://archive.midrange.com/c400-l.

-- 
This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L) mailing list
To post a message email: C400-L-Zwy7GipZuJhWk0Htik3J/[email protected]
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/c400-l
or email: C400-L-request-Zwy7GipZuJhWk0Htik3J/[email protected]
Before posting, please take a moment to review the archives
at http://archive.midrange.com/c400-l.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.