PDocs 7: Importing Custom Modules - GitbyteMaster/PRIME-Lang GitHub Wiki

Importing Custom Modules

[v1.4.3]

The syntax for importing a module that isn't built into PRIME is similar to importing a built-in module, but just extended. Like so:

importfrmdir [Full Module Directory]

To actually create a PRIME module, is to just create a .prime file in any directory. Once importing your module, the script of the module is read and added to the PRIME interpreter's collected version of the file. It is a similar process to that of system.file.direct(). Only, instead of resetting interpreter data and reopening, it adds the module data to the current data already collected. Here is a simple demonstration.

//module.prime:
import system

system.display("I have!");

//script.prime:
importfrmdir C://Users/user/Desktop/module.prime

system.display("Have you been imported?");

//Output:
Have you been imported?
I have!

Pres any key to continue...

Because the module data is added at the very end of the interpreter data, it executes later unless it is just custom functions.