MyChat Scripts: mDBStorageGetData, get the string by the specified key from the built-in database
Get the string by the specified key from the built-in database.
Syntax
function mDBStorageGetData(sKey: string): string;
Parameters and return values
Parameter |
Type |
Value |
sKey |
string |
text key for search. The letter case matters; no limitations for naming. |
Function result
Text string with the key. If there is not data with specified key or the key does not exist the function returns an empty string.
Example
const
TOTAL = 12;
var
i: integer;
sKey, sData: string;
dt: double;
begin
mLogScript('Start saving month names to database...', '');
for i := 1 to TOTAL do begin
dt := EncodeDate(2018, i, 1);
sData := FormatDateTime('mmmm', dt); // name of month
mDBStorageSetData('month_name_' + IntToStr(i), sData);
end;
mLogScript('Ready. Start reading:', '');
for i := 1 to TOTAL do begin
sKey := 'month_name_' + IntToStr(i);
mLogScript('Key: ' + sKey + ', value: "' + mDBStorageGetData(sKey) + '"', '');
end;
end.
Script work result
[19:36:15] (Log "DBStorage"): Start saving month names to database...
[19:36:15] (Log "DBStorage"): Ready. Start reading:
[19:36:15] (Log "DBStorage"): Key: month_name_1, value: "January"
[19:36:15] (Log "DBStorage"): Key: month_name_2, value: "February"
[19:36:15] (Log "DBStorage"): Key: month_name_3, value: "March"
[19:36:15] (Log "DBStorage"): Key: month_name_4, value: "April"
[19:36:15] (Log "DBStorage"): Key: month_name_5, value: "May"
[19:36:15] (Log "DBStorage"): Key: month_name_6, value: "June"
[19:36:15] (Log "DBStorage"): Key: month_name_7, value: "July"
[19:36:15] (Log "DBStorage"): Key: month_name_8, value: "August"
[19:36:15] (Log "DBStorage"): Key: month_name_9, value: "September"
[19:36:15] (Log "DBStorage"): Key: month_name_10, value: "October"
[19:36:15] (Log "DBStorage"): Key: month_name_11, value: "November"
[19:36:15] (Log "DBStorage"): Key: month_name_12, value: "December"
[19:36:15] (Run "DBStorage"): Script operation time: 199 ms
[19:36:15] (Run "DBStorage"): Script done successfully.