Call to undefined function sc_include() in onScriptInit

Hi,

This doesn’t make sense to me, is anyone else experiencing this? I have the following simple set of code (a php library with autoloader and a simple function in the other),

sc_include_library("sys", "phpXXXkLib", "XXX/Autoloader/Autoloader.php", true, true);
sc_include(security_helper.php, sys);

When I run this I get “Call to undefined function sc_include()”. If I add the macros in reverse my libraries work perfectly (and no errors).

sc_include(security_helper.php, sys);
sc_include_library("sys", "phpXXXkLib", "XXX/Autoloader/Autoloader.php", true, true);

Is there a macro order dependency in scriptcase - sc_include before sc_include_library? Although it’s still bizarre to me that the it doesn’t recognize sc_include even if order is a dependency.

I even tested this out on the simplest of dummy data and I get the same error.

sc_include_library("sys", "delete_me", "echo.php", true, true);
sc_include(int_delete_me.php, sys);

The echo.php file contains just

<?php
echo 'hello';
?>

and the int_delete_me.php file contains

<?php
function hello(){
  echo 'hello';
}
?>

Arthur

In case anyone is wondering why I didn’t just include the internal library using the “checkbox” method, it’s because my internal library has code outside of the function which means you must use sc_include.

This might seem not exactly related. But the issue is the same.
I created a set of internal libraries which I want to include across multiple applications within the same project. The libraries are as follows
sc_include(“data_validations.php”, “prj”);
sc_include(“email_service.php”, “prj”); // Email sending service using the PHPMailer V7 created as external library

If the email service is above the data validations I get an error while generating the form application as follows
Undefined variable $nm_php_seg_func | Script: /Applications/Scriptcase/v9-php81/wwwroot/scriptcase/devel/class/generator/nmDados.class.php linha: 7706

Strange thing : This does not happen with blank application. I tried with multiple form applications to with same type of error
Thanks to this post, I changed the ORDER as above with data validations before email service and the generation is working fine.

ATTN TO SCRIPTCASE TECHNICAL TEAM: I am willing to share the libraries, the forms if they want to check this further

Hi,
Why do you use sc_include instead of including the internal libraries from Programming / Internal libraries, only checking those necessary for the application?

I don’t know, perhaps the behavior is different due to how SC generates the code.

You are right. Even that works.
But It is easy for me to copy paste into all applications. I am developing a huge application and I want to centralize the data_validations. i am using a table called validation_rules which will contain all the rules for vaidation. And in every form onValidate event I will call this data_validations
I am using postgres.
The unique ID is a UUID generated by postgres. This is shown a text in scriptcase . Sometimes this UUID can be null.
I have a set of adit fields like created by , created at, last modifed by , last modified at , is_deleted (bool) , deleted by, deleted at (the delete is for soft delete)
It is easier for me to copy a set of code in all forms onValidate event and then modify some parts.
I am a bit lazy. I use python to populate the Application Language values in Scriptcase.
I use AI to get me the field names from sql queries to csv format and send that to python which will then set the values in Application Lanuage. Lazy to the bone :smiley:

As such, The centralised validation helps me. And you are right that I can use Appication / Library and I will try that and let you know.
But the sc_include should not have this quirk of including in an order.