include question

26 views
Skip to first unread message

jf

unread,
Mar 30, 2025, 10:15:57 AMMar 30
to Picat
Hi,

I have:

main =>
   print("Start"),nl,
   include "i.pi",
   print(End),nl.

and i.pi is:
End = "End",

-----
But it says:

*** SYNTAX ERROR *** (8-11) missing ',', ';', or some other operator.
main =>
   print("Start"),nl,
   include  <<HERE>>
           "i.pi",
   print(End),nl.
-----
It should verbatim include the i.pi.
What is the right syntax?

Thank you
Josef

Hakan Kjellerstrand

unread,
Mar 30, 2025, 5:30:54 PMMar 30
to jf, Picat
Hi Josef.

include is a directive (e.g. like import) and must be placed outside the defined predicates.
Also, the file that's included must be a proper Picat program, and your suggested include file
   End = "End".
is not correct. Instead, define a predicate (or a function), e.g.
  e("End").

This should work:

* main program
"""
include "i.pi".

main =>
   print("Start"),nl,
   e(End),
   print(End),nl.
"""

* i.pi
"""
e("End").
"""

The output:
"""
Start
End
"""

Hope this help

Best,

Hakan


--
You received this message because you are subscribed to the Google Groups "Picat" group.
To unsubscribe from this group and stop receiving emails from it, send an email to picat-lang+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/picat-lang/c7f00733-120f-4b9d-9260-1d572f691786n%40googlegroups.com.


--

Hakan Kjellerstrand

unread,
Mar 30, 2025, 5:30:59 PMMar 30
to jf, Picat
Come to think of it, perhaps you should instead use cl/1 since it can be used in a predicate/function.

% main.pi
main =>
   print("Start"),nl,
   cl("i.pi"),
   e(End),
   print(End),nl.

% i.pi
e("End").


/Hakan

jf

unread,
Mar 31, 2025, 8:35:39 AMMar 31
to Picat

Dear Sir,

I know import for modules and cl, but import
must be placed separately in the header and
cl will consult the database, like e(End).

I thought import is something new, which will
enable us to initiate variables from other
files as well. For example if you use some
program (like Perl) to download and
save some file with data, you must read
and process them with Picat:

12 5 45
read_file_lines(F) ... split ...

while if you are in Perl you could just print
A = [12, 5, 45],

and then get it directly to Picat.

Best regards
Josef


Dne neděle 30. března 2025 v 23:30:59 UTC+2 uživatel Hakan Kjellerstrand napsal:
Reply all
Reply to author
Forward
0 new messages