K
K
Kirill Zhilyaev2016-10-29 21:28:03
In contact with
Kirill Zhilyaev, 2016-10-29 21:28:03

How to download messages from the end?

I sit for the 3rd hour and think: how to download messages from the end.
Here wrote execut'ku

var count = API.messages.get ({"count" : 0 , "out" : parseInt (Args.out)}).count;
var offset = count - parseInt (Args.ofset) - parseInt (Args.count);
var counts;
if (offset<0) {
    counts = offset * -1;
    offset = 0;
} else {
    counts = parseInt (Args.count);
}


//return [counts,count, parseInt (Args.ofset)];
if (counts>count- parseInt (Args.ofset))
    counts = count-parseInt (Args.ofset);

return [counts , offset ,  API.messages.get ({"count" : counts , "out" : parseInt (Args.out) , "offset" : offset})];
//return API.messages.get ({"count" : counts , "out" : parseInt (Args.out) , "offset" : offset});

But something always goes wrong. If there are few messages and count is large, then the procedure returns incorrect data. Or how to download messages, but so as not to run into repetitions (for example, when adding a new message while loading)?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question