'SELECT COMPILER
if mo=1 'SHIFT ONLY
s="\co2m64.exe" 'CO2M64 64BIT COMPILING
else '
s="\co2.exe" 'CO2 COMPILING
's="\gxo2.exe" 'GXO2 COMPILING
endif
'RUN COMPILER AS A SEPARATE PROCESS
'Exec qu+o2dir+s+qu+" "+qu+OxyPath(f)+qu
's=qu+o2dir+s+qu+" "+cmo+qu+OxyPath(f)+qu
'Exec(s)
QuExec( o2dir+s, cmo, OxyPath(f) )
end if
end if
'process flags:
%CREATE_NEW_CONSOLE 0x00000010
%CREATE_NO_WINDOW 0x08000000
'etc
'
function Exec(string c, int wait=0, flags=0) as int
===================================================
STARTUPINFO infs
PROCESS_INFORMATION infp
CreateProcess null,c,0,0,0,flags,0,0,@infs,@infp
if wait
WaitForMultipleObjects 1,@infp.hthread,1,-1
end if
GetExitCodeProcess(infp.hProcess,@function)
CloseHandle infp.hProcess
CloseHandle infp.hThread
return 0
end function
function QuExec(string c,d,f, int wait=0,flags=0) as int
========================================================
return Exec(qu+c+qu+" "+d+" "+qu+f+qu, wait,flags)
end function
function DOS(string s, int wait=0,flags=0)
==========================================
string c
if s then
c="cmd.exe /c "+s
else
c="cmd.exe"
end if
Exec c, wait,flags
end function
extern lib "oxygen.dll"
uses oxygenAPI
end extern
'12:43 18/03/2017
'23:23 29/07/2022
'ABST
'====
'compile source code string and return intermediate code string
! o2_abst( string s ) as string
'BASIC
'=====
'compile source code string to binary code, and return pointer
! o2_basic( string s ) as sys
'BUF
'===
'select current binary code buffer and return pointer
! o2_buf( int n ) as sys
'ERRNO
'=====
'return error number, if any
! o2_errno() as int
'ERROR
'=====
'return compiling error string, if any
! o2_error() as string
'EXEC
'====
'execute inary code in current buffer (or from location specified by pointer
! o2_exec( sys p=0 ) as sys
'LEN
'===
'return length of code in current binary code buffer
! o2_len() as int
'LIB
'===
'return base location of o2 runtime function table
! o2_lib() as sys
'LINK
'====
'compile o2 machine script to binary and return pointer
! o2_link( string src ) as sys
'STATS
'=====
'return set of compilation metrics
! o2_stats() as string
'MODE
'====
'specify string mode for various o2 API functions
'0 ascii char*
'1 ascii char*
'2 unicode wchar*
'8 ole bstring ascii
'9 ole bstring ascii
'10 ole bstring unicode
! o2_mode( int m )
'PATHCALL
'set callback to obtain hosted oxygenBasic path string
! o2_pathcall( sys m )
'PREP
'====
'compile source code string and return assembly code string
! o2_prep( string s ) as string
'VARCALL
'=======
'set callback to obtain host variable location, by name
! o2_varcall( sys m )
'VERSION
'=======
'return version string, include time/datestamp
! o2_version() as string
'VIEW
'====
'compile source code string and return o2 machine script string
! o2_view( string s ) as string
o2_mode 9 'for oxygenBasic ascii strings
#COMPILE EXE
#DIM ALL
#INCLUDE "Win32api.inc"
' if I am loading 'co2.exe' I have got an error "You must set the path ofa the headers"
DECLARE FUNCTION o2_basic(BYREF s AS ASCIIZ) AS LONG
DECLARE FUNCTION o2_exec (BYVAL p AS LONG) AS LONG
DECLARE FUNCTION o2_errno() AS LONG
'DECLARE FUNCTION o2_error() AS ASCIIZ*260 PTR '' error
DECLARE FUNCTION ThisFunction() AS LONG
FUNCTION PBMAIN () AS LONG
DIM lHandle AS LONG
DIM lResult AS LONG
DIM lAddress AS LONG
lHandle = LoadLibrary("oxygen.dll")
IF lHandle <> 0 THEN
lAddress = GetProcAddress(lHandle, "thisFunction")
IF lAddress <> 0 THEN
CALL DWORD lAddress USING ThisFunction() TO lResult
END IF
FreeLibrary lHandle
END IF
'
DIM qu AS STRING
DIM cr AS STRING
DIM src AS ASCIIZ*260 'STRING
qu=CHR$(34)
cr=CHR$(13)+CHR$(10)
src="print " + qu+"Hello Batman"+qu+cr
MSGBOX "src: " + src
'
o2_basic(src) ' error undefined sub/function reference
'
IF o2_errno()<>0 THEN
'PRINT o2_error()
'ELSE
o2_exec(0)
END IF
END
END FUNCTION
Page created in 0.135 seconds with 11 queries.