Skip to content

Commit e2cbbe0

Browse files
committed
Initial upload
1 parent 534abac commit e2cbbe0

File tree

3 files changed

+2221
-0
lines changed

3 files changed

+2221
-0
lines changed

Example.pb

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
XIncludeFile "Includes\Julia\julia.pbi"
2+
3+
UseModule Julia
4+
5+
OpenConsole()
6+
7+
; #### Function which can be called from julia
8+
ProcedureC.d JL_Test(test.s)
9+
Debug test
10+
ProcedureReturn ValD(test) + 123
11+
EndProcedure
12+
13+
; #### Do not use julia if the library isn't loaded
14+
If Not IsLibrary(_JL_Library_ID)
15+
Print("Julia couldn't be loaded. Is it installed? Is the same architecture used for this application and julia (x86, x86-64)? Are environment varaibles set correctly? Press any key to exit...")
16+
Input()
17+
End
18+
EndIf
19+
20+
; #### Init julia
21+
If Not jl_init(#Null)
22+
Print("Julia couldn't be initialized. Are environment varaibles set correctly? Press any key to exit...")
23+
Input()
24+
End
25+
EndIf
26+
27+
PrintN("Julia Version: " + PeekS(jl_ver_string(), -1, #PB_UTF8))
28+
29+
; #### Make JL_Test callable from julia
30+
*Result = jl_eval_string("Something(s::String) = ccall(convert(Ptr{Void}, "+Str(@JL_Test())+~"), Float64, (Cwstring,), s)")
31+
If jl_exception_occurred()
32+
PrintN("Error: " + PeekS(jl_typeof_str(jl_exception_occurred()), -1, #PB_UTF8))
33+
EndIf
34+
35+
; #### Call Something (JL_Test())
36+
*Result = jl_eval_string(~"Something(\"123.321 test\")")
37+
If jl_exception_occurred()
38+
PrintN("Error: " + PeekS(jl_typeof_str(jl_exception_occurred()), -1, #PB_UTF8))
39+
EndIf
40+
41+
; #### Retrieve result
42+
If *Result And jl_is_float64(*Result)
43+
PrintN("Result (" + PeekS(jl_typeof_str(*Result), -1, #PB_UTF8) + "): " + StrD(jl_unbox_float64(*Result)))
44+
EndIf
45+
46+
Print("Press any key to exit...")
47+
Input()
48+
49+
; #### Tell julia that the program exits
50+
jl_atexit_hook(0)
51+
; IDE Options = PureBasic 5.42 LTS (Windows - x64)
52+
; CursorPosition = 28
53+
; Folding = -
54+
; EnableUnicode
55+
; EnableXP

0 commit comments

Comments
 (0)