99_Utils.pm: return undef,undef, if key was not found (Forum #30528)
git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@7364 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -16,7 +16,7 @@ sub
|
|||||||
getUniqueId()
|
getUniqueId()
|
||||||
{
|
{
|
||||||
my ($err, $uniqueID) = getKeyValue("uniqueID");
|
my ($err, $uniqueID) = getKeyValue("uniqueID");
|
||||||
return $uniqueID if(!$err);
|
return $uniqueID if(defined($uniqueID));
|
||||||
srand(time);
|
srand(time);
|
||||||
$uniqueID = join "",map { unpack "H*", chr(rand(256)) } 1..16;
|
$uniqueID = join "",map { unpack "H*", chr(rand(256)) } 1..16;
|
||||||
setKeyValue("uniqueID", $uniqueID);
|
setKeyValue("uniqueID", $uniqueID);
|
||||||
@@ -33,7 +33,7 @@ getKeyValue($)
|
|||||||
for my $l (@l) {
|
for my $l (@l) {
|
||||||
return (undef, $1) if($l =~ m/^$key:(.*)/);
|
return (undef, $1) if($l =~ m/^$key:(.*)/);
|
||||||
}
|
}
|
||||||
return ("Key not found", undef);
|
return (undef, undef);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
@@ -404,7 +404,8 @@ myUtils_Initialize($$)
|
|||||||
|
|
||||||
<li><b>getKeyValue(keyName)</b><br>
|
<li><b>getKeyValue(keyName)</b><br>
|
||||||
return ($error, $value), stored previously by setKeyValue.
|
return ($error, $value), stored previously by setKeyValue.
|
||||||
$error is undef if there was no error, otherwise $value is undef.
|
$error is set if there was an error. Both are undef, if there is no
|
||||||
|
value yet for this key.
|
||||||
</li></br>
|
</li></br>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
Reference in New Issue
Block a user