Codesnippets > Inline / 3rd party
DLL help
Maxheadroom:
first i tryed this (not even working)?
--- Code: GLBasic ---// --------------------------------- //
// Project:
// Start: Monday, October 23, 2006
// IDE Version: 3.283
LET lt=1
LET chip=1
startup
setltp
setoutput
END
INLINE
DLLCALL("K8D.dll", "start_8000", (void**) &start_8000);
DLLCALL("K8D.dll", "SelectI2CprinterPort", (void**) &SelectI2CprinterPort);
DLLCALL("K8D.dll", "ConfigIOchipAsOutput", (void**) &ConfigIOchipAsOutput);
extern "C" double (__stdcall* start_8000);
extern "C" double (__stdcall* SelectI2CprinterPort) (long lt);
extern "C" double (__stdcall* ConfigIOchipAsOutput) (long chip);
ENDINLINE
FUNCTION startup:
INLINE
start8000
ENDINLINE
ENDFUNCTION
FUNCTION setltp: it
INLINE
SelectI2CprinterPort (it)
ENDINLINE
ENDFUNCTION
FUNCTION setoutput: chip
INLINE
ConfigIOchipAsOutput (chip)
ENDINLINE
ENDFUNCTIONthen i tryed this ?
--- Code: GLBasic ---// --------------------------------- //
// Project:
// Start: Monday, October 23, 2006
// IDE Version: 3.283
LET lt=1
LET chip=1
// load the start up io
INLINE
extern "C" double (__stdcall* start8000);
DLLCALL("K8D.dll", "start_8000", (void**) &start8000);
ENDINLINE
// load lpt1
INLINE
extern "C" double (__stdcall* setltp1) (long lt);
DLLCALL("K8D.dll", "SelectI2CprinterPort", (void**) &SelectI2CprinterPort);
ENDINLINE
// load lpt1
INLINE
extern "C" double (__stdcall* setltp1) (long chip);
DLLCALL("K8D.dll", "ConfigIOchipAsOutput", (void**) &ConfigIOchipAsOutput);
ENDINLINE
PRINT 100,100,lt
SHOWSCREEN
MOUSEWAITand that a some errors
--- Code: GLBasic ---compiling:
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp: In function `int __GLBASIC__::__MainGameSub_()':
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:10: error: `LET' undeclared (first use this function)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:10: error: (Each undeclared identifier is reported only once for each function it appears in.)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:10: error: expected `;' before "lt"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:11: error: expected `;' before "chip"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:15: error: expected primary-expression before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:15: error: expected `;' before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:16: error: `start8000' undeclared (first use this function)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:22: error: expected primary-expression before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:22: error: expected `;' before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:23: error: `SelectI2CprinterPort' undeclared (first use this function)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:29: error: expected primary-expression before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:29: error: expected `;' before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:30: error: `ConfigIOchipAsOutput' undeclared (first use this function)
linking:
success
_______________________________________
*** Finished ***
Time: 1.4 sec
Build: 1 succeeded, 0 failed
Kitty Hello:
--- Quote from: Maxheadroom ---first i tried this (not even working)?
--- Code: GLBasic ---// --------------------------------- //
// Project:
// Start: Monday, October 23, 2006
// IDE Version: 3.283
// LET is dead. Please leave it.
lt=1
chip=1
// a function must be called with ( )
startup()
setltp(lt)
setoutput(chip)
END
// You must "end" the main game function
// this is done by forcing another function to
// begin and end
FUNCTION dummy:
ENDFUNCTION
INLINE
// here the order got messed up.
// first declaration and definition
// then linking to it
// also, don't forget the "=0", so you can check if
// the function has been loaded
extern "C" double (__stdcall* start_8000) = 0;
extern "C" double (__stdcall* SelectI2CprinterPort) (long lt) = 0;
extern "C" double (__stdcall* ConfigIOchipAsOutput) (long chip) = 0;
DLLCALL("K8D.dll", "start_8000", (void**) &start_8000);
DLLCALL("K8D.dll", "SelectI2CprinterPort", (void**) &SelectI2CprinterPort);
DLLCALL("K8D.dll", "ConfigIOchipAsOutput", (void**) &ConfigIOchipAsOutput);
ENDINLINE
FUNCTION startup:
INLINE
// in C++ always call functions with ( )
// and end a command with ';'
// also, check if the function could be loaded first:
if (start8000) // function pointer is good
{
start8000();
}
else
{
PRINT("Can't load function", 100, 100);
SHOWSCREEN();
MOUSEWAIT();
END();
}
ENDINLINE
ENDFUNCTION
FUNCTION setltp: it
INLINE
SelectI2CprinterPort (it); // semicolon
ENDINLINE
ENDFUNCTION
FUNCTION setoutput: chip
INLINE
ConfigIOchipAsOutput (chip); // semicolon
ENDINLINE
ENDFUNCTION
--- End quote ---
Maxheadroom:
Thanks that’s starting to make more sense, I will try it tonight, however should the call be start_8000(); ?
thanks max...
Kitty Hello:
Right. Typo from me. Just wanted to see if you read carefully ;)
Maxheadroom:
so close but so far.
--- Code: GLBasic ---// --------------------------------- //
// Project:
// Start: Monday, October 23, 2006
// IDE Version: 3.283
// LET is dead. Please leave it.
lt=1
chip=1
info=10
// a function must be called with ( )
startup()
setltp(lt)
setoutput(chip)
output(chip, info)
END
INLINE
extern "C" double (__stdcall* start_8000) = 0;
extern "C" double (__stdcall* SelectI2CprinterPort) (long lt) = 0;
extern "C" double (__stdcall* ConfigIOchipAsOutput) (long chip) = 0;
extern "C" double (__stdcall* IOoutput) (long chip, long info) = 0;
DLLCALL("K8D.dll", "start_8000", (void**) &start_8000);
DLLCALL("K8D.dll", "SelectI2CprinterPort", (void**) &SelectI2CprinterPort);
DLLCALL("K8D.dll", "ConfigIOchipAsOutput", (void**) &ConfigIOchipAsOutput);
DLLCALL("K8D.dll", "IOoutput", (void**) &IOoutput);
ENDINLINE
// You must "end" the main game function
// this is done by forcing another function to
// begin and end
FUNCTION dummy:
ENDFUNCTION
FUNCTION startup:
INLINE
// in C++ always call functions with ( )
// and end a command with ';'
// also, check if the function could be loaded first:
IF (start_8000) // function pointer is good
{
start_8000();
}
ELSE
{
PRINT("Can't load function", 100, 100);
SHOWSCREEN();
MOUSEWAIT();
END();
}
ENDINLINE
ENDFUNCTION
FUNCTION setltp: it
INLINE
SelectI2CprinterPort (it); // semicolon
ENDINLINE
ENDFUNCTION
FUNCTION setoutput: chip
INLINE
ConfigIOchipAsOutput (chip); // semicolon
ENDINLINE
ENDFUNCTION
FUNCTION output: chip, info
INLINE
IOoutput (chip,info); // semicolon
ENDINLINE
ENDFUNCTIONout put of the complier
--- Code: GLBasic ---_______________________________________
*** Configuration: WIN32 ***
precompiling...
GPC - GLBasic Precompiler V.2006.279 - 3D, NET
compiling...
k8000.gbas (1 KB)
Wordcount:10 commands
compiling:
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp: In function `int __GLBASIC__::__MainGameSub_()':
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:22: error: expected primary-expression before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:22: error: expected `;' before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:23: error: expected primary-expression before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:23: error: expected `;' before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:24: error: expected primary-expression before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:24: error: expected `;' before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:25: error: expected primary-expression before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:25: error: expected `;' before "extern"
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:26: error: `start_8000' undeclared (first use this function)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:26: error: (Each undeclared identifier is reported only once for each function it appears in.)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:27: error: `SelectI2CprinterPort' undeclared (first use this function)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:28: error: `ConfigIOchipAsOutput' undeclared (first use this function)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:29: error: `IOoutput' undeclared (first use this function)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp: In function `DGInt __GLBASIC__::startup()':
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:50: error: `start_8000' undeclared (first use this function)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:50: error: `IF' undeclared (first use this function)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:51: error: expected `;' before '{' token
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:55: error: `ELSE' undeclared (first use this function)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:55: error: expected `;' before '{' token
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp: In function `DGInt __GLBASIC__::setltp(DGInt)':
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:70: error: `SelectI2CprinterPort' undeclared (first use this function)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp: In function `DGInt __GLBASIC__::setoutput(DGInt)':
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:80: error: `ConfigIOchipAsOutput' undeclared (first use this function)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp: In function `DGInt __GLBASIC__::output(DGInt, DGInt)':
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:90: error: `IOoutput' undeclared (first use this function)
linking:
success
_______________________________________
*** Finished ***
Time: 1.3 sec
Build: 1 succeeded, 0 failed
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version