STOP code and CHECK values

This may be a very stupid question, but…

how can i stop the code at a point and check some values?

Can you elaborate with an example of exactly what you’re trying to accomplish ?

Before SC i used to program in Access. Then i had the possibility to STOP the code and check some values/string. A way to check where the error could be when rolling the code. I do make some errors :slight_smile:

ACCESS placed a kind of bookmark and stopped, or I could place the word STOP into the code, stopping the code when arriving a that point. Allowing me to check some values/strings,…

Is this possible?

The reason why is that following code is NOT working. I have this on a AJAC_onclick. Code changes the value of a tinyINT field from 1 to 0 and from 0 to 1. When value is 1 the code works perfect, but the second part is not working. I don’t know why!!!

sc_select(rs, "SELECT Galop FROM tblafwezigheden WHERE Id = “.{id}.” ");
if(rs[0] == 0)
{
sc_exec_sql("UPDATE tblafwezigheden SET Galop = 1 WHERE Id = “.{id}.” ");
}
elseif(rs[0] == 1)
{
sc_exec_sql("UPDATE tblafwezigheden SET Galop = 2 WHERE Id = “.{id}.” ");
}
sc_ajax_refresh();

In msaccess, this is debugging. There is no breakpoint in scriptcase web based ide. But there is a debug option under application settings. Turn it on, it will show you the sql queries being executed, but not the value of variables.

On your code, if you want to check particular variables, put multiple sc_error_message with your variable and scriptcase will show you their all their values at the point.

Yhx, ill try this :slight_smile:

sc_error_message is not working on a GRID

I think you need to rewrite your code like this:

sc_lookup(RS, "SELECT Galop FROM tblafwezigheden WHERE Id = “.{id}.” ");
if ({RS[0][0]} == 0)
{
sc_exec_sql("UPDATE tblafwezigheden SET Galop = 1 WHERE Id = “.{id}.” ");
} else
{
sc_exec_sql("UPDATE tblafwezigheden SET Galop = 2 WHERE Id = “.{id}.” ");
}

This would work only if id is a primary key and you are retrieving only 1 row

On gird, I use sc_alert instead.

On the macro documentation, it says onapplicationinit and scriptinit, well in fact it works more than just that, even onRecord it works.

your code did not work, don’t ask me why because I don’t know.

Following code did work:
sc_select(rs, "SELECT Raster FROM tblafwezigheden WHERE Id = “.{id}.” ");

if($rs->fields[0] == 1)
{
sc_exec_sql("UPDATE tblafwezigheden SET Raster = 0 WHERE Id = “.{id}.” ");
}
elseif($rs->fields[0] == 0)
{
sc_exec_sql("UPDATE tblafwezigheden SET Raster = 1 WHERE Id = “.{id}.” ");
}

sc_ajax_refresh();

if id is number: sc_select(rs, “SELECT Raster FROM tblafwezigheden WHERE Id = “.{id});
if is string: sc_select(rs, “SELECT Raster FROM tblafwezigheden WHERE Id = '”.{id}.”’”);

The error came from

if(rs[0] == 0)

i replace it with

if($rs->fields[0] == 1)

Last code is working

rs[0] will not work.

it should be

{RS[0][0]} == 0