-
Notifications
You must be signed in to change notification settings - Fork 0
Modules
Modules in jask are single files containing jask code. You can use modules to share your code with others so they can use it. This simple example will show you how modules work: Let's say you build a super fancy function called unicorn:
function unicorn()
printLine("Unicorns live among us!")
endSaved it in a file called unicornModule.jask and share it! Now your friends can import it using the use statement:
; import the module
use unicornModule
; and use the funtion!
unicorn()There are only two things to keep in mind:
- jask searches for modules in the current directory
- Import modules without the extension '.jask' If you have stored your modules in a different location, you can tell jask where to search:
use /my/module/path/unicornModuleThat's all!
Have a look at the following module:
function helloMessage()
printLine("I am a module!")
endIf you import this module in your jask code, you can call the function helloMessage. But what if your code also contains a function named helloMessage? Then, your local function will have a higher priority and gets called:
use moduleWithHelloMessage
function helloMessage()
printLine("I am jask code")
end
helloMessage()This will print
jask ~> I am jask codejask gives you the ability to remove modules during code executing:
use jcore/jnumber
printLine(PI())
remove jcore/jnumberUse this option when you no longer need the module.
- Home
- Getting started
- Control flow
- Functions
- Passing by value
- List variables in jask
- Dictionary variables in jask
- Structs in jask
- Convert variables
- Internal Functions
- The access operator
- Callbacks in jask
- Modules
- Internal Modules
- The jask standard library jcore
- Using CMD arguments in jask
- Nested function calls
- Functions inside functions!
- Modules inside functions!
- Performance comparison of loops