Solve Equations by Substitution

It can be tedious to solve equations when looking at it from the wrong angle. Although Yarado supports all kinds of Advanced if scenarios there just might be a much easier approach.

Example 1:
Convert month names to numbers as translation between data. The source system is a input form, the end data is an ERP system that requires normal date fomatting

Luckily there are only 12 months in a year so you can get away by build a scenario with 12 IF’s and place it in a SubTask to lesser complexity.

it would probably look like
If %month_name% = January Return 1
If %month_name% = February Return 2
If %month_name% = March Return 3
etc …

A far more easier way would be to use the Find and replace using list. Function

Corresponding list

So with 1 step 12 equations are solved :+1:


Example 2:
image
Some application has 5 status indicators, they can turn to color gray,green,yellow and red.
Business request : Report which status indicator, is in the status Red or Yellow. Color can be obtained with the Yarado function get Pixel Color

Traditional way
To solve the equation the location per status indicator is required. lots of variables e.g.

variable value
%Light1x% 17
%Light1y% 5
%Light2x% 17
%Light2y% 12
%Light3x% 17
%Light3y% 19
%Light4x% 17
%Light4y% 26
%Light5x% 17
%Light5y% 46

Then 5 times get pixelcolor will be called upon
Getpixelcolor(%Light1x%,%Light1y%)
Getpixelcolor(%Light2x%,%Light2y%)
Getpixelcolor(%Light3x%,%Light3y%)
Getpixelcolor(%Light4x%,%Light4y%)
Getpixelcolor(%Light5x%,%Light5y%)

After that the If equations are needed
If Light 1 = Yellow Write Light1 Yellow
If Light 1 = Red Write Light1 Red
If Light 2 = Yellow Write Light1 Yellow
If Light 2 = Red Write Light2 Red
If Light 3 = Yellow Write Light3 Yellow
If Light 3 = Red Write Light3 Red
If Light 4 = Yellow Write Light4 Yellow
If Light 4 = Red Write Light4 Red
If Light 5 = Yellow Write Light5 Yellow
If Light 5 = Red Write Light5 Red

When implementing it like this, every change will be tedious especially adding different statuses will exponentially grow the equations and steps. Moving the equations to Subtasks will lighten this burden slightly.

How will this look

Same scenario only Solve Equations by Substitution notice how much less complex this looks
image

Let us now look at the solve equations by substitution approach.
create a replace list Lightsloc.csv
image

Create variables
Variable %x%
Variable %y%
%lightcount% set it to 0
%colo%

Step 1:
%lightcount% = %lightcount% + 1
%x% = Find and Replace using list lightsloc.csv value “Light”%lightcount%x
%y% = Find and Replace using list lightsloc.csv value “Light”%lightcount%y
%color% GetPixelcolor(x,y)

Step 2
Append Text “Status” Light"%lightcount% has color : %color%
%lightcount%=%lightcount% + 1

Step3
If %lightcount% is not 6 goto step 1

Step4
Remove all lines from textfile that contains gray,green



Example 3:
Replace Diacritic characters for normal characters (é,â,î or ô) to (e,a,i or o) system A supports these type of characters where as system B does not. With the Find and Replace Using List function all these characters can be replaced by the desired character combination. The left Image Represents the configuration of this function, Whereas the right image is the input source for the Find and Replace Using List.

image

2 Likes