How to compare the genrated texbox entered value and db query value?

Hello All,

I have dynamiclaly genearted 12 values as below usingthe code:

set global task_value to ""
repeat 12 times
	put format("%.2f",random(0,20000)/1000) into genrated_task_value
	replace "." with "," in genrated_task_value
	insert genrated_task_value into global task_value 
end repeat
log "Genrated_task_value:"&&global task_value 

Values:
[“16,82”,“19,58”,“3,41”,“0,32”,“15,17”,“15,70”,“2,31”,“17,34”,“10,26”,“0,01”,“7,36”,“19,30”]
Now entered this value into repestive text boxes & stored in the DB.

After BD query the ouptut as below:
[{demand01:“16.82”, demand02:“19.58”, demand03:“3.41”, demand04:“.32”, demand05:“15.17”, demand06:“15.70”, demand07:“2.31”, demand08:“17.34”, demand09:“10.26”, demand10:“.01”, demand11:“7.36”, demand12:“19.30”, TaskName:“EAA_task_name_1”}]

Now have I comapred both values as below. Eventhough both output looks same. but It’s fail.

	put ["16,82","19,58","3,41","0,32","15,17","15,70","2,31","17,34","10,26","0,01","7,36","19,30"] into genrated_value
put [{demand01:"16.82", demand02:"19.58", demand03:"3.41", demand04:".32", demand05:"15.17", demand06:"15.70", demand07:"2.31", demand08:"17.34", demand09:"10.26", demand10:".01", demand11:"7.36", demand12:"19.30", TaskName:"EAA_task_name_1"}] into db_task_value
repeat with each item of db_task_value
	put the values of it into raw_task_value
end repeat
log "Raw_task_value:"&raw_task_value
replace "." with "," in raw_task_value
log "Raw_task_value with comma:"&raw_task_value
log "Genrated value:"&genrated_value
if genrated_value begins with raw_task_value
	log "matched"
else
	log "not matched"
end if

O/p:
Raw_task_value:[“16.82”,“19.58”,“3.41”,“.32”,“15.17”,“15.70”,“2.31”,“17.34”,“10.26”,“.01”,“7.36”,“19.30”,“EAA_task_name_1”]
2/22/23, 8:03:49 AM Log Raw_task_value with comma:[“16,82”,“19,58”,“3,41”,“,32”,“15,17”,“15,70”,“2,31”,“17,34”,“10,26”,“,01”,“7,36”,“19,30”,“EAA_task_name_1”]
2/22/23, 8:03:49 AM Log Genrated value:[“16,82”,“19,58”,“3,41”,“0,32”,“15,17”,“15,70”,“2,31”,“17,34”,“10,26”,“0,01”,“7,36”,“19,30”]
2/22/23, 8:03:49 AM Log not matched
Could you pls help, How to compare the entered value with DB value?

Hi @Thanagaraj,
The issue is that values in each item are being treated as text and not as numeric values. This means that they will need to match character for character. Your generated_value list includes leading zeros of “0,32” etc., so they don’t match. Also there may be some confusion about the difference in SenseTalk between a list (multiple items) and a property list (single item). I have verified that the code below works as expected.

put ["16,82","19,58","3,41","0,32","15,17","15,70","2,31","17,34","10,26","0,01","7,36","19,30"] into genrated_value
put {demand01:"16.82", demand02:"19.58", demand03:"3.41", demand04:".32", demand05:"15.17", demand06:"15.70", demand07:"2.31", demand08:"17.34", demand09:"10.26", demand10:".01", demand11:"7.36", demand12:"19.30", TaskName:"EAA_task_name_1"} into db_task_value -- remove square brackets

//Converts db_task_value from a single item property list into a multiple item standard list
Put the values of db_task_value into raw_task_value -- db_task_value is a single item property list so repeat is not necessary

log "Raw_task_value:"&raw_task_value
repeat with each item CurrentItem of raw_task_value by reference -- by reference is required to change the values in raw_task_value
	If CurrentItem begins with period then set CurrentItem to "0" & CurrentItem -- appends a zero to each item that does not have a leading zero
	replace "." with "," in CurrentItem
end repeat

log "Raw_task_value with comma:"&raw_task_value
log "Genrated value:"&genrated_value
if raw_task_value begins with genrated_value
	log "matched"
else
	log "not matched"
end if

Thanks lot.Now working for me