1
WS aka Web Scripts (Attended RPA for SAP) / Delete the Specified Integer from an Array.
« on: March 19, 2019, 10:26:23 AM »
Purpose: Delete the Specified Integer from an Array.
Liquid UI Code:
var found;
var position;
var num = [23,65,89,54,74];
var num_tobe_deleted = 54;
var array_length = num.length;
println("The Array Elements = [23,65,89,54,74]");
println("The given number to be deleted is = "+num_tobe_deleted);
for (var m = 0; m < array_length; m++)
{
if (num[m] == num_tobe_deleted)
{
found = 1;
position = m;
break;
}
}
if (found == 1)
{
for (var k = position; k < array_length - 1; k++)
{
num[k] = num[k + 1];
}
println("The resultant Array after deleting the number is = "+num_tobe_deleted);
for (var z = 0; z < array_length - 1;z++)
{
println(num[z]);
}
}
else {
println("This number is not found", num_tobe_deleted);
}
Liquid UI Code:
var found;
var position;
var num = [23,65,89,54,74];
var num_tobe_deleted = 54;
var array_length = num.length;
println("The Array Elements = [23,65,89,54,74]");
println("The given number to be deleted is = "+num_tobe_deleted);
for (var m = 0; m < array_length; m++)
{
if (num[m] == num_tobe_deleted)
{
found = 1;
position = m;
break;
}
}
if (found == 1)
{
for (var k = position; k < array_length - 1; k++)
{
num[k] = num[k + 1];
}
println("The resultant Array after deleting the number is = "+num_tobe_deleted);
for (var z = 0; z < array_length - 1;z++)
{
println(num[z]);
}
}
else {
println("This number is not found", num_tobe_deleted);
}