Skip to content

Instantly share code, notes, and snippets.

@RainerRoss
Created July 19, 2020 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save RainerRoss/ad0fc639cde84d7a8c24b6e1d0b59b28 to your computer and use it in GitHub Desktop.
Save RainerRoss/ad0fc639cde84d7a8c24b6e1d0b59b28 to your computer and use it in GitHub Desktop.
Code for the Array based on pointers in RPG AS400 powered by Sam John
ctl-opt dftactgrp(*no) main(main);
//------------------------------------------------------------------//
// Code for the Array based on pointers in RPG AS400 from Sam John //
// https://www.myeasyclasses.com/2020/07/ //
// code-for-array-based-on-pointers-in-rpg.html //
//------------------------------------------------------------------//
dcl-proc main;
dcl-s ArrayData char(10) dim(10) based(ptr1);
dcl-s ptr1 pointer;
dcl-s Arraysize packed(6);
dcl-s ArrayIndex packed(9);
ArraySize = %Size(ArrayData);
ptr1 = %alloc(ArraySize);
ArrayIndex = 1;
Dow ArrayIndex <= %Elem(ArrayData);
ArrayData(ArrayIndex) = 'A' + %Trim(%Char(ArrayIndex));
Dsply ArrayData(ArrayIndex);
ArrayIndex = ArrayIndex + 1;
Enddo;
end-proc;
//------------------------------------------------------------------//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment