Blog Archive

RPGLE for loop example - AS400 (iSeries)

Instead of a dowhile or a dountil you can now use a for loop just any other language in RPGLE.
The syntax of the FOR operation is as follows:
      FOR         index-name { = starting-value }
                  { BY increment-value }
                  { TO | DOWNTO limit-value }
         { loop body }
      ENDFOR | END

The starting-value, increment-value, and limit-value can be numeric values or expressions with zero decimal positions. The increment value, if specified, cannot be zero. The BY and TO (or DOWNTO) clauses can be specified in either order. Both "BY 2 TO 99" and "TO 99 BY 2" are allowed.

Example 1:
for i=1 by 1 to 100;
     //do something
endfor;

Example 2:
Extract all blank-delimited words from a sentence.
    WordCnt = 0;
    for i = 1 by WordIncr to %len (Sentence);
       // Is there a blank?
       if %subst(Sentence: i: 1) = ' ';
          WordIncr = 1;
          iter;
       endif;
        // We've found a word - determine its length
       for j = i+1 to %len(Sentence);
          if %subst (Sentence: j: 1) = ' ';
             leave;
          endif;
       endfor;
        // Store the word
       WordIncr = j - i;
       WordCnt = WordCnt + 1;
       Word (WordCnt) = %subst (Sentence: i: WordIncr);
    endfor;

Source: IBM Information Center

13 comments :

  1. Wonderful blog! This is very informative site. I am totally pleased by your excellent work. Many thanks for sharing.
    agario skins | mahjong connect | minecraft games |pac man | geometry dash lite | sniper games |halloween | game

    ReplyDelete
  2. Thank you for your post, I look for such article along time, today i find it finally. this post give me lots of advise it is very useful for me
    Signature:
    i like play games happy wheels online and play happy wheels 2 games and friv , girlsgogames , games2girls

    ReplyDelete
  3. We thank you for sharing. If you feel tired because the work is too stressful or pressure from our study let's try this fascinating game offline. Thank you!
    return man 3
    Juegos de Matar Zombies
    return man 3
    return man 2
    return man
    return man 3 unblocked
    return man 3 hacked
    return man 3 zombies
    return man 3 the season
    return man 5
    return man 6

    ReplyDelete
  4. Thank you for sharing, I really enjoyed this. You can also participate in free games with our wonderful smell from it. Thank you !

    Juegos de Matar Zombies
    earn to die
    earn to die 2
    earn to die 3
    earn to die 4
    earn to die 2012
    earn to die 1
    earn to die part 2
    earn to die 6

    ReplyDelete
  5. Thanks for sharing the information. It is very useful for my future. keep sharing
    Geometry Dash 2.0 |Dr Driving | Trollface Quest 2 | Square Quick

    ReplyDelete
  6. This time I feel stressed, I go online to find the article to read. I happened to read your article, it's nice and emotional. I love it. descargar facebook , descargar facebook , baixar whatsapp , descargar whatsapp , baixar whatsapp plus , baixar mobogenie gratis , mobogenie

    ReplyDelete
  7. Great. This article is excellent. I have read many articles with this topic, but I have not liked. I think I have the same opinion with you. baixar facebook , baixar facebook , descargar facebook , descargar whatsapp gratis , descargar mobogenie gratis , baixar mobogenie gratis , messenger whatsapp

    ReplyDelete
  8. Thanks for your sharing. We feel very happy about that. You should also try my best to play our FREE today to get the sense of fun that brings. Thank you!
    return man 3
    return man 2
    return man

    ReplyDelete
  9. I wanted to thank you for this excellent read!! I definitely loved every little bit of it.Cheers for the info!!!! & This is the perfect blog for anyone who wants to know about this topic. I like play games Piano Tiles 2 game online, Score Hero game, Dream League Soccer, b612 and descargar b612 gratis. How about you?

    ReplyDelete
  10. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.
    Signature:
    messenger indir | messenger indir | messenger | messenger download | messenger indir | messenger indir | download messenger | messenger indir

    ReplyDelete
  11. Thanks for sharing. I hope it will be helpful for too many people that are searching for this topic.
    Red Ball is a online, platform games series, posted by King. It involves a red ball 4 stuck in a world of various levels, and hola launcher is a freemium web and mobile application which claims to provide a faster, private and more secure Internet. Whether you are looking to improve your culinary skills or you simply love whipping up tasty treats, this simulation game named cooking fever will surely leave your mouth watering. Sun, sand, surf, and all the fish you can eat! Sail away to paradise bay, where you'll help Keani and friends restore the island to its former glory. The and, agario is a fun addicting MMO game in which you have to eat or be eaten while you strive to dominate the World of colorful cells. Good happy !

    ReplyDelete
  12. Thanks for sharing this valuable information to our vision.
    Signature:
    Download retrica online includes more than eighty different filters with many different styles and include retrica indir , and zombie tsunami is the ideal game for anyone who loves the running game genre

    ReplyDelete