E
E
eRKa2017-02-25 13:31:10
In contact with
eRKa, 2017-02-25 13:31:10

Code does not compile to execute. How to make a cycle?

According to the documentation, the loop is done like this

var a = 1; var b = 10; while (b != 0) { b = b - 1; a = a+1; }; return a;

For me it looks like this
var posts=API.newsfeed.search({"q":"Test"});
var [email protected]_id;
var i=0;
var gIds=[];
var uIds=[];
while(i<ownerIds.length)
{
  if(ownerIds[i]<0)
  {
    gIds.push(ownerIds[i]);    
  };
  i=i+1;
};
return gIds;

This code returns an error
"error_code":12,"error_msg":"Unable to compile code:  ';' expected

Empirically established that the problem is in the line i=i+1;
If this line is removed and the while is slightly rewritten without comparing with i, then it compiles and returns a normal result.
And I also tried to run the example from the docks. It falls off on the line b = b - 1;
The call code itself in C#, if that matters
using (var client = new HttpClient())
{
    client.DefaultRequestHeaders.Accept.Clear();

    var res = client.GetAsync($"https://api.vk.com/method/execute?code={queryParam}&access_token={token}&v=5.62").Result;
    var answer = res.Content.ReadAsStringAsync().Result;
}

Where is my error? Already spent a lot of time.
PS:
Posted a question. I tried the code on the docks page in vk and it worked. And then it dawned on me that it was the '+'. Get request accepts it as a space. But the problem persisted even after I made Urlencode. On the vk side, he still does not see this plus and goes into an eternal loop.
Help with advice on how to solve this)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
eRKa, 2017-02-25
@kttotto

In general, I made a request via POST and everything is fine. It was not possible to send +/- through GET, even encoding, vk returns an error.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question