MyChat Scripts Engine: mIncUIN, find the next UIN after the specified one
Get the next unique number (UIN) of a registered user on the server.
Users UINs are unique and never repeated. UIN=0 is for built-in bot Elisa, UIN=1 is an Administrator for managing the server. All other users can be created and deleted, but free UINs can't be used to save databases.
To select existing user UINs, avoiding gaps, it is better using functions mlncUIN and mDecUIN.
Syntax
function mIncUIN(iUIN: integer): integer;
Parameters and return values
Parameter |
Type |
Value |
iUIN |
integer |
unique user identifier from which you need to get the next ID. |
Function result
>0 |
next UIN; |
-1 |
first UIN does not exist on the server; |
-2 |
no UINs left. |
Example
Sorting out all registered users UINs starting from the first one and counting numbers of paired UINs of registered users.
const
START_UIN = 1;
var
iCount, iUIN: integer;
begin
iCount := 0;
iUIN := START_UIN;
repeat
iUIN := mIncUIN(iUIN);
if iUIN mod 2 = 0 then inc(iCount);
until iUIN < 0;
mLogScript('Paired UINs count: ' + IntToStr(iCount), '');
end.
Script work result
[19:52:58] (Log "mIncUIN"): Paired UINs count: 4004
[19:52:58] (Run "mIncUIN"): Script operation time: 52 ms
[19:52:58] (Run "mIncUIN"): Script done successfully.