# Exporting predicates in the code loaded into PEngines via the src\_text parameter?

**URL:** <https://swi-prolog.discourse.group/t/exporting-predicates-in-the-code-loaded-into-pengines-via-the-src-text-parameter/763>\
**Category:** Help!\
**Created:** [June 4, 2019, 2:02am UTC](https://swi-prolog.discourse.group/t/exporting-predicates-in-the-code-loaded-into-pengines-via-the-src-text-parameter/763 "2019-06-04T02:02:11Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![prodog](https://avatars.discourse-cdn.com/v4/letter/p/57b2e6/32.png) [@prodog](https://swi-prolog.discourse.group/u/prodog)\
**Post date:** [June 4, 2019, 1:17pm UTC](https://swi-prolog.discourse.group/t/exporting-predicates-in-the-code-loaded-into-pengines-via-the-src-text-parameter/763/5 "2019-06-04T13:17:50Z")

</div>

But that’s the problem. I _can’t_ call the predicates in the code I load via the `src_text` property via an `ask()` call as I stated in this thread:

> [@Can't call predicate loaded via src\_text parameter during PEngines ask() call?](https://swi-prolog.discourse.group/t/cant-call-predicate-loaded-via-src-text-parameter-during-pengines-ask-call/765):
>
> I’m using: SWI-Prolog version 8.0.2 on Ubuntu Linux 18.04. I have now converted my code from being mostly residenton the PEngines server (loaded at server startup), to being passed to the PEngines instance I create via the src\_text parameter given to the create() call. I do not get any errors during the create() call. Also, I set the destroy option set to false in the create() call . However, when I try to call one of the predicates found in the code in the src\_text parameter, I get an exist…

That’s what prompted me to try turning the code I load in the `src_text` property into a module. I know the **pengine\_execute\_single\_user\_action()** predicate is definitely there as you can see in the `src\_text property here:

```prolog
Error: procedure `'7cd30558-35dc-4ba6-9d64-348ba0837c11':pengine_execute_single_user_action(A,B)' does not exist
Object received:{
    "arg1": "procedure",
    "arg2": "'7cd30558-35dc-4ba6-9d64-348ba0837c11':pengine_execute_single_user_action('$VAR'(0),'$VAR'(1))",
    "code": "existence_error",
    "data": "procedure `'7cd30558-35dc-4ba6-9d64-348ba0837c11':pengine_execute_single_user_action(A,B)' does not exist",
    "event": "error",
    "id": "7cd30558-35dc-4ba6-9d64-348ba0837c11",
    "pengine": {
        "options": {
            "server": "http://localhost:3030/pengine",
            "application": "tsll",
            "destroy": false,
            "src_text": "% ===================== EXECUTE A USER COMMAND =======================\n% ----->>>>> execute_user_action_list\n%\n%\tThis predicate executes a list of actions and then accumulates the\n%\t\tevents generated in the per-volley temporary database predicate\n%\t\tin order to build a full response to the caller.\n\n% All actions executed\nexecute_user_action_list_1([]) :- !.\n\n% Execute the next action.\nexecute_user_action_list_1([Action | Action_T]) :-\n\tnonvar(Action),\n\t% Execute the next action.\n\tcall(Action),\n\t!,\n\texecute_user_action_list_1(Action_T).\n\n% This predicate is here to skip failed actions so that\n% other actions can be tried.\n% TODO: Revisit the soundness of the above strategy.\nexecute_user_action_list_1([_ | Action_T]) :-\n\t!,\n\t% Skip the action.\n\texecute_user_action_list_1(Action_T).\n\nexecute_user_action_list(ActionList, Response) :-\n\tnonvar(ActionList),\n\t% Clear out the database predicate clauses that accumulate\n\t%\tas events are added to the database during the current\n\t%\tvolley.\n\tu_retractall(temp(_)),\n\t% Execute the given list of actions. The events generated\n\t%\twill accumulate in the temp predicate.\n\texecute_user_action_list_1(ActionList),\n\t% Build our response for this volley.\n\tcreate_response(Response),\n\t!.\n\n% ----->>>>> execute_single_user_action\n%\tHelper function to execute just one user action.\nexecute_single_user_action(Action, Response) :-\n\tnonvar(Action),\n\texecute_user_action_list([Action], Response).\n\n% ----->>>>> pengine_execute_single_user_action\n\n%\tHelper function to execute just one user action.\n **pengine_execute_single_user_action** (Action, Response) :-\n\tnonvar(Action),\n\texecute_user_action_list([Action], Response),\n\t!.\n\t% item_to_dict(Response, JsonTerm).\n",
            "format": "json"
        },
        "id": "7cd30558-35dc-4ba6-9d64-348ba0837c11",
        "request": {}
    }
}

```

But as I show in that other thread, I get an _existence error_ when I try to call it from an `ask()` call, with or without having a module declaration at the top of the `src_text` code.

---

_[View the full topic](https://swi-prolog.discourse.group/t/exporting-predicates-in-the-code-loaded-into-pengines-via-the-src-text-parameter/763)._
