I have a simple function to compare two string:
function stringCmp(string a, string b) public returns (bool){
bytes memory aa=bytes(a);
bytes memory bb=bytes(b);
if(aa.length!=bb.length)
return false;
for(uint i=0; i< aa.length; i++)
if(aa[i]!=bb[i])
return false;
return true;
}
This function properly work in truffle console if used as follow:
t=contract_name.at("address_of_c");
t.stringCmp.call("string1","string1") --> true
t.stringCmp.call("string1","string2") --> false
Supposing we have declared in the contract:
string public p="ciao";
string public q="ciao";
string public r="hello";
Which is the properly way to pass those string to the call? I tried :
t=contract_name.at("address_of_c");
t.stringCmp.call(t.p(),t.q()) --> true (and it seems ok but..)
t.stringCmp.call(t.p(),t.r()) --> true (So what..???)
t.stringCmp.call(t.p,t.r) --> true (???)
t.stringCmp.call(t.p.call(),t.q.call()) --> Invalid number of arguments to Solidity function
Moreover what is exactly going on? Any Workaround?