PHP Arrays for RPG Programmers



Similar documents
PHP on IBM i: What s New with Zend Server 5 for IBM i

MySQL for IBM i Or Zend DBi == MySQL!

The C Programming Language course syllabus associate level

Bring your intranet to the IBM i With Drupal and Zend Server

Collaborative Open Source with PHP on IBM i

SmartArrays and Java Frequently Asked Questions

ALLIED PAPER : DISCRETE MATHEMATICS (for B.Sc. Computer Technology & B.Sc. Multimedia and Web Technology)

Stacks. Linear data structures

CHAPTER 7: The CPU and Memory

C Programming. for Embedded Microcontrollers. Warwick A. Smith. Postbus 11. Elektor International Media BV. 6114ZG Susteren The Netherlands

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

PHP Batch Jobs on IBM i. Alan Seiden Consulting alanseiden.com

El Dorado Union High School District Educational Services

Microsoft Windows PowerShell v2 For Administrators

Oracle Database: SQL and PL/SQL Fundamentals NEW

Introduction to Python

VB.NET Programming Fundamentals

1 Description of The Simpletron

Bring your intranet to the IBM i With Drupal and Zend Server

Fundamentals of Java Programming

Database Programming with PL/SQL: Learning Objectives

The Clean programming language. Group 25, Jingui Li, Daren Tuzi

Efficient Data Structures for Decision Diagrams

Summit Public Schools Summit, New Jersey Grade Level / Content Area: Mathematics Length of Course: 1 Academic Year Curriculum: AP Computer Science A

Visual Basic Programming. An Introduction

Oracle Database: SQL and PL/SQL Fundamentals

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?

AP Computer Science Java Subset

Chapter 2: Elements of Java

Arrays in Java. Working with Arrays

Web Development using PHP (WD_PHP) Duration 1.5 months

protocol fuzzing past, present, future

1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D.

PO-18 Array, Hurray, Array; Consolidate or Expand Your Input Data Stream Using Arrays

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.

Oracle Database: SQL and PL/SQL Fundamentals

MICROPROCESSOR AND MICROCOMPUTER BASICS

Oracle Database: SQL and PL/SQL Fundamentals NEW

A binary search tree or BST is a binary tree that is either empty or in which the data element of each node has a key, and:

1.4 Arrays Introduction to Programming in Java: An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Copyright /6/11 12:33 PM!

Solid State Storage in a Hard Disk Package. Brian McKean, LSI Corporation

Changing the Display Frequency During Scanning Within an ImageControls 3 Application

Perl in a nutshell. First CGI Script and Perl. Creating a Link to a Script. print Function. Parsing Data 4/27/2009. First CGI Script and Perl

Lab Experience 17. Programming Language Translation

1 Classical Universal Computer 3

WebSphere Business Monitor

I PUC - Computer Science. Practical s Syllabus. Contents

PHP in the Enterprise

Java (12 Weeks) Introduction to Java Programming Language

Jonathan Worthington Scarborough Linux User Group

Oracle Database 12c: Introduction to SQL Ed 1.1

Instruction Set Architecture (ISA)

AQA GCSE in Computer Science Computer Science Microsoft IT Academy Mapping

Programming and Software Development (PSD)

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

Certified PHP/MySQL Web Developer Course

In this Chapter you ll learn:

arrays C Programming Language - Arrays

Embedding SQL in High Level Language Programs

Glossary of Object Oriented Terms

Magento & Zend Benchmarks Version 1.2, 1.3 (with & without Flat Catalogs)

Class Overview. CSE 326: Data Structures. Goals. Goals. Data Structures. Goals. Introduction

by NetMedia, Inc. All rights reserved. Basic Express, BasicX, BX-01, BX-24 and BX-35 are trademarks of NetMedia, Inc. 2.

C++ INTERVIEW QUESTIONS

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

Why move to Free-Form RPG?

Python Lists and Loops

Introduction to Java

Field Properties Quick Reference

16. Recursion. COMP 110 Prasun Dewan 1. Developing a Recursive Solution

Overview. What is software testing? What is unit testing? Why/when to test? What makes a good test? What to test?

Visual Logic Instructions and Assignments

Name = array(x,y,...,z) the indexing starts at zero, i.e. Name(0) = x. Programming Excel/VBA Part II (A.Fring)

Chapter 3: Restricted Structures Page 1

Microsoft Office 2010: Access 2010, Excel 2010, Lync 2010 learning assets

Facebook Twitter YouTube Google Plus Website

Hash Tables. Computer Science E-119 Harvard Extension School Fall 2012 David G. Sullivan, Ph.D. Data Dictionary Revisited

Chapter 07: Instruction Level Parallelism VLIW, Vector, Array and Multithreaded Processors. Lesson 05: Array Processors

Moving from CS 61A Scheme to CS 61B Java

Object Oriented Software Design

PROBLEM SOLVING SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON

CMSC 202H. ArrayList, Multidimensional Arrays

CHM 579 Lab 1: Basic Monte Carlo Algorithm

Objective C and iphone App

Introduction to Computers and Programming. Testing

Interoperable Web Services for Building Automation Integrating KNX. KNX Scientific Conference 2006

Jet Data Manager 2012 User Guide

CS 2112 Spring Instructions. Assignment 3 Data Structures and Web Filtering. 0.1 Grading. 0.2 Partners. 0.3 Restrictions

Storing Measurement Data

Advanced SQL. Jim Mason. Web solutions for iseries engineer, build, deploy, support, train

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals

INTRODUCTION TO BUSINESS INTELLIGENCE What to consider implementing a Data Warehouse and Business Intelligence

1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++

Symbol Tables. Introduction

Java Map and Set collections

SQL Basics for RPG Developers

Transcription:

PHP Arrays for RPG Programmers Mike Pavlak Solutions Consultant mike.p@zend.com (815) 722 3454 Function Junction All rights reserved. Zend Technologies, Inc.

PHP Sessions Session 1-9:00 Session 2-:30 11:45 Session 3-12:30 Session 4-1:45 Session 5-3:00 4:00 PHP1 PHP Arrays for the RPG Programmer Lunch PHP Function Junction PHP Toolkit Functions Build your Intranet on IBM i for Free Goodies! 2 Copyright 2009 Zend Technologies, Inc, All rights All rights reserved. Zend Technologies, Inc. 02/03/ reserved

Agenda Introduce arrays in PHP Review RPG arrays Compare RPG and PHP array concepts More functions for arrays in PHP Q&A 3 All rights reserved. Zend Technologies, Inc.

Why are we talking about arrays? Fastest method for manipulating ordered sets Highly leveraged in PHP development PHP developers take them for granted Available in RPG but long neglected Gap that needs to be closed Array defined: a data structure consisting of a group of elements that are accessed by indexing 4 All rights reserved. Zend Technologies, Inc.

PHP Array Examples All rights reserved. Zend Technologies, Inc.

Data Type Review: 8 Data Types Scalar String the quick brown fox..., 123456 Integer 860, -9, 57009 Floating point 19.99, 29.99, 3.1412 Boolean true, false Compound Array [0] => 0 [1] => 1 [2] => 1 [3] => 2 [4] => 3 Object OOP Special Resource Handle Null Something that not nothing (empty set) 6 All rights reserved. Zend Technologies, Inc.

Three types of arrays Enumerated Simple list Associative Custom key $arrayone = array( Scooby, Shaggy, Daphne, Fred, Velma ); $arraytwo = array( Cartoon1=> Scooby, Cartoon2=> Shaggy, Cartoon3=> Daphne, Cartoon4=> Fred, Cartoon5=> Velma ); Multidimensional Array of arrays $arraythree = array( array( Scooby, Shaggy, Daphne, Fred, Velma ), array( Bugs, Daffy, Tweety, Elmer, Foghorn ) ); 7 All rights reserved. Zend Technologies, Inc.

Enumerated array Code: Output: Array one: Array ( [0] => Scooby [1] => Shaggy [2] => Daphne [3] => Fred [4] => Velma ) 8 All rights reserved. Zend Technologies, Inc.

Associative array Code: Output: Array two: Array ( [Cartoon1] => Scooby [Cartoon2] => Shaggy [Cartoon3] => Daphne [Cartoon4] => Fred [Cartoon5] => Velma ) If you have trouble, think CL command parameters: Keyword & Values!!! 9 All rights reserved. Zend Technologies, Inc.

Multidimensional array Code: Output: Array three: Array ( [0] => Array ( [0] => Scooby [1] => Shaggy [2] => Daphne [3] => Fred [4] => Velma ) [1] => Array ( [0] => Bugs [1] => Daffy [2] => Tweety [3] => Elmer [4] => Foghorn ) ) All rights reserved. Zend Technologies, Inc.

Adding elements & growing the array PHP Arrays are dynamic Can be sized on the fly, no need to recompile Example adding element: 11 All rights reserved. Zend Technologies, Inc.

Removing elements & reducing the array array_pop removes element from the end unset removes an element you specify (or entire array!) 12 All rights reserved. Zend Technologies, Inc.

Trivia points Really only one type of array, associative Data content is non-restrictive, any data types Each element can be different Array sizes change dynamically Supports no known limit of dimensions! Memory! Humans like 2 or 3 (Think spreadsheet and workbook) Used heavily in i/o Both keys and content can be dynamic Index starts at zero while RPG starts at one 13 All rights reserved. Zend Technologies, Inc.

Got Doc? php.net/array 14 All rights reserved. Zend Technologies, Inc.

Review RPG Arrays All rights reserved. Zend Technologies, Inc.

In the beginning Indicators were the only ordered set Original RPG and RPG II Name Indicators Notes Numbered *IN01-*IN99 Gen purpose Command Key *INKA - *INKY No O Halt H1-H9 Error recovery Matching M1-M9, MR Matching records Control L1-L9 Level Breaks External U1-U8 Switches Cycle 1P, LR, OA-OG, OV Printing 16 All rights reserved. Zend Technologies, Inc.

And then RPG II - Then came simple arrays. Predefined length Single variable data type Built in E-specs Op Codes XFOOT Summing aray MOVEA Move data (Still most extremely powerful) LOKUP Search the array SORTA Gee, I wonder what this does? Seems like things paused here for a while 17 All rights reserved. Zend Technologies, Inc.

Today Compile time tables Great for static content Defined below O specs Two dimensional in nature RPG III Multiple Occurrence Data Structure (MODS) Two dimensional feel Still a little clunky RPG IV More Power! V5R1 BIF s : %LOOKUP, %LOOKUPGT, etc. V5R2 DIM for Data Structures; MODS on Steroids! V5R3 %SUBARR is an attempt at dynamic sizing V5R4 XML processing i6.1 DIM up to 16,773,4 18 All rights reserved. Zend Technologies, Inc.

How PHP matches up to RPG All rights reserved. Zend Technologies, Inc.

Array shootout Base functions RPG has about a dozen op-codes and BIF s (Variations on BIF s) Many op-codes can manipulate array content PHP has 75 functions www.php.net/array Size RPG has limits, 16,773,4 as if i6.1 PHP has no practical limits, No array index overflow error RPG array must be defined, PHP grows dynamically Type RPG uses static typing (one type, one length) PHP is dynamically typed (Each element can be different) 20 All rights reserved. Zend Technologies, Inc.

Simple Array Search (Lookup) RPG PHP I found her in position==> 2 21 All rights reserved. Zend Technologies, Inc.

Simple traverse RPG PHP Scooby is the index value 0 Shaggy is the index value 1 Daphne is the index value 2 Fred is the index value 3 Velma is the index value 4 22 All rights reserved. Zend Technologies, Inc.

RPG to PHP function map Function RPG PHP Notes Search %LOOKUP array_search Sum %XFOOT array_sum Array_prod can multiply Get portion %SUBARR array_slice Substring an array by chunks Sort SORTA asort, arsort PHP sequence dynamic Move MOVEA array_slice Substring by character Count %ELEM count Get number of elements 23 All rights reserved. Zend Technologies, Inc.

More functions in PHP All rights reserved. Zend Technologies, Inc.

Interesting functions How to move around the array Randomize contents Array housekeeping Move array elements to variables Sort two or more arrays at once Execute a function on each element with no loop! Data file example 25 All rights reserved. Zend Technologies, Inc.

Navigate the array Thanks Jon! 26 All rights reserved. Zend Technologies, Inc.

Mix it up with a shuffle 27 All rights reserved. Zend Technologies, Inc.

Consolidate, clean and sort arrays 28 All rights reserved. Zend Technologies, Inc.

Sort Multiple Arrays at once! 29 All rights reserved. Zend Technologies, Inc.

Manipulate all elements of an array 30 All rights reserved. Zend Technologies, Inc.

Get data from a file Loop through data List function copies to variables Implicit copy, be careful Arrays in PHP like Data Structures in RPG: The workhorse of data manipulation! 31 All rights reserved. Zend Technologies, Inc.

New book, new printing, same great stuff! Kevin Schroeder from Zend s Global Services Group with Jeff Olen, co-author of Get yours at MCPressonline or at fine bookstores everywhere All rights reserved. Zend Technologies, Inc.

Q&A www.zend.com mike.p@zend.com Insert->Header 33 & Footer All rights reserved. Zend Technologies, Inc.