Conditional Statements. Switch
Using Switch block for handling decisions
Now we know the file extension, but how to check if it suits us? We have already checked for quantity, but here we need another solution because there may be several options.
For this, it would be reasonable to use the Switch block. Its usage is similar to If-Else, but more complex and not limited to True and False as options.
The first step in using it is setting the Value input parameter. This is necessary in order to determine what options can be in general (strings, numbers, selection from the Enum list, or something else). In our case, we use the String element as the Value, which was obtained as a result of the work of the Array Element block.
The next step is to add possible options. Let's write "xlsx" for the Excel file and various options for image file extensions (jpg, jpeg, png, and others). In addition, there is always the Default option, meaning none of the presented options fit. In our case, it is on Default that you can assign a call to a message (Notification) that the selected files do not meet the requirements.
If everything went according to plan and the file is really of the desired format, then it remains only to check the second file according to the same scheme, with the difference that the number of available options is reduced. If the first file is xlsx, then the second one needs to be checked only for compliance with the image format. Or vice versa, if the first file is an image, then the second must be xlsx.
Note that different variants of the Switch block can lead to the same path. In our case, it doesn't matter what kind of extension the image file had, and the further route will not depend on this. The main thing is that it really was one of the options for images.
At this stage of training, such a scheme is quite workable, but in further modules of the course, we will figure out how to make it more elegant. Use loops and variables, create your own business processes for repeating fragments and use them as a separate block.