Problem in working with return in the loop! - Forum

Forum Navigation
You need to log in to create posts and topics.

Problem in working with return in the loop!

Hello and good time to all my dear friends
I have called the information of a table! And I want to call the data one by one in a subroutine using the loop command and for example check the information from another table with the IP of each data in another subroutine so that I can save it in the first subroutine! The problem is that I can't get information from the second subroutine with the return command! Is there a special rule and law?

@javadrajabihakami sorry, I can't understand you.
Please share a basic sample app showing the problem.
Thank you!

javadrajabihakami has reacted to this post.
javadrajabihakami

For example :

I call the data of a table!

Then I will call the rows of the table one by one with the loop command!

Loop   …………………………………………….

For example: ID - name - national code

And then with the following command that calls the data with the national code of each person, we call the information!

neoPhpExecSql "dbName" "dbQuery" ""params" callBackFn

endloop  ................................. ...................................

Now my problem is that I have a command in the subroutine ((callBackFn)) to update the details of the person in question, which are called in sequence with the loop command!

Update happens only for the last record.

@javadrajabihakami you shouldn't use neoPhpExecSql command inside a loop.
A loop is executed as fast as possible so you can have dozens or hundreds of calls to the server in a fraction of a second (so fast that only the last one will be sent really).
You should call neoPhpExecSql just once and then wait for callBackFn to be executed. Then, and only then, you can execute neoPhpExecSql again.
So, use a variable to store the current index, and start with the first one.
Then use callBackFn to increase the value one by one and call neoPhpExecSql again from callBackFn using itself as a callback function (recursive).
By sure to detect the last index to not call neoPhpExecSql outside the array boundaries!

javadrajabihakami has reacted to this post.
javadrajabihakami