IBMi (AS400) fans only - Discover the power of the %SPLIT BIF in RPG
In RPG, we often need to manage strings, split them into substrings, and manipulate them efficiently. The %SPLIT BIF is a powerful and useful tool to handle this task. But what exactly is %SPLIT? 🤔 %SPLIT divides a string into multiple parts using a specified delimiter. It can return an array of values based on the delimiter you choose, making it easier to handle complex data or composite strings. Here’s a practical code example to understand it better: **FREE Dcl-s stringa Varchar(100) Inz('apple,banana,orange'); Dcl-s array Varchar(20) Dim(10); Dcl-s delimiter Varchar(1) Inz(','); Dcl-s i Int(10); // Index for the loop // ***************************************************** // PGM start // ***************************************************** array = %Split(stringa : delimiter); *inlr = *on; For i = 1 to %Elem(array); Dsply array(i); EndFor; In this example, the string 'apple,bana