global variables and...

I am puzzled by the following.

In the onscriptinit I look if a global variable has a value.

If not then I fill another global variable with the name of the application and do a sc_redir to a filter application.
In this filter application I do a select of a certain field and when I click select, then the global variable gets the value and the application will do a sc_redir to the application which was calling.

The global variable is used in an sql statement and I put it in the header.

Now the odd thing: the header is showing me the correct data. But the sql statement does not. In fact, if you set debug on then the global field is empty (although it is shown correctly in the header). If I do a refresh of the same screen it works well.

** why??? **

what goes wrong?

Albert,

could you post your SQL Statement ?

See attachment

demo.jpg

I think that the header is fresh one time when the form load it.

I don’t understand. The header is shown when the screen builds up. Then the detail part is shown. Where’s the part that the global variable is cleaned? Not in my code. The filter applications sets the filter in a global variable. This variable is shown in the header and is used in the sql. In the header it is shown ok, in the sql it is lost???

Hello,

Have you tried to set the value onApplicationInit() instead of onScriptInit()?

regards,
Bernhard Bernsmann

Yes, but doesn’t onApplicationInit only fires once? What if the global is reset? Besides that, why is the variable correctly shown in the header and not in the form? Point is that an application is called which sets a global var. When I return in my old application the global is shown correctly in the header, but not on the form… ?

Look as the sql, the first is correct, but the latest the global is gone:

(mysql): INSERT INTO sc_log (inserted_date, username, application, creator, ip_user, action, description) VALUES (‘2013-06-30 14:40:57’, ‘aidee:’, ‘ba_grid_medicalintake’, ‘Scriptcase’, ‘192.168.1.37’, ‘access’, ‘’)
(mysql): SELECT naam, geslacht, geboortedatum FROM persoon WHERE dohmpersnr = ‘1’ (mysql): select count(*) from medicalintake where dohmpersnr=’’
(mysql): SELECT dohmpersnr, intakeseq, intakedate, intaketype, intakecomm, actief from medicalintake where dohmpersnr=’’ LIMIT 0,17

My onscriptinit:


if ([glob_dohmpersnr] == '') {
    [glob_returnurl]='ba_grid_medicalintake.php';
    sc_redir('ba_filter.php');
}
[glob_returnurl]='';

$check_sql = "SELECT naam, geslacht, geboortedatum FROM persoon " 
            . "WHERE dohmpersnr = '[glob_dohmpersnr]'";
  
sc_lookup(rs, $check_sql);

if (isset({rs[0][0]}))     // Row found
  {
    [glob_dohmpersdata] = {rs[0][0]} . ' ('.{rs[0][1]}.')  ' . {rs[0][2]};
  }


If I reselect the same function from the menu then the global is set and the correct record shown…

Ok, if i set the global variables and do a sc_redir, I get odd result. But if I pass the global variable myself in the sc_redir as parameters then it does work… Looks like a bug to me.