For an example, both of the following would work and would do the same thing:
In C:
#include <stdlib.h>
#include <stdio.h>
int waitForThisKey(int Code);
void waitForAnyKey(void);
int waitForThisKey(int Code)
{
char c = (char)Code;
if(getch() == c) return 1; else return 0;
}
void waitForAnyKey(void) { system("pause"); }
In C++:
#include <cstdlib>
#include <cstdio>
using namespace std;
bool waitForThisKey(int Code);
void waitForAnyKey();
bool waitForThisKey(int Code)
{
if(getch() == (char c = (char)Code)) return true; else return false;
}
void waitForAnyKey() { system("pause"); }
GCC uses different rules for getch() as you may be used to (if you know C or C++), so compile these examples in Dev-C++ (http://www.bloodshed.net/dev/) as DLLs, and call them as you normally do in DarkBASIC. So:
For the C version (if it was named waitC.dll):
load dll "waitC.dll",1
x as integer
x = call dll(1,"waitForThisKey",100)
call dll 1,"waitForAnyKey"
delete dll 1
For the C++ version (if it was called waitCPP.dll):
load dll "waitCPP.dll",2
x as boolean
x = call dll(2,"waitForThisKey",100)
call dll 2,"waitForAnyKey"
delete dll 2
Note that the C++ version of waitForThisKey() returns a boolean value, so it is best to save it in a boolean variable. The C version will return it as an integer.
Hope that helps! If you have any problems, just ask!
For the Software You Want, AMPERSAND LABORATORIES is the place! [URL=http://www.andlabs.com/]
[/URL]