https://wiki.midrange.com/api.php?action=feedcontributions&user=Jky&feedformat=atomMidrangeWiki - User contributions [en]2024-03-28T22:53:19ZUser contributionsMediaWiki 1.30.0https://wiki.midrange.com/index.php?title=Python&diff=13553Python2019-06-11T14:30:59Z<p>Jky: Updated to mention the RPM packages</p>
<hr />
<div>{{SeealsoWP|Python (programming language)}}<br />
{{AN}} is a general-purpose very-high-level programming language.<br />
<br />
==IBM i implementation==<br />
<br />
There are currently several implementations for IBM i:<br />
* Native port of Python 2.7 by Per Gummedal, called [http://www.iseriespython.com iSeriesPython], for V5R3 and later<br />
* [[PASE]] port of Python 3.4 by IBM, as Option 2 of [[5733-OPS]] (Open Source for IBM i Product) for 7.1 and later<br />
* [[PASE]] port of Python 2.7 by IBM, as Option 4 of [[5733-OPS]] (Open Source for IBM i Product) for 7.1 and later<br />
* [[PASE]] port of Python 3.6 by IBM, distributed as an [https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/IBM%20i%20Technology%20Updates/page/Open%20Source%20RPM%27s RPM package] via <code>yum</code> for 7.2 and later<br />
* [[PASE]] port of Python 2.7 by IBM, distributed as an [https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/IBM%20i%20Technology%20Updates/page/Open%20Source%20RPM%27s RPM package] via <code>yum</code> for 7.2 and later<br />
<br />
Additionally, there are AIX ports on Perzl.org which may or may not work in PASE.<br />
<br />
The RPM-based distributions are the most up to date and generally considered the easiest to install.<br />
<br />
==Hello world==<br />
<br />
===Python 2===<br />
print "Hello world"<br />
<br />
===Python 3===<br />
print("Hello world")<br />
<br />
==External links==<br />
* [http://www.iseriespython.com iSeriesPython Web Site]<br />
* [http://iseriespython.blogspot.ca iSeriesPython Blog]<br />
* [https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/IBM%20i%20Technology%20Updates/page/Python IBM i Technology Updates - Python]<br />
* [http://ibm.biz/ibmi-rpms Installation and availability of open source RPM packages from IBM]<br />
* [https://www.gateway400.org/documents/Gateway400/Handouts/GetStartedWithPythonOnIBMi2016.pdf "Getting started with Python on IBM i" (PDF)] - handed out at Gateway/400 User Group meeting Jan 14, 2016<br />
<br />
==Categories==<br />
{{stub}}<br />
[[Category:Programming languages]]</div>Jkyhttps://wiki.midrange.com/index.php?title=Category:RPG&diff=12478Category:RPG2018-11-15T18:53:32Z<p>Jky: Made sweeping changes to the section comparing RPG to other languages, and especially the spurious "defense" of RPG as object-oriented.</p>
<hr />
<div>'''RPG''' is an acronym which stands for {{bu|R|eport}} {{bu|P|rogram}} {{bu|G|enerator}}. It is a programming language developed by IBM originally created for developing business applications. <br />
<br />
{{SeeAlsoWP|RPG programming language}}<br />
<br />
Programmers, coming to RPG from other programming environments, will still need to get some education to familiarize themselves with its capabilities, and how it functions.<br />
<br />
There are four major versions of RPG currently in use... [[RPG II]], [[RPG III]], [[RPG 400]], and [[RPG IV]] (sometimes referred to as [[ILE]] RPG). The latter has two distinctive flavors: the traditional column restricted language entry and the modern /Free alternative where most of the coding can be entered in a non-column restricted way.<br />
<br />
RPG is almost exclusively limited to IBM midrange platforms. Various RPG implementations have been developed for other platforms over the years including the IBM 1401, System/360, S/370 and follow-ons; the Hewlett Packard HP3000 [http://docs.hp.com/cgi-bin/doc3k/B3031890001.10422/1]; as well as Wang, Sperry, Burroughs, and Digital PDP and VAX computers. These can all be considered niche projects with very little adoption, especially the ones outside IBM.<br />
<br />
[[OS/400]] contains extensive support for debugging and run-time identification of RPG code. There is a large established base of RPG code in production environments, usually performing heavy-lifting batch-oriented data tasks, or providing support for interactive [[ERP]] applications, either with native [[5250]] interface or with a graphical user interface ([[GUI]]) or Web [[Skin]] applied over the [[5250]] data stream.<br />
<br />
== RPG vs. other languages ==<br />
Compared to other programming languages, RPG is especially strong in <br />
* transactional processing;<br />
* access to the integrated [[Db2]] database on the IBM i platform;<br />
<br />
The main criticisms of RPG center around the language not having enough "modern" features, such as support for object-oriented programming (OOP). However, the language continues to evolve and improve, and already compares favorably with most languages in terms of procedural programming support.<br />
<br />
Another area of criticism is lack of direct support for GUI programming, though there are [[RPG Third Party]] offerings to fill that gap.<br />
<br />
=== RPG vs. Java ===<br />
Arguably the biggest difference between these two languages, as used for "business" programming, is that [[Java]] is explicitly object-oriented while RPG is not. Java also has a very large ecosystem of third-party packages, most of which are free and open-source, while RPG (as yet) has a very small ecosystem by comparison.<br />
<br />
Both coexist and interoperate well on the IBM midrange platform, allowing businesses to leverage the respective strengths of each language on the same machine.<br />
<br />
=== Objects and RPG ===<br />
This seems to be a persistent bone of contention among those who try to portray RPG as object-oriented, apparently due to some perceived need to "keep up with the Joneses". However, RPG is not object-oriented in any way which would be recognizable to programmers of languages with explicit support for OOP, such as Java, C++, C#, Python, Ruby, Smalltalk, etc.<br />
<br />
RPG is about as object-oriented as C or Pascal, which is to say you could use pointers and data structures to create your own notion of "objects". However, this is far more cumbersome and less robust than using the explicit, built-in object-oriented mechanisms (such as classes and inheritance) in the languages recognized by the rest of the computing world as "object-oriented".<br />
<br />
What the "RPG-is-object-oriented" proponents invariably describe as object-oriented features are better understood to the rest of the world as ''modular'' programming features. In particular, the ILE environment and ILE-related language improvements bring GCC-style modularity and language interoperability to the IBM midrange.<br />
<br />
== APIs ==<br />
[[API]] stands for {{bu|A|pplication}} {{bu|P|rogram}} {{bu|I|nterface}}. RPG has access to C functions via service programs in binding directory QC2LE, as well as CEE APIs. There are also APIs specific to IBM i, like IFS access.<br />
<br />
A new API mechanism is called IBM Rational Open Access: RPG Edition <ref>IBM United States Software Announcement 210-114 , [http://www-01.ibm.com/common/ssi/cgi-bin/ssialias?subtype=ca&infotype=an&appname=iSource&supplier=897&letternum=ENUS210-114 IBM Rational Open Access: RPG Edition delivers RPG IV extensibility to access new devices and resources ],13 Apr 2010. Retrieved on 19 Apr 2010</ref> Open Access is a separately purchased product for IBM i 6.1 and above via handlers similar to using SPECIAL files.<br />
<br />
== Conditional compilation ==<br />
Conditional compilation is a mechanism that allows you to include or omit sections of code based on the compilation environment. This is in contrast to editing the code to add or remove sections. A typical reason for conditional compilation is code only used during testing. Imagine a scenario where you're writing a program that will perform a web service. Putting it in debug might be problematic because halting on a breakpoint will stop all web users from seeing results. So you insert code that logs useful information to an IFS file. Unfortunately, leaving that code in all the time slows execution down too much. One solution is conditional compilation.<br />
<br />
Conditional compilation uses condition-names as the main driver. In conjunction with condition-names, compiler directives /IF, /ENDIF, /ELSE and /ELSEIF are used to perform the tests the compiler will use to determine whether to include a section of code or not. Condition-names can be predefined by the compiler, or defined by the developer via /DEFINE and /UNDEFINE. There is one last directive, /EOF, which tells the compiler to ignore any remaining source lines in the source member.<br />
<br />
An example might make this easier.<br />
<br />
<pre><br />
/if defined(LOG_FULL)<br />
logDebug('customer credit code': creditCode)<br />
logDebug('customer A/R balance': %editc(balance: 'J')<br />
/endif<br />
</pre><br />
<br />
If LOG_FULL is defined, either in the compile command: DEFINE(LOG_FULL), or within the source code: /DEFINE LOG_FULL then this logging code is included and compiled. If LOG_FULL is not defined, that code is not compiled.<br />
<br />
RPG comes with some useful predefined condition-names:<br />
<br />
{| class="wikitable" class=sortable style="position:relative; margin: 0 0 0.5em 1em; border-collapse: collapse; background:white; clear:right; text-align:left;" border="1" cellpadding="3"<br />
|-<br />
! i5/OS version<br />
! Condition-name<br />
! Purpose<br />
|-<br />
| V5R4<br />
| *CRTRPGMOD<br />
| Set if the compilation command is CRTRPGMOD<br />
|-<br />
| V5R4<br />
| *CRTBNDRPG<br />
| Set if the compilation command is CRTBNDRPG<br />
|-<br />
| V5R4<br />
| *VxRxMx<br />
| Set if the TGTRLS on the compile command is this level OR LATER. For example, if *V5R4M0 is specified, it will evaluate true if TGTRLS is V5R4, 6.1, 7.1 or higher.<br />
|}<br />
<br />
Examples:<br />
<pre><br />
/if defined(*CRTBNDRPG)<br />
H dftactgrp(*no) actgrp('MYCOMPANY')<br />
/endif<br />
</pre><br />
<br />
<pre><br />
/if defined(*V5R4M0)<br />
callp someV5R4API();<br />
/else<br />
callp ourHandWrittenVersion();<br />
/endif<br />
</pre><br />
<br />
<br />
{{stub}}<br />
<br />
<br />
== Learning about RPG ==<br />
* [https://www.itjungle.com/2014/02/12/fhg021214-story01/ Four Reasons RPG Geezers Should Care About The New Free-Form RPG]<br />
* [https://www.itjungle.com/2014/04/16/fhg041614-story01/ The Geezer's Guide to Free-Form RPG, Part 2: Data Structures and More]<br />
* [https://www.itjungle.com/2014/05/28/fhg052814-story01/ The Geezer's Guide to Free-Form RPG, Part 3: Data Structures and More Data Definitions]<br />
* [https://www.itjungle.com/2014/07/09/fhg070914-story01/ The Geezer's Guide To Free-Form RPG, Part 4: Prototypes and Procedure Interfaces]<br />
* [https://www.itjungle.com/2014/08/13/fhg081314-story01/ The Geezer's Guide to Free-Form RPG, Part 5: File Definitions]<br />
* [http://www.rpgpgm.com/2015/12/trying-fully-free-rpg.html Trying fully free RPG]<br />
* [http://www.rpgpgm.com/2017/01/using-seu-with-totally-free-rpg.html Using SEU with totally free RPG]<br />
* [https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/We13116a562db_467e_bcd4_882013aec57a/page/Coding%20in%20Free-Form%20RPG%20IV%20-%20a%20beginner%27s%20tutorial Coding in Free-Form RPG IV - a beginner's tutorial]<br />
* [http://www.rpgpgm.com/2016/12/calling-program-in-totally-free-rpg.html Calling a program in totally free RPG]<br />
* [http://www.mcpressonline.com/programming/rpg/practical-rpg-techniques-for-procedures?mc_cid=58ae4db7af&mc_eid=14b7380d89 Practical RPG: Techniques for Procedures]<br />
* [http://www.rpgpgm.com/2016/09/the-equivalent-of-movea-in-all-free-rpg.html The equivalent of MOVEA in all free RPG]<br />
* [http://www.rpgpgm.com/2016/05/example-subfile-program-using-modern-rpg.html Example subfile program using modern RPG]<br />
* [https://www.ibm.com/developerworks/ibmi/library/i-ibmi-rpg-support/index.html Free-form RPG support on IBM i]<br />
* [http://www.ibmsystemsmag.com/ibmi/developer/rpg/freerpg_surprises/?page=2 Surprises in the New Free Format RPG]<br />
* [http://www.ocean400.org/assets/documents/2014/free_form_rpg_ocean.pdf RPG is free at last!]<br />
* [http://www.isoftwerks.net/newoperations.pdf New RPG Free-Format operations]<br />
* [http://www.rpgpgm.com/2014/02/defining-variables-in-rpg-all-free.html Defining variables in RPG all free]<br />
* [http://www.semiug.org/2016/docs/Free_Form_RPG_Deeo_Dive.pdf Deep dive into RPG free-form]<br />
<br />
== Open Source Sites ==<br />
* http://iseries-toolkit.sourceforge.net/<br />
* http://www.scottklement.com/oss.html<br />
* http://www.martinvt.com/Code_Samples/code_samples.html<br />
* http://Netshare400.com<br />
* http://www.think400.dk (Danish)<br />
* http://home.alltel.net/craigru/jcrcmd2.html<br />
* http://sourceforge.net/projects/iseriestoexcel<br />
* http://www.rpgiv.com/downloads/<br />
* http://www.code400.com<br />
* http://mowyourlawn.com/<br />
* http://www.rpgnext.com/tutorials.php<br />
* http://www.rpgunit.org<br />
* http://www.opensource4i.com/<br />
<br />
== External Links ==<br />
* RPG Developer Network http://www.rpgiv.com/<br />
* "RPG: A Great Language with a Greater History" by Brian Kelly, The Four Hundred, Volume 18, Number 30 -- August 17, 2009 [http://www.itjungle.com/tfh/tfh081709-story01.html]<br />
<br />
== References ==<br />
<references /><br />
<br />
[[Category:Programming languages]]</div>Jkyhttps://wiki.midrange.com/index.php?title=Python&diff=12275Python2017-06-14T19:02:37Z<p>Jky: Added .org to Perzl site</p>
<hr />
<div>{{SeealsoWP|Python (programming language)}}<br />
{{AN}} is a general-purpose very-high-level programming language.<br />
<br />
==IBM i implementation==<br />
<br />
There are currently at least three implementations for IBM i:<br />
* Native port of Python 2.7 by Per Gummedal, called iSeriesPython, for V5R3 and later<br />
* [[PASE]] port of Python 3.4 by IBM, as Option 2 of [[5733-OPS]] (Open Source for IBM i Product) for 7.1 and later<br />
* [[PASE]] port of Python 2.7 by IBM, as Option 4 of [[5733-OPS]] (Open Source for IBM i Product) for 7.1 and later<br />
<br />
Additionally, there are AIX ports on Perzl.org which may or may not work in PASE.<br />
<br />
==Hello world==<br />
<br />
===Python 2===<br />
print "Hello world"<br />
<br />
===Python 3===<br />
print("Hello world")<br />
<br />
==External links==<br />
* [http://www.iseriespython.com iSeriesPython Web Site]<br />
* [http://iseriespython.blogspot.ca iSeriesPython Blog]<br />
* [https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/IBM%20i%20Technology%20Updates/page/Python IBM i Technology Updates - Python]<br />
* [https://www.gateway400.org/documents/Gateway400/Handouts/GetStartedWithPythonOnIBMi2016.pdf "Getting started with Python on IBM i" (PDF)] - handed out at Gateway/400 User Group meeting Jan 14, 2016<br />
<br />
==Categories==<br />
{{stub}}<br />
[[Category:Programming languages]]</div>Jkyhttps://wiki.midrange.com/index.php?title=Python&diff=12274Python2017-06-14T19:01:54Z<p>Jky: Updated information</p>
<hr />
<div>{{SeealsoWP|Python (programming language)}}<br />
{{AN}} is a general-purpose very-high-level programming language.<br />
<br />
==IBM i implementation==<br />
<br />
There are currently at least three implementations for IBM i:<br />
* Native port of Python 2.7 by Per Gummedal, called iSeriesPython, for V5R3 and later<br />
* [[PASE]] port of Python 3.4 by IBM, as Option 2 of [[5733-OPS]] (Open Source for IBM i Product) for 7.1 and later<br />
* [[PASE]] port of Python 2.7 by IBM, as Option 4 of [[5733-OPS]] (Open Source for IBM i Product) for 7.1 and later<br />
<br />
Additionally, there are AIX ports on Perzl which may or may not work in PASE.<br />
<br />
==Hello world==<br />
<br />
===Python 2===<br />
print "Hello world"<br />
<br />
===Python 3===<br />
print("Hello world")<br />
<br />
==External links==<br />
* [http://www.iseriespython.com iSeriesPython Web Site]<br />
* [http://iseriespython.blogspot.ca iSeriesPython Blog]<br />
* [https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/IBM%20i%20Technology%20Updates/page/Python IBM i Technology Updates - Python]<br />
* [https://www.gateway400.org/documents/Gateway400/Handouts/GetStartedWithPythonOnIBMi2016.pdf "Getting started with Python on IBM i" (PDF)] - handed out at Gateway/400 User Group meeting Jan 14, 2016<br />
<br />
==Categories==<br />
{{stub}}<br />
[[Category:Programming languages]]</div>Jkyhttps://wiki.midrange.com/index.php?title=Python&diff=12138Python2016-05-12T19:26:11Z<p>Jky: </p>
<hr />
<div>{{SeealsoWP|Python (programming language)}}<br />
{{AN}} is a general-purpose very-high-level programming language.<br />
<br />
==IBM i implementation==<br />
<br />
There are currently two implementations for IBM i:<br />
* Native port of Python 2.7 by Per Gummedal, called iSeriesPython, for V5R3 and later<br />
* [[PASE]] port of Python 3.4 by IBM, as Option 2 of 5733-OPS (Open Source for IBM i Product) for 7.1 and later<br />
<br />
Another is expected in the near future:<br />
* [[PASE]] port of Python 2.7 by IBM, as Option 4 of 5733-OPS (Open Source for IBM i Product) for 7.1 and later<br />
<br />
==Hello world==<br />
<br />
===Python 2===<br />
print "Hello world"<br />
<br />
===Python 3===<br />
print("Hello world")<br />
<br />
==External links==<br />
* [http://www.iseriespython.com iSeriesPython Web Site]<br />
* [http://iseriespython.blogspot.ca iSeriesPython Blog]<br />
* [https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/IBM%20i%20Technology%20Updates/page/Python IBM i Technology Updates - Python]<br />
* [https://www.gateway400.org/documents/Gateway400/Handouts/GetStartedWithPythonOnIBMi2016.pdf "Getting started with Python on IBM i" (PDF)] - handed out at Gateway/400 User Group meeting Jan 14, 2016<br />
<br />
==Categories==<br />
{{stub}}<br />
[[Category:Programming languages]]</div>Jkyhttps://wiki.midrange.com/index.php?title=Python&diff=12137Python2016-05-11T20:17:55Z<p>Jky: </p>
<hr />
<div>{{SeealsoWP|Python (programming language)}}<br />
{{AN}} is a general-purpose very-high-level programming language.<br />
<br />
==IBM i implementation==<br />
<br />
There are currently two implementations for IBM i:<br />
* Native port of Python 2.7 by Per Gummedal, called iSeriesPython, for V5R3 and later<br />
* [[PASE]] port of Python 3.4 by IBM, as Option 2 of 5733-OPS (Open Source for IBM i Product) for 7.1 and later<br />
<br />
Another is expected in the near future:<br />
* [[PASE]] port of Python 2.7 by IBM, as Option 4 of 5733-OPS (Open Source for IBM i Product) for 7.1 and later<br />
<br />
==Hello world==<br />
<br />
===Python 2===<br />
print "Hello world"<br />
<br />
===Python 3===<br />
print("Hello world")<br />
<br />
==External links==<br />
* [http://www.iseriespython.com iSeriesPython Web Site]<br />
* [http://iseriespython.blogspot.ca iSeriesPython Blog]<br />
* [https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/IBM%20i%20Technology%20Updates/page/Python IBM i Technology Updates - Python]<br />
* [https://www.gateway400.org/documents/Gateway400/Handouts/GetStartedWithPythonOnIBMi2016.pdf "Getting started with Python on IBM i" - handed out at Gateway/400 User Group meeting Jan 14, 2016 (PDF)]<br />
<br />
==Categories==<br />
{{stub}}<br />
[[Category:Programming languages]]</div>Jkyhttps://wiki.midrange.com/index.php?title=Python&diff=12136Python2016-05-11T19:44:37Z<p>Jky: </p>
<hr />
<div>{{SeealsoWP|Python (programming language)}}<br />
{{AN}} is a general-purpose very-high-level programming language.<br />
<br />
==IBM i implementation==<br />
<br />
There are currently two implementations for IBM i:<br />
* Native port of Python 2.7 by Per Gummedal, called iSeriesPython, for V5R3 and later<br />
* [[PASE]] port of Python 3.4 by IBM, as Option 2 of 5733-OPS (Open Source for IBM i Product) for 7.1 and later<br />
<br />
Another is expected in the near future:<br />
* [[PASE]] port of Python 2.7 by IBM, as Option 4 of 5733-OPS (Open Source for IBM i Product) for 7.1 and later<br />
<br />
==Hello world==<br />
<br />
===Python 2===<br />
print "Hello world"<br />
<br />
===Python 3===<br />
print("Hello world")<br />
<br />
==External links==<br />
* [http://www.iseriespython.com iSeriesPython Web Site]<br />
* [http://iseriespython.blogspot.ca iSeriesPython Blog]<br />
* [https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/IBM%20i%20Technology%20Updates/page/Python IBM i Technology Updates - Python]<br />
* [https://www.gateway400.org/documents/Gateway400/Handouts/GetStartedWithPythonOnIBMi2016.pdf "Getting started with Python on IBM i" (PDF) from Gateway/400 Group]<br />
<br />
==Categories==<br />
{{stub}}<br />
[[Category:Programming languages]]</div>Jkyhttps://wiki.midrange.com/index.php?title=Python&diff=12135Python2016-05-11T19:34:06Z<p>Jky: Prettified links and removed link to outdated Garry Taylor article</p>
<hr />
<div>{{SeealsoWP|Python (programming language)}}<br />
{{AN}} is a general-purpose very-high-level programming language.<br />
<br />
==IBM i implementation==<br />
<br />
There are currently two implementations for IBM i:<br />
* Native port of Python 2.7 by Per Gummedal, called iSeriesPython, for V5R3 and later<br />
* PASE port of Python 3.4 by IBM, as Option 2 of 5733-OPS (Open Source for IBM i Product) for 7.1 and later<br />
<br />
Another is expected in the near future:<br />
* PASE port of Python 2.7 by IBM, as Option 4 of 5733-OPS (Open Source for IBM i Product) for 7.1 and later<br />
<br />
==Hello world==<br />
<br />
===Python 2===<br />
print "Hello world"<br />
<br />
===Python 3===<br />
print("Hello world")<br />
<br />
==External links==<br />
* [http://www.iseriespython.com iSeriesPython Web Site]<br />
* [http://iseriespython.blogspot.ca iSeriesPython Blog]<br />
* [https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/IBM%20i%20Technology%20Updates/page/Python IBM i Technology Updates - Python]<br />
* [https://www.gateway400.org/documents/Gateway400/Handouts/GetStartedWithPythonOnIBMi2016.pdf "Getting started with Python on IBM i" (PDF) from Gateway/400 Group]<br />
<br />
==Categories==<br />
{{stub}}<br />
[[Category:Programming languages]]</div>Jkyhttps://wiki.midrange.com/index.php?title=Python&diff=12134Python2016-05-11T15:38:53Z<p>Jky: </p>
<hr />
<div>{{SeealsoWP|Python (programming language)}}<br />
{{AN}} is a general-purpose very-high-level programming language.<br />
<br />
==IBM i implementation==<br />
<br />
There are currently two implementations for IBM i:<br />
* Native port of Python 2.7 by Per Gummedal, called iSeriesPython, for V5R3 and later<br />
* PASE port of Python 3.4 by IBM, as Option 2 of 5733-OPS (Open Source for IBM i Product) for 7.1 and later<br />
<br />
Another is expected in the near future:<br />
* PASE port of Python 2.7 by IBM, as Option 4 of 5733-OPS (Open Source for IBM i Product) for 7.1 and later<br />
<br />
==Hello world==<br />
<br />
===Python 2===<br />
print "Hello world"<br />
<br />
===Python 3===<br />
print("Hello world")<br />
<br />
==External links==<br />
* http://www.iseriespython.com<br />
* [http://www.itjungle.com/fhg/fhg082510-story01.html "An Introduction to Python on IBM i, Part 1"] by Garry Taylor, in ''The Four Hundred Guru'', Volume 10, Number 25 -- August 25, 2010<br />
* http://iseriespython.blogspot.ca<br />
* https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/IBM%20i%20Technology%20Updates/page/Python<br />
* https://www.gateway400.org/documents/Gateway400/Handouts/GetStartedWithPythonOnIBMi2016.pdf<br />
<br />
==Categories==<br />
{{stub}}<br />
[[Category:Programming languages]]</div>Jkyhttps://wiki.midrange.com/index.php?title=Python&diff=12133Python2016-05-11T15:34:16Z<p>Jky: </p>
<hr />
<div>{{SeealsoWP|Python (programming language)}}<br />
{{AN}} is a general-purpose very-high-level programming language.<br />
<br />
==System i implementation==<br />
Though not available on the i as an IBM [[LPP]], a native port of Python 2.7 by Per Gummedal is freely downloadable.<br />
<br />
There are no known implementations of Python 3.x for the i.<br />
<br />
===Hello world===<br />
print "Hello world"<br />
<br />
==External links==<br />
* http://www.iseriespython.com<br />
* [http://www.itjungle.com/fhg/fhg082510-story01.html "An Introduction to Python on IBM i, Part 1"] by Garry Taylor, in ''The Four Hundred Guru'', Volume 10, Number 25 -- August 25, 2010<br />
* http://iseriespython.blogspot.ca/<br />
<br />
==Categories==<br />
{{stub}}<br />
[[Category:Programming languages]]</div>Jkyhttps://wiki.midrange.com/index.php?title=Parameter_passing&diff=12132Parameter passing2016-04-26T14:53:04Z<p>Jky: Fixed a few apostrophe errors and other miscellaneous spelling/punctuation errors</p>
<hr />
<div>{{AN}} in IBM i<br />
<br />
This is a first cut at explaining the mechanism behind passing parameters from a [[command line]] or from a [[CLP]] program to other programs on the IBM i platform. Once someone edits this to something reasonable, hopefully it will include sub-procedures, too.<br />
<br />
=Summary=<br />
This might be the most frequently asked midrange question:<br />
''Why do I get garbage in my parameter when I call a program from the command line?''<br />
<br />
The answer is:<br />
''Write a command to wrap the program call.''<br />
<br />
This is a buffer overflow situation. The caller (the command line) sets aside a buffer that is the larger of:<br />
* 32 bytes OR<br />
* the number of characters you type (including spaces) between the quotes.<br />
<br />
If the callee declares its parameter as 128 bytes and you type something like '''CALL MYPGM 'ABC'''' on the command line, the command line sets aside 32 bytes, initialises it and calls your program. Which proceeds to read the 32 initialised bytes and also the remaining 96 uninitialised bytes - garbage.<br />
<br />
=Brief explanation=<br />
IBM i programs pass parameters by reference. This means that the caller and callee are using the same storage, defined in the caller. If the declaration of the parameters does not match exactly in type and length, unpredictable results may occur because the callee will be referring to storage that the caller did not set.<br />
<br />
Calling a program from the command line, or passing literals, the operating system has to make some assumptions about the declaration of the passed values:<br />
* all numeric literals are treated as packed decimal 15, 5<br />
* all other literals are treated as char(32) minimum or the number of characters between the quotes, whichever is longer.<br />
<br />
Using a user defined command for the caller, the exact matching declaration could be defined in the command and the operating system does all needed casting.<br />
<br />
<br />
=Detailed explanation=<br />
<br />
Taken from the [http://faq.midrange.com/data/cache/70.html Midrange FAQ]<br />
===CL Parameter Basics===<br />
<br />
When a variable is declared within a CL program, the system assigns storage for that variable within the program automatic storage area (PASA). If you subsequently use the variable as a parameter within a CALL command, the system does not pass the value of that variable to the called program, but rather a pointer to the PASA of the calling program. This is known as parameter passing by reference.<br />
<br />
For this reason, it is very important that both programs declare the parameter to be of the same type and size. To illustrate, let's look at the following example:<br />
PgmA: Pgm<br />
DCL &Var1 *CHAR 2 Inz( 'AB' )<br />
DCL &Var2 *CHAR 2 Inz( 'YZ' )<br />
Call PgmB Parm( &Var1 &Var2)<br />
EndPgm<br />
<br />
PgmB: Pgm Parm( &i_Var1 &i_Var2 )<br />
DCL &i_Var1 *CHAR 4<br />
DCL &i_Var2 *CHAR 2<br />
EndPgm<br />
<br />
Hopefully, you've noticed that the first parameter is declared to be larger in PgmB than it was in PgmA. Although you might expect &i_Var1 to contain 'AB ' after the call, the following is what the input parameters in PgmB actually contain:<br />
<br />
&i_Var1 = 'ABYZ'<br />
&i_Var2 = 'YZ'<br />
<br />
&i_Var1 shows the contents of the first parameter, and the second, because the second parameter is immediately adjacent to the first within the storage area. If the second parameter was not contiguous to the first, then the last two bytes of &i_Var1 would show whatever happened to be in the storage area at that time.<br />
<br />
You can think of &i_Var1 as a 4-byte "window" into the storage area of the calling program. It's passed a pointer that tells it where the view begins, and it accesses anything in storage from that point up to the parameter's declared length.<br />
<br />
===Looking at Literals===<br />
There are several ways that a program can be called, other than from another program. Examples include the command line, SBMJOB, job scheduler etc. In the case of an interactive call from the command line, you specify the parameters as literals, ie:<br />
<br />
Call PgmB Parm('AB' 'YZ')<br />
<br />
Consider that when we do this, there is no PASA. We'll look at the implications of that in a minute, but for now, just make a note of it.<br />
<br />
Submitting a job from the command line isn't any different. If you're submitting a CALL, then you'll be specifying any associated parameters as literals. However, things can get a bit deceiving when you submit a job from within a program, as the following example illustrates:<br />
PgmC: Pgm<br />
DCL &Var1 *CHAR 2 Inz( 'AB' )<br />
DCL &Var2 *CHAR 2 Inz( 'YZ' )<br />
SbmJob Cmd(Call PgmB Parm( &Var1&Var2))<br />
EndPgm<br />
<br />
Clearly, we're not passing literals here. Or are we?<br />
<br />
Let's think about how things would work if we passed variables:<br />
<br />
* PgmC submits a call to PgmB, passing two variables as parameters.<br />
* PgmC immediately ends as a result of the EndPgm statement.<br />
* PgmB begins running in batch and receives pointers to PgmC's PASA.<br />
* PgmB crashes when it attempts to use the pointers.<br />
<br />
We have invalid pointers because PgmC is no longer running. If you've ever tried this personally, you know that it doesn't happen in practice. The reason for that is that the system is converting those variables to literals before issuing the CALL command. Very sneaky, but effective.<br />
<br />
Now that we've seen some examples of where literals are used, and why, it's time to talk about the PASA again. When we discussed the basics of CL parameter passing, we learned that the called program expects to receive a pointer to a storage area within the PASA for each input parameter. This requirement hasn't changed. So now we have a situation where the CALL command is passing literals, but the called program is still expecting pointers.<br />
<br />
Obviously, it's time for the system to perform some more magic behind the scenes. In order to accomodate the requirements of the called program, the system creates a space in temporary storage for each literal being passed, and moves the value of the literal into that storage space. Now it can pass pointers to the called program, and everyone is happy.<br />
<br />
Except you that is, because none of this changes the fact that you're getting "garbage" in the input variables of your called program! Fair enough. I'm getting to that now, but you needed the background in order to understand the next part.<br />
Sizing It All Up<br />
<br />
Now that you know the system is creating variables behind the scene, you might wonder how it knows what size those variables need to be. The answer is that it doesn't. Instead, the designers have imposed some specific rules about how literals are transformed to variables, and thereby passed as parameters.<br />
<br />
CL supports only three basic data types: character, decimal, and logical. For the purposes of this discussion, you can consider the logical data type equivalent to the character type, because it's treated in the same manner.<br />
<br />
The simplest rule is the one that handles decimal literals. All decimal literals will be converted to packed decimal format with a length of (15 5), where the value is 15 digits long, of which 5 digits are decimal places. Therefore, any program that you expect to call from the command line, or SBMJOB etc., needs to declare its numeric input parameters as *DEC(15 5).<br />
<br />
Character literals are a little bit more complicated, but still fairly straightforward. There are two rules to remember. The first is that any character literal up to 32 characters in length will be converted to a 32 byte variable. The value is left justified, and padded on the right with blanks.<br />
<br />
So if you were to pass the following literal:<br />
<br />
Call PgmB 'AB'<br />
<br />
the associated storage space for that literal would contain:<br />
<br />
'ABxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' (where "x" represents a blank space)<br />
<br />
The second rule is that character literals longer than 32 bytes are converted to a variable of the same length as the literal value itself, as in the following example:<br />
<br />
Call PgmB 'This is a long character literal that will exceed 32 bytes.'<br />
<br />
the associated storage space for that literal would contain:<br />
<br />
'This is a long character literal that will exceed 32 bytes.'<br />
<br />
Finally, since the logical data type follows the same rules as the character type, and the only possible values for a logical data type are '0' or '1', we know that a logical literal will always be created as a 32 byte, left justified, padded character variable.<br />
<br />
===Command-Line or SBMJOB CMD(CALL) Parameter Problems===<br />
In the beginning of this explanation, you learned that it was important for the parameter declarations to match between a called program and its caller. Then you discovered that the system sometimes has to take it upon itself to declare the parameters of the caller on your behalf. If the two declarations don't match, we have the potential for trouble.<br />
<br />
In the case of a decimal value, the result is immediate and obvious; you get a data decimal error. Character variables are more difficult to debug because they don't generate any immediate errors. What actually happens depends upon the length of the parameter in the called program.<br />
<br />
If the length of the parameter in the called program is less than the length of the parameter being passed, the extra characters are effectively truncated, as follows:<br />
<br />
Call SomePgm ('ABCDEFG') /* system creates 32 byte *CHAR */<br />
<br />
SomePgm: Pgm Parm( &i_Var1 )<br />
DCL &i_Var1 *CHAR 4<br />
EndPgm<br />
<br />
What happens is that the system passes 'ABCDEFGxxxxxxxxxxxxxxxxxxxxxxxxx' ('x' is a blank), but because of the declared length of &i_Var1, SomePgm only sees 'ABCD'. For most of us, this is the behaviour that we would expect.<br />
<br />
Things get nasty when the declared length of the variable is longer than what is being passed in. Using the same example as we've just seen above:<br />
SomePgm: Pgm Parm( &i_Var1 )<br />
DCL &i_Var1 *CHAR 34<br />
EndPgm<br />
<br />
In this case, the system will still allocate 32 bytes of storage and assign 'ABCDEFGxxxxxxxxxxxxxxxxxxxxxxxxx' to it, but because &i_Var1 is now declared to be 34 bytes long, SomePgm will see more storage than it was intended to. It will see the 32 bytes that were allocated for it, plus two additional bytes. It's those two additional bytes that can cause the infamous "unpredictable results" which IBM's documentation often refers to.<br />
<br />
If the extra bytes contain blanks, chances are that you won't notice a problem, but if they contain something else, your input parameter will contain "garbage".<br />
<br />
As you can see, when dealing with literals, the magic number for character parameters is 32. If the called program declares the parameter to be less than or equal to 32, you'll never see "garbage" in the parameter. Once you cross that 32 byte threshhold, you need to take extra care to ensure that the size of the literal being passed is equal to the declared size of the input parameter.<br />
<br />
===Command-Line or SBMJOB CMD(CALL) Things to Remember===<br />
* always match the type/size of parameters on your pgm to pgm calls.<br />
* remember that the system converts literals to variables in the background.<br />
* remember that decimal literals are always converted to *DEC(15 5).<br />
* and that char literals less than or equal to 32 bytes are converted to *CHAR(32).<br />
* and that char literals greater than 32 bytes are converted to variables of equivalent size.<br />
<br />
and last, but not least:<br />
<br />
* the called program "sees" as much storage as it declares for an input parameter, regardless of whether or not the caller actually allocated that much storage for it.<br />
<br />
Taken from the [http://faq.midrange.com/data/cache/197.html Midrange FAQ]<br />
<br />
When one runs debug and sees garbage in input parameters, it's often due to a mismatch in definition or size between the caller and called programs.<br />
<br />
Some solutions:<br />
<br />
* Solution 1: For SBMJOB, do not use the CMD() parameter to pass a CALL command if the PARMs contain *CHAR variables greater than 32 bytes in size that need trailing blanks. Construct the RQSDTA() string instead.<br />
* Solution 2: Store all numerics being used as parameters as 15,5 packed.<br />
* Solution 3: Store all parameters embedded in a character datastructure and pass a single parameter, the datastructure.<br />
* Solution 4: Use another object, such as a file or a data area, to contain the parameters.<br />
* Solution 5: And my favorite. Write your own command and use that, instead of CALL, on your SBMJOB commands.<br />
<br />
SBMJOB has a parameter called CMD. Traditionally people put a CALL command here, and then call their program directly.<br />
<br />
Let's say you have a RPG program which calls another program. The first program has a screen which processes some information and passes it to the second program. And maybe this second program is rather intensive and you want that to run in batch. Then you may have the following in your first program:<br />
<br />
C CALL 'MYPGM'<br />
C PARM MYNBR 50<br />
<br />
Then you create a source member of type CMD. And this may contain:<br />
<br />
CMD PROMPT('Your description here')<br />
PARM KWD(MYNBR) TYPE(*DEC) LEN(5) MIN(1) CHOICE('Valid +<br />
number') PROMPT('Enter number here')<br />
<br />
To compile this you do CRTCMD CMD(MYLIB/MYPGM) PGM(MYLIB/MYPGM)<br />
<br />
To see how this looks you can they type in the following at a command line MYPGM and hit <Enter> and you will get a prompt screen. Yes, you can design a 400 screen with so few lines of code.<br />
<br />
And your second program may have:<br />
<br />
PGM ( +<br />
&PARM1 /* My numeric variable */ +<br />
&PARM2 /* */ +<br />
)<br />
DCL &PARM1 *DEC 5 /* My numeric variable */<br />
DCL &JOBINFO *CHAR 1 /* 1=Interactive, 0=Batch */<br />
/* +<br />
| Retrieve current job type +<br />
*/<br />
RTVJOBA TYPE(&JOBINFO)<br />
/* +<br />
| Submit job if currently interactive +<br />
*/<br />
IF COND(&JOBINFO = '1') THEN(DO)<br />
SBMJOB CMD(MYPGM MYNBR(&MYNBR))<br />
GOTO CMDLBL(END)<br />
ENDDO<br />
/* +<br />
| Do your real processing here +<br />
*/<br />
END:<br />
ENDPGM<br />
<br />
Further background [http://faq.midrange.com/data/cache/57.html Midrange FAQ]<br />
<br />
Q When I pass numeric parameters to my RPG program from the command line my program isn't working as expected, why?<br />
<br />
A The command line doesn't know what type of parameters it is trying to pass, so it converts all numeric variables into 15,5 before passing them.<br />
<br />
Number of work arounds include:<br />
<br />
Create a command to call the RPG program, which will convert the numeric variables to the length declared in the command.<br />
Pass the numeric values as character data (i.e. PARM('0009') rather than PARM(9))<br />
<br />
This is part of a common misunderstanding of how to pass a<br />
constant as a parameter.<br />
<br />
The caller's parameter definitions must match the called<br />
program's definitions. The command line has no way to<br />
declare a variable so it uses a default type and length.<br />
<br />
Numeric default is packed 15, 5 decimals (8 bytes).<br />
Character default is character 32 bytes.<br />
<br />
The manual that describes this is the OS/400 CL Programming manual,<br />
section 3.4 (Passing Parameters between Programs and Procedures)<br />
http://publib.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/qb3auo03/3.4<br />
<br />
Check out the helpful section entitled<br />
Common Errors when calling Programs and Procedures at<br />
http://publib.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/qb3auo03/3.4.2<br />
<br />
...and also the section entitled<br />
Using the Call Command at<br />
http://publib.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/qb3auo03/3.4.1<br />
(all references V4R5)<br />
<br />
All of this is predicated on the concept that you MUST pass a<br />
constant from the command line by a mechanism like<br />
SBMJOB CMD(call myprog ('VALUE1' 25.00 'VALUE2'))<br />
You could also write a command as a wrapper so you'd end up<br />
with something more like SBMJOB CMD(PRTATB VALUE1 25.00 VALUE2)<br />
<br />
Taken from the [http://faq.midrange.com/data/cache/576.html Midrange FAQ]<br />
<br />
===Creating a simple command processing program===<br />
A simple CMD object, without any of the great bells and whistles capable<br />
of within a CMD object can be created quite easily from a CL program. For<br />
example, take the following:<br />
<br />
PGM PARM(&WSIDX &JBTYPE)<br />
DCL VAR(&WSID) TYPE(*CHAR) LEN(10)<br />
DCL VAR(&WSIDX) TYPE(*CHAR) LEN(10)<br />
DCL VAR(&JOBQ) TYPE(*CHAR) LEN(10)<br />
DCL VAR(&JOBQLBR) TYPE(*CHAR) LEN(10)<br />
DCL VAR(&JOBD) TYPE(*CHAR) LEN(10)<br />
DCL VAR(&JBTYPE) TYPE(*CHAR) LEN(1)<br />
...<br />
<br />
Just copy this from QCLSRC to QCMDSRC.<br />
Change the type from CLP to CMD.<br />
Drop all lines except the PGM and any variables that appear on the PGM<br />
statement.<br />
PGM PARM(&WSIDX &JBTYPE)<br />
DCL VAR(&WSIDX) TYPE(*CHAR) LEN(10)<br />
DCL VAR(&JBTYPE) TYPE(*CHAR) LEN(1)<br />
<br />
Change the DCL to PARM<br />
PGM PARM(&WSIDX &JBTYPE)<br />
PARM VAR(&WSIDX) TYPE(*CHAR) LEN(10)<br />
PARM VAR(&JBTYPE) TYPE(*CHAR) LEN(1)<br />
<br />
Drop the VAR from the PARM commands<br />
PGM PARM(&WSIDX &JBTYPE)<br />
PARM (&WSIDX) TYPE(*CHAR) LEN(10)<br />
PARM (&JBTYPE) TYPE(*CHAR) LEN(1)<br />
<br />
Drop the ampersand, and maybe the parenthesis<br />
PGM PARM(&WSIDX &JBTYPE)<br />
PARM WSIDX TYPE(*CHAR) LEN(10)<br />
PARM JBTYPE TYPE(*CHAR) LEN(1)<br />
<br />
And, now that you got the variables down, change the PGM to a CMD and drop<br />
the parameters<br />
CMD<br />
PARM WSIDX TYPE(*CHAR) LEN(10)<br />
PARM JBTYPE TYPE(*CHAR) LEN(1)<br />
<br />
This will compile successfully and work just fine. This is a quick and<br />
dirty way to convert a SBMJOB CMD(CALL ... that's getting you into all<br />
sorts of trouble because of parameters lengths to a nice SBMJOB<br />
CMD(MYCMD... that won't have that trouble.<br />
<br />
Now, there's a lot more potential there. Like keyword prompting, default<br />
values, multiple list items, indents like library/object and so on. But<br />
this will do that fast conversion.<br />
<br />
==Categories==<br />
{{stub}}</div>Jkyhttps://wiki.midrange.com/index.php?title=Python&diff=11732Python2014-06-03T04:36:43Z<p>Jky: </p>
<hr />
<div>{{SeealsoWP|Python (programming language)}}<br />
{{AN}} is a general-purpose very-high-level programming language.<br />
<br />
==System i implementation==<br />
Though not available on the i as an IBM [[LPP]], a native port of Python 2.7 by Per Gummedal is freely downloadable.<br />
<br />
There are no known implementations of Python 3.x for the i.<br />
<br />
===Hello world===<br />
print "Hello world"<br />
<br />
==External links==<br />
* http://www.iseriespython.com<br />
* [http://www.itjungle.com/fhg/fhg082510-story01.html "An Introduction to Python on IBM i, Part 1"] by Garry Taylor, in ''The Four Hundred Guru'', Volume 10, Number 25 -- August 25, 2010<br />
<br />
==Categories==<br />
{{stub}}<br />
[[Category:Programming languages]]</div>Jkyhttps://wiki.midrange.com/index.php?title=Python&diff=11731Python2014-06-03T04:33:09Z<p>Jky: /* System i implementation */</p>
<hr />
<div>{{SeealsoWP|Python (programming language)}}<br />
{{AN}} is a is a general-purpose high-level programming language.<br />
<br />
==System i implementation==<br />
Though not available on the i as an IBM [[LPP]], a native port of Python 2.7 by Per Gummedal is freely downloadable.<br />
<br />
There are no known implementations of Python 3.x for the i.<br />
<br />
===Hello world===<br />
print "Hello world"<br />
<br />
==External links==<br />
* http://www.iseriespython.com<br />
* [http://www.itjungle.com/fhg/fhg082510-story01.html "An Introduction to Python on IBM i, Part 1"] by Garry Taylor, in ''The Four Hundred Guru'', Volume 10, Number 25 -- August 25, 2010<br />
<br />
==Categories==<br />
{{stub}}<br />
[[Category:Programming languages]]</div>Jkyhttps://wiki.midrange.com/index.php?title=Main_Page/Draft&diff=11730Main Page/Draft2014-06-03T04:24:43Z<p>Jky: /* Languages */</p>
<hr />
<div>----<br />
This is a testing area for revisions, overhauls and improvements to the [[Main Page]]. This is needed because the wiki software, [[wikipedia:MediaWiki|MediaWiki]], has the Main Page configured to be one of a small set of pages which only a user with administrative edit privileges can edit, to prevent spam or vandalism.<br />
----<br />
Below is a copy of the Main Page wiki-code as of '''15:47, 4 November 2013 (CST)''' &mdash;&nbsp;[[User:MrDolomite|MrDolomite]]&nbsp;•&nbsp;[[User talk:MrDolomite|Talk]] <!--- to update use '''~~~~~''' ~~~ ---><br />
----<br />
<big><big><big><big>'''Welcome to the {{midrangeWiki}}!'''</big></big></big></big><br />
[[Image:Midrangewikilogo.png|right|200px]]<br />
<br />
==Welcome==<br />
{{boxright|See [[Main Page/Draft]]|An article everyone can edit<br>to improve the face of {{SITENAME}}}}<br />
The goal of this site is to provide information on the [[IBM]] i / [[System i]] / [[eServer]] [[iSeries]] / [[AS/400]] system (yes, it has had a number of [[names]]).<br />
<br />
All categories can be found in [[:Special:Categories]] and {{ccl|Categories}}.<br />
<br />
==Overview==<br />
<br />
* [[Iseries|iSeries Hardware]]<br />
* [[OS/400|OS/400]]<br />
* [[Why i|Why i?]]<br />
<br />
== Operations ==<br />
* [[GettingStarted|Getting Started Guide]]<br />
* [[:Category:Commands|Commands]]<br />
* [[:Category:Security|Security]]<br />
* [[:Category:Quick Reference| Quick References]]<br />
* [[:Category:SQL|Structured Query Language (SQL)]]<br />
* [[:Category:HMC|Hardware Managment Console]]<br />
* [[:Category:Tips And Techniques|Tips and Techniques]]<br />
<br />
==Programming==<br />
* [[Programming]]<br />
<br />
===Languages===<br />
* [[:Category:CLP|CLP]]<br />
* [[:Category:RPG|RPG]]<br />
* [[:Category:COBOL|COBOL]]<br />
* [[:Category:.NET|.NET]]<br />
* [[:Category:Java|Java]]<br />
* [[PHP]]<br />
* [[REXX]]<br />
* [[Python]]<br />
<br />
===Tools ===<br />
* [[:Category:API]]<br />
<br />
===Editors===<br />
* [[DFU]]<br />
* [[SDA]]<br />
* [[SEU]]<br />
* [[WDSC]]<br />
* [[EDTF]]<br />
<br />
== Certifications ==<br />
* [[:Category:Certifications|Certifications]]<br />
<br />
== Software ==<br />
* [[:Category:Software|Software]]<br />
<br />
== Midrange People in Social Media ==<br />
* [[Twitter|Midrange People on Twitter]]<br />
<br />
== Other Information ==<br />
One of the goals of this Wiki is to replace the current Midrange FAQ with a somewhat more robust system. The current effort can be found in [[:Category:FAQ | here]].<br />
<br />
The primary administrator for this site is [[User:David|David Gibbs]].<br />
<br />
[[Category:Categories|*Main Page]]</div>Jkyhttps://wiki.midrange.com/index.php?title=Category:RPG&diff=11729Category:RPG2014-06-03T03:20:19Z<p>Jky: </p>
<hr />
<div>'''RPG''' is an acronym which stands for {{bu|R|eport}} {{bu|P|rogram}} {{bu|G|enerator}}. It is a programming language developed by IBM originally created for developing business applications. <br />
<br />
{{SeeAlsoWP|RPG programming language}}<br />
<br />
Programmers, coming to RPG from other programming environments, will still need to get some education to familiarize themselves with its capabilities, and how it functions.<br />
<br />
There are four major versions of RPG currently in use... [[RPG II]], [[RPG III]], [[RPG 400]], and [[RPG IV]] (sometimes referred to as [[ILE]] RPG). The latter has two distinctive flavours: the traditional column restricted language entry and the modern /Free alternative where most of the coding can be entered in a non-column restricted way.<br />
<br />
RPG is most commonly associated with IBM Midrange platforms, however various RPG flavors have been developed for other platforms over the years including the IBM 1401, System/360, S/370 and follow-ons; the Hewlett Packard HP3000 [http://docs.hp.com/cgi-bin/doc3k/B3031890001.10422/1]; as well as Wang, Sperry, Burroughs, and Digital PDP and VAX computers. While never immensely popular on non-IBM platforms, it did exist outside of IBM.<br />
<br />
[[OS/400]] contains extensive support for debugging and run-time identification of RPG code. There is a large established base of RPG code in production environments, usually performing heavy-lifting batch-oriented data tasks, or providing support for interactive [[ERP]] applications, either with native [[5250]] interface or with a graphical user interface ([[GUI]]) or Web [[Skin]] applied over the [[5250]] data stream.<br />
<br />
== RPG vs. other languages ==<br />
Compared to other programming languages, RPG is especially strong in <br />
* transactional processing;<br />
* data base access, such as [[DB2]];<br />
<br />
The main perceived flaw with RPG is that it is not object oriented, nor does it contain direct support for a (GUI), although there are [[RPG Third Party]] offerings to fill that gap.<br />
<br />
=== RPG vs. Java ===<br />
A comparison between RPG and [[Java]] can be made so long as Java is used in a developer framework, or one of the available [[application servers]]. Unlike Java, however, RPG contains language-level features for common business tasks such as database access.<br />
<br />
=== Objects and RPG ===<br />
Although RPG is perceived as not being object-oriented, the OS/400 operating system is composed entirely of objects that can be manipulated by RPG and other languages.<br />
<br />
RPG has long had the capability of importing standardized blocks of code to do standard functions via [[Slash COPY|/COPY]]. Additionally, several versions of RPG support [[CALL|calling]] a sub-program, thus many aspects of object management are facilitated within RPG.<br />
<br />
== APIs ==<br />
[[API]] stands for Application Program Interface. RPG has access to C functions via service programs in binding directory QC2LE, as well as CEE APIs. There are also APIS specific to IBM i, like IFS access.<br />
<br />
A new API mechanism is called IBM Rational Open Access: RPG Edition <ref>IBM United States Software Announcement 210-114 , [http://www-01.ibm.com/common/ssi/cgi-bin/ssialias?subtype=ca&infotype=an&appname=iSource&supplier=897&letternum=ENUS210-114 IBM Rational Open Access: RPG Edition delivers RPG IV extensibility to access new devices and resources ],13 Apr 2010. Retrieved on 19 Apr 2010</ref> Open Access is a separately purchased product for IBM i 6.1 and above via handlers similar to using SPECIAL files.<br />
<br />
== Conditional compilation ==<br />
Conditional compilation is a mechanism that allows you to include or omit sections of code based on the compilation environment. This is in contrast to editing the code to add or remove sections. A typical reason for conditional compilation is code only used during testing. Imagine a scenario where you're writing a program that will perform a web service. Putting it in debug might be problematic because halting on a breakpoint will stop all web users from seeing results. So you insert code that logs useful information to an IFS file. Unfortunately, leaving that code in all the time slows execution down too much. One solution is conditional compilation.<br />
<br />
Conditional compilation uses condition-names as the main driver. In conjunction with condition-names, compiler directives /IF, /ENDIF, /ELSE and /ELSEIF are used to perform the tests the compiler will use to determine whether to include a section of code or not. Condition-names can be predefined by the compiler, or defined by the developer via /DEFINE and /UNDEFINE. There is one last directive, /EOF, which tells the compiler to ignore any remaining source lines in the source member.<br />
<br />
An example might make this easier.<br />
<br />
<pre><br />
/if defined(LOG_FULL)<br />
logDebug('customer credit code': creditCode)<br />
logDebug('customer A/R balance': %editc(balance: 'J')<br />
/endif<br />
</pre><br />
<br />
If LOG_FULL is defined, either in the compile command: DEFINE(LOG_FULL), or within the source code: /DEFINE LOG_FULL then this logging code is included and compiled. If LOG_FULL is not defined, that code is not compiled.<br />
<br />
RPG comes with some useful predefined condition-names:<br />
<br />
{| class="wikitable" class=sortable style="position:relative; margin: 0 0 0.5em 1em; border-collapse: collapse; background:white; clear:right; text-align:left;" border="1" cellpadding="3"<br />
|-<br />
! i5/OS version<br />
! Condition-name<br />
! Purpose<br />
|-<br />
| V5R4<br />
| *CRTRPGMOD<br />
| Set if the compilation command is CRTRPGMOD<br />
|-<br />
| V5R4<br />
| *CRTBNDRPG<br />
| Set if the compilation command is CRTBNDRPG<br />
|-<br />
| V5R4<br />
| *VxRxMx<br />
| Set if the TGTRLS on the compile command is this level OR LATER. For example, if *V5R4M0 is specified, it will evaluate true if TGTRLS is V5R4, 6.1, 7.1 or higher.<br />
|}<br />
<br />
Examples:<br />
<pre><br />
/if defined(*CRTBNDRPG)<br />
H dftactgrp(*no) actgrp('MYCOMPANY')<br />
/endif<br />
</pre><br />
<br />
<pre><br />
/if defined(*V5R4M0)<br />
callp someV5R4API();<br />
/else<br />
callp ourHandWrittenVersion();<br />
/endif<br />
</pre><br />
<br />
<br />
{{stub}}<br />
<br />
== Open Source Sites ==<br />
* http://iseries-toolkit.sourceforge.net/<br />
* http://www.scottklement.com/oss.html<br />
* http://www.martinvt.com/Code_Samples/code_samples.html<br />
* http://Netshare400.com<br />
* http://www.think400.dk (Danish)<br />
* http://home.alltel.net/craigru/jcrcmd2.html<br />
* http://sourceforge.net/projects/iseriestoexcel<br />
* http://www.rpgiv.com/downloads/<br />
* http://www.code400.com<br />
* http://mowyourlawn.com/<br />
* http://www.rpgnext.com/tutorials.php<br />
* http://www.rpgunit.org<br />
* http://www.opensource4i.com/<br />
<br />
== External Links ==<br />
* RPG Developer Network http://www.rpgiv.com/<br />
* "RPG: A Great Language with a Greater History" by Brian Kelly, The Four Hundred, Volume 18, Number 30 -- August 17, 2009 [http://www.itjungle.com/tfh/tfh081709-story01.html]<br />
<br />
== References ==<br />
<references /><br />
<br />
[[Category:Programming languages]]</div>Jkyhttps://wiki.midrange.com/index.php?title=Category_talk:RPG&diff=11728Category talk:RPG2014-06-03T03:15:55Z<p>Jky: </p>
<hr />
<div>I would like to remove the suggestion that RPG is object-oriented. I feel uncomfortable unilaterally editing it, as I'm completely new to this wiki, and I would at least like to see how other people feel about it first. From where I'm sitting, RPG is "perceived as not object-oriented" because it's simply not. At least not in the sense that anyone else in the world talking about OOP means. So, thoughts, anyone? [[User:Jky|jky]] ([[User talk:Jky|talk]]) 19:42, 29 May 2014 (CDT)<br />
<br />
I see the 'Objects and RPG' section as a bit odd as well, and I have over 3 decades of RPG experience. I think it was a way of trying to introduce IBM i into the topic. IBM i is quite important as far as RPG goes, because it is for all practical purposes impossible to separate RPG from IBM i. If you're still uncomfortable removing the lines, definitely feel free to make an edit that clarifies that RPG does not implement inheritance or polymorphism. We do have a limited subset of encapsulation though. [[User:Starbuck5250|Buck]] ([[User talk:Starbuck5250|talk]]) 15:09, 2 June 2014 (CDT)<br />
<br />
Hmm. Actually, now that I read the whole thing more carefully, I have to say I'm even more uncomfortable, because honestly, the article needs a lot of love to get it into shape. When the API section starts, we're most likely not talking about RPG vs. other languages anymore, despite the styling cues. Everything between the "RPG vs. other languages" heading and the "API" heading reads as very defensive. As if RPG is being bullied by proponents of other languages, who don't know enough about RPG to give it a fair shake. And maybe they don't know enough, but as someone who learned other languages before and after learning RPG, the "defense" only makes it sound like the RPG proponents are the ones who are suffering from ignorance of other languages. And that's unfortunate, because I don't think the language needs defending, it just needs to be presented accurately. That's all any language needs or deserves, really. I'll have to mull it over and write some drafts. [[User:Jky|jky]] ([[User talk:Jky|talk]]) 22:15, 2 June 2014 (CDT)</div>Jkyhttps://wiki.midrange.com/index.php?title=Category_talk:RPG&diff=11726Category talk:RPG2014-05-30T00:42:23Z<p>Jky: </p>
<hr />
<div>I would like to remove the suggestion that RPG is object-oriented. I feel uncomfortable unilaterally editing it, as I'm completely new to this wiki, and I would at least like to see how other people feel about it first. From where I'm sitting, RPG is "perceived as not object-oriented" because it's simply not. At least not in the sense that anyone else in the world talking about OOP means. So, thoughts, anyone? [[User:Jky|jky]] ([[User talk:Jky|talk]]) 19:42, 29 May 2014 (CDT)</div>Jkyhttps://wiki.midrange.com/index.php?title=Category_talk:RPG&diff=11725Category talk:RPG2014-05-30T00:41:54Z<p>Jky: Created page with "I would like to remove the suggestion that RPG is object-oriented. I feel uncomfortable unilaterally editing it, as I'm completely new to this wiki, and I would at least like ..."</p>
<hr />
<div>I would like to remove the suggestion that RPG is object-oriented. I feel uncomfortable unilaterally editing it, as I'm completely new to this wiki, and I would at least like to see how other people feel about it first. From where I'm sitting, RPG is "perceived as not object-oriented" because it's simply not. At least not in the sense that anyone else in the world talking about OOP means. So, thoughts, anyone?</div>Jky