× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



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@xxxxxxxxxxxx [mailto:c400-l-bounces@xxxxxxxxxxxx] 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@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/c400-l
or email: C400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at http://archive.midrange.com/c400-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.