#Compiled / #EndCompiled

<< Click to Display Table of Contents >>

Navigation:  ThinBASIC and FreeBASIC interop >

#Compiled / #EndCompiled

 

Description

 

Defines section of FreeBASIC source code inside ThinBASIC script.

 

Syntax

 

#Compiled [SuppressRTE] [language = LanguageName]

 {FreeBASIC statements and exported functions}

#EndCompiled

 

Returns

 

Parameters

 

Remarks

 

There can be multiple #Compiled / #EndCompiled sections in your thinBasic script(s).

 

The content of all #Compiled / #EndCompiled sections will be concatenated into a single FreeBASIC source code and compiled automatically by ThinBASIC into a single DLL to be usable from thinBASIC script.

 

DLL will be named with the same name of the ThinBASIC script and placed into the same directory.

The name of the compiled DLL can be retrieved at script runtime via Compiled_DLL_FileName command.

 

In case there are functions or subs defined inside the #Compiled / #EndCompiled, they can be used directly from ThinBASIC code without the need to declare them if and only if:

1.they use CDECL calling convention

2.they use EXPORT to be visible from DLL

 

If SuppressRTE option is present, no classic thinBasic runtime error will occur in case of errors

 

Language option will be used for future compiled langaues other than FreeBASIC.

Actually ONLY FreeBasic is allowed in case Language option is specified - at the moment.

 

Restrictions

 

If FreeBASIC code will contain errors, a standard ThinBASIC runtime error window will appear showing output from FreeBASIC compiler.

 

If programmer wants to handle FreeBASIC compiler errors, use SuppressRTE option. In this case no ThinBASIC runtime error window will appear and programmer can use Compiled_LastCompile_Result and Compiled_LastCompile_Output functions to handle errors.

 

See also

 

Examples

 

#Compiled

 

sub SayHelloFromFreeBasic cdecl alias "SayHelloFromFreeBasic" (byref sMessage as zstringexport

  print sMessage

end sub

  

#EndCompiled

 

uses "Console"

 

' Thanks to thinBASIC autodetection,

' the FreeBasic function is discovered automatically

SayHelloFromFreeBasic("Hello, BASIC")

 

printl "Press a key to end..."

waitKey