How to compare unordered property list value?

Hello Team,
I have the below code for entering the task name and random valueclick
put ““TaskName_0” as task_name
put 1 as number into global version_number
typetext task_name
typetext tab
put random(1,20) into downarrow_press
typetext downArrow repeated downarrow_press times
wait 2
typetext returnkey
wait 2
typetext tab
put task_name into global task_info.task_name
put global version_number into global task_info.version
log global task_info
repeat 12 times
put format(”%.2f",random(0,20000)/1000) into task_value
replace “.” with “,” in task_value
typetext task_value
typetext tab
put “Demand”&repeatindex() into demand_value
put task_value into global task_info.(demand_value)
end repeat
insert global task_info into global task_details
log “Current version Entered Value:”&&global task_detailss.

The o/p of the first iteration:
[{Demand1:“3,72”, Demand10:“2,38”, Demand11:“1,26”, Demand12:“5,53”, Demand2:“3,43”, Demand3:“5,43”, Demand4:“17,80”, Demand5:“9,38”, Demand6:“16,00”, Demand7:“14,08”, Demand8:“8,43”, Demand9:“8,07”, task_name:“TaskName_0”, version:1}]

While query the DB:

[{Demand01:“3.72”, Demand02:“3.43”, Demand03:“5.43”, Demand04:“17.80”, Demand05:“9.38”, Demand06:“16.00”, Demand07:“14.08”, Demand08:“8.43”, Demand09:“8.07”, Demand10:“2.38”, Demand11:“1.26”, Demand12:“5.53”, TaskName:“TaskName_0”, version:“1”}]

How to ensure these Two property list are same?

The next iteartion

The acumualted entered value is as below

[{Demand1:“3,72”, Demand10:“2,38”, Demand11:“1,26”, Demand12:“5,53”, Demand2:“3,43”, Demand3:“5,43”, Demand4:“17,80”, Demand5:“9,38”, Demand6:“16,00”, Demand7:“14,08”, Demand8:“8,43”, Demand9:“8,07”, task_name:“TaskName_0”, version:1},{Demand1:“18,54”, Demand10:“5,84”, Demand11:“10,52”, Demand12:“0,63”, Demand2:“0,29”, Demand3:“13,55”, Demand4:“16,67”, Demand5:“4,25”, Demand6:“14,43”, Demand7:“1,48”, Demand8:“13,28”, Demand9:“0,80”, task_name:“taskname_1”, version:2}]

How to update the version number in the accumulated result of intial version data so that I can compare my current version DB data?

[{Demand01:“3.72”, Demand02:“3.43”, Demand03:“5.43”, Demand04:“17.80”, Demand05:“9.38”, Demand06:“16.00”, Demand07:“14.08”, Demand08:“8.43”, Demand09:“8.07”, Demand10:“2.38”, Demand11:“1.26”, Demand12:“5.53”, TaskName:“TaskName_0”, version:“2”},{Demand01:“18.54”, Demand02:“.29”, Demand03:“13.55”, Demand04:“16.67”, Demand05:“4.25”, Demand06:“14.43”, Demand07:“1.48”, Demand08:“13.28”, Demand09:“.80”, Demand10:“5.84”, Demand11:“10.52”, Demand12:“.63”, TaskName:“taskname_1”, version:“2”}]

Regards
D.Thangaraj

Probably the simplest approach will be to generate the keys and values in the same format that they are in when coming from the database.

Add this line sometime before the repeat loop:
set the numberFormat to "00"

That will make put “Demand”&repeatindex() into demand_value generate keys like Demand03 instead of Demand3.

Then delete this line - replace “.” with “,” in task_value - so the values will match the ones in the database and I think the comparison will work correctly.

To compare unordered property list values, you can follow these steps:

Convert the property lists to arrays: Convert both property lists into arrays so that their elements can be easily compared.

Sort the arrays: Sort both arrays in ascending or descending order depending on the nature of the values they contain. This step ensures that the elements in both arrays are in the same order and can be compared effectively.

Compare the arrays: Compare the sorted arrays using a built-in function or a custom comparison algorithm. If the arrays have the same elements in the same order, they are considered equal. Otherwise, they are considered unequal. For more details visit here

1 Like