[OpenR8 solution] ForLoop (for loop)
  1. Chapter1: ForLoop Introduction

 

ForLoop refers to the for loop in Loop. If there is some basicity for the program, it should be familiar to the loop. Simply for the meaning of the loop is the meaning of "From what started to what, every time I do something", as shown in Fig. 1.

 

ForLoop will teach you how to use loops for series, multiplication, and advanced use.

 

※ For the introduction of the for loop function, please see Chapter 6.

 

Fig. 1. For loop.png

Fig. 1. For loop.

 

 

  1. Chapter2: ForLoop folder introduction

 

ForLoop is in the solution folder of OpenR8, as shown in Fig. 2, with three flow files and an images folder, as shown in Fig. 3.

 

  1. images folder: forloop_3.flow the folder that will be used by forloop_3.flow.
  2. forloop.flow, forloop_2.flow, forloop_3.flow: for the loop example solution.

 

Fig. 2. ForLoop location.png

Fig. 2. ForLoop location.

 

Fig. 3. ForLoop folder.png

Fig. 3. ForLoop folder.

 

 

  1. Chapter3: Loop — List the series

 

Please click “R8_Python3.6_CPU.bat or R8_Python3.6_GPU.bat” => “File” => “Open” => “Enter the solution folder under OpenR8” => “Select ForLoop folder” => “Load forloop.flow”, as shown in Fig. 4, Fig. 5.

 

Fig. 4. Select forloop.flow.png

Fig. 4. Select forloop.flow.

 

Fig. 5. Load forloop.flow.png

Fig. 5. Load forloop.flow.

 

Press the Run.

 

Fig. 6. Execute solution.png

Fig. 6. Execute solution.

 

※For the introduction of the for loop function, please see Chapter 6.

 

 

  1. Chapter4: Loop — Multiplication application solution

 

Please click “R8_Python3.6_CPU.bat or R8_Python3.6_GPU.bat” => “File” => “Open” => “Enter the solution folder under OpenR8” => “Select ForLoop folder” => “Load forloop_2.flow”,as shown in Fig. 7, Fig. 8.

 

Fig. 7. Select forloop_2.flow.png

Fig. 7. Select forloop_2.flow.

 

Fig. 8. Load forloop_2.flow.png

Fig. 8. Load forloop_2.flow.

 

Press the Run.

 

Fig. 9. Execute solution.png

Fig. 9. Execute solution.

 

Fig. 10. forloop_2.flow result description.png

Fig. 10. forloop_2.flow result description.

 

※ See Chapter 6 for an introduction to the for loop function.

 

 

  1. Chapter5: Loop — Read file solution

 

Please click “R8_Python3.6_CPU.bat or R8_Python3.6_GPU.bat” => “File” => “Open” => “Enter the solution folder under OpenR8” => “Select ForLoop folder” =>“Load forloop_3.flow”,as shown in Fig. 11, Fig. 12.

 

Fig. 11. Select forloop_3.flow.png

Fig. 11. Select forloop_3.flow.

 

Fig. 12. Load forloop_3.flow.png

Fig. 12. Load forloop_3.flow.

 

Press Run to read the jpg image in the images folder.

 

Fig. 13. Run the solution.png

Fig. 13. Run the solution.

 

Fig. 14. forloop_3.flow result description.png

Fig. 14. forloop_3.flow result description.

 

 

  1. Chapter6: For loop usage instructions

 

Fig. 15. for loop function.png

Fig. 15. for loop function.

 

Fig. 16. For the loop field corresponding to the program position.png

Fig. 16. For the loop field corresponding to the program position.

 

 As shown in Fig. 15, for the loop function, there are four variable fields, which are counter (object), from, to, step. If there is a program concept, the "from, to, step" field corresponds. The program code is shown in Fig. 16.

 

※ For the end of the for loop function, be sure to add [For_End].

 

 

  1. Chapter7: forloop.flow flow introduction

 

The function of this process is to print values starting from 5 and adding 2 to 15 each time.

 

Fig. 17. forloop.flow.png

Fig. 17. forloop.flow.

 

  1. For:

Set the starting value, the ending value, and the value added each time.

counter: create an object.

from: Start with 5.

to: Until 15.

step: Add 2 each time.

  1. For_GetCounter:

Get the value in the current for loop.

Example:

Start with 5, add 2 to 15 each time:

 

Fig. 18. Obtaining the For Loop Counting Schematic.png

Fig. 18. Obtaining the For Loop Counting Schematic.

 

  1. Println:

What is the value of the print that appears in the loop.

  1. For_End:

The things that are repeated in the loop stop here.

 

Fig. 19. forloop.flow running result.jpg

Fig. 19. forloop.flow running result

 

 

  1. Chapter8: forloop_2.flow flow introduction

 

The function of this process is to print the values of the two loops multiplied from 1 to 10, as shown in Fig. 20.

 

Fig. 20. forloop_2.flow result.png

Fig. 20. forloop_2.flow result.

 

Fig. 21. forloop_2.flow.png

Fig. 21. forloop_2.flow.

 

special function:

In the sixth [Int_compare] to the ninth [If_end] in the process, its intention is to align.

 

Without these four functions (Int_compare, if, print, If_end), the print result will not be as neat as Fig. 22, so when the values of the two loops are multiplied ( i * j ), if its value has only a single digit (less than 10), add "_" in front to align it, as shown in Fig. 20.

 

Fig. 22. No alignment.jpg

Fig. 22. No alignment.

 

※If you change the value of Sting (10th function [Print]) from "_" to "" (space), it looks very neat!

 

Fig. 23. .jpg

Fig. 23. Effect of replacing Sting's bottom line with a space.

 

 

  1. Chapter9: forloop_3.flow flow introduction

 

The function of this solution is to read the number of files in the folder and display the file images one by one, as shown in Fig. 24.

 

Fig. 24. .png

Fig. 24. forloop_3.flow result.

 

Fig. 25. .png

Fig. 25. forloop_3.flow.

 

The role of the Int_Add function in forloop_3.flow is explained: Int_Add:

 

Because the number of files output by [File_ReadFilesFromFolder] is different from the file number read in [File_ReadTargetPathFromFiles], for example: If the number of files output is 5, then the first of the 5 files The serial number of the file is 0, the serial number of the second file is 1..., the serial number of the fifth file is 4, and the serial number of the last file is different from the total number of 5, so the number of files to be output is reduced by 1.

Tag:

Recommended Article

1.
OpenR8 - AI Software for Everyone (Download)