in reply to Re: YASWI "Prolog System Error: Thread 1"
in thread YASWI "Prolog System Error: Thread 1"

Hi Salva

Well after a few version control problems of my own making, we're back to a stable system.

I've implemented the line you suggest at the beginning of the module (.pm file). However, I'm not sure that it's the optimum way. This is what it looks like now:

updated

#!/usr/bin/perl -w use strict; package i_observation; ######################delete block ########################## use Wx 0.15 qw[:allclasses]; use strict; use warnings; use Wx qw[:everything]; use Wx::Event qw( EVT_MENU ); use base qw(Wx::Frame); use threads (); # Used for mult +i-tasking ffmpeg use Threads; # Used in Timer to + determine state of tasks use base qw(Wx::Panel Class::Accessor::Fast); __PACKAGE__->mk_ro_accessors( qw(html_help chm_help comboctrl) ); use Language::Prolog::Yaswi qw(:load :run :query); use Language::Prolog::Types::overload; use Language::Prolog::Sugar functors => {location_organ => 'location_organ', location_segment => 'location_segment', listsegments => 'listsegments', listwalls => 'listwalls', diagnosis => 'diagnosis' }, chains => { orn => ';', andn => ',', add => '+' }, vars => [qw (X Y Z)]; swi_init(qw(-nosignals -g true)); sub new{ . . . # other routines in the package . . . sub set_location_list{ . . . . my @files = (t("/home/steve/Documents/i_prolog.pl")); swi_consult @files; . . . }

So, it's not clear to me when the code before any routines gets executed. The error now is:

% /home/steve/Documents/i_prolog.pl compiled 0.00 sec, 32,784 bytes % /home/steve/Documents/i_prolog.pl compiled 0.00 sec, 0 bytes % /home/steve/Documents/i_prolog.pl compiled 0.00 sec, -232 bytes

So it looks as though it is called three times. UPDATE: Actually these messages come way before the crash now. There is no crash message at all, so I need to step through the code and find the crash. It may not be Prolog related. Sorry for the confusion.

Regards

Steve

Replies are listed 'Best First'.
Re^3: YASWI "Prolog System Error: Thread 1"
by salva (Canon) on Jan 20, 2010 at 15:21 UTC
    So, it's not clear to me when the code before any routines gets executed. The error now is:
    % /home/steve/Documents/i_prolog.pl compiled 0.00 sec, 32,784 bytes

    This is not an error, just a message telling you the Prolog module i_prolog.pl has been loaded. If you get it several times it is probably because you are calling set_location_list() repeatedly.

    Without seeing the full source code of your application I can only guess, and maybe there are some real bugs on the module annoying you, but it seems to me that the actual problem is that you don't got it yet. You should become more familiar with the module and Prolog and how they work together before trying to use them inside a complex application.

      Hi Salva,

      It's true I am.

      Can I just clarify something? Whan I *first* call prolog, the prolog engine is loaded in a second thread, so I don't need to consult the file again. Once i_prolog.pl is loaded, it stays loaded and the engine stays running until the application ends? Is that right? I had been assuming that once I exited the module all the variables cleared themselves, because thgey were out of scope. I get the feeling that this is not true. So the only reason for calling consult @files again is if the files change for any reason, eg if I dynamically alter i_prolog.pl. Have I got that right?

      Thanks for your patient and expert help, it's truly invaluable.

      Regards

      Steve

        Once i_prolog.pl is loaded, it stays loaded and the engine stays running until the application ends?

        Yes, that's it. In this regard, Prolog is similar to Perl, once you load a module, the subs/predicates defined there remain defined until you shutdown the program.