Id like someone to take a look at this piece of code and tell me any errors to correct, ms-vc++ 6.0 says there are 3, but when I correct them it creates more errors (example being: going from 3 errors to 18 with one ';' going in)
Help appreciated.
Here is the code:

// --------------------- Database Management Library ---------------------------------
// Do not modify this.

function	script	func_searchdb	{
	set $@array_size, getarraysize(getarg(0));
	for(set $@db_count, 0; $@db_count < $@array_size; set $@db_count, $@db_count + 1){
		if(getelementofarray(getarg(0), $@db_count) == getarg(1))
			return $@db_count;
	}
	return -1;
}

function	script	func_addentry	{
	if(getarraysize(getarg(0)) < 127) {
		if(getarg(0) != 0)
			set getelementofarray(getarg(0), getarraysize(getarg(0))), getarg(1);
		else
			set getarg(0), getarg(1);
		return 0;
	}
	return 1;
}

function	script	func_removeentry	{
	set $@re_entry, callfunc("func_searchdb", getarg(0), getarg(1));
	if($@re_entry != -1)
		deletearray getelementofarray(getarg(0),$@re_entry),1;
	return;
}

// --------------------------- Core Function -----------------------------------------
// Do not modify this.

function	script	func_soundall	{
	set $@rid_backup, playerattached();
	for(set $@dbe_cnt2, 0; $@dbe_cnt2 < $@rid_dbe_num; set $@dbe_cnt2, $@dbe_cnt2+1) {
		set $@database_name$, getarg(0) + $@dbe_cnt2;
		set $@array_size, getarraysize(getd($@database_name$));
		for(set $@sa_count, 0; $@sa_count < $@array_size; set $@sa_count, $@sa_count + 1){
			if(attachrid(getelementofarray(getd($@database_name$), $@sa_count)) != 0)
				soundeffect getarg(1), 0;
		}
	}
	attachrid $@rid_backup;
	return;
}

// --------------------------- Database Handler --------------------------------------
// Modify according to your needs.
-	script	database_handler	-1,{
	end;

OnInit:
	// The base database name
	set $@rid_database_name$, "$@rid_database_";
	// The maximum number of database to allocate
	// Adjust this to your needs, each database is capable of holding 127 players.
	set $@rid_dbe_num,;
	end;

}

// ------------------------ Login/Logout Events --------------------------------------
// Modify this depending on your server's configurations.
// If event_type is set to label mode, be sure to modify the code below.

-	script	PCLoginEvent	-1,{
	set $@dbe_cnt,;
	while(callfunc("func_addentry", getd($@rid_database_name$ + $@dbe_cnt), playerattached()) != 0)
		set $@dbe_cnt, $@dbe_cnt + 1;
	set soundall_database, $@dbe_cnt;
	end;
}

-	script	PCLogoutEvent	-1,{
	callfunc "func_removeentry", getd($@rid_database_name$ + soundall_database), playerattached();
	end;
}

// -------------------------- Sample Script -----------------------------------------
// To use this library, call the function func_soundall
// Syntax:
// callfunc "func_soundall", <rid-array-variable>, <wav-file>;

prontera.gat,180,200,4 Sampler 111,{
	callfunc "func_soundall", $@rid_database_name$, "se_organ02";
	end;
}

there is no such thing (keywords) as function script in either c or c++. maybe in managed c++ (I don't know managed c++), but VC++ 6.0 compiler doesn't know how to compile managed code.

'Script' is an external function being called.
Its just general errors it contains, thats what I need help identifying..

'Script' is an external function being called.
Its just general errors it contains, thats what I need help identifying..

not according to the code you posted -- its just so much garbage.

[edit]A closer look shows that the code you posted is neither C or C++, maybe pascal or some other language.

$@db_count

The above is not a C or C++ variable construction.

It is for a group of source files which is why some things dont make sense.
The errors I'm getting are:

F:\Mike\eAAC Test Part I.cpp(4) : error C2146: syntax error : missing ';' before identifier 'script'
F:\Mike\eAAC Test Part I.cpp(4) : error C2501: 'function' : missing storage-class or type specifiers
F:\Mike\eAAC Test Part I.cpp(4) : fatal error C1004: unexpected end of file found

Just general errors it's found.

It is for a group of source files which is why some things dont make sense.
The errors I'm getting are:

F:\Mike\eAAC Test Part I.cpp(4) : error C2146: syntax error : missing ';' before identifier 'script'
F:\Mike\eAAC Test Part I.cpp(4) : error C2501: 'function' : missing storage-class or type specifiers
F:\Mike\eAAC Test Part I.cpp(4) : fatal error C1004: unexpected end of file found

Just general errors it's found.

Yup ! just as I already told you, the compiler has no clude what function keyword is. It ain't c or c++.

The file is a game script from RagnarokOnline, its a database management library.
Things like OnInit are commands from the games source, would it recognise it if I defined it?

EDIT:
Adding :

#define function
#define script
#ifndef function
#ifndef script

Removed 2 of the 3 errors, last error is:

Part I.cpp(95) : fatal error C1004: unexpected end of file found

How can I fix this?

the source was not written in either c or c++, maybe in basic of java. you will have to do a complete rewrite (port) if you want to use a c or c++ compiler. And the answer to your question is No -- simply declaring the function will not fix the errors.

[edit]
>>How can I fix this?

put at the very top of the program

#include "stdafx.h"
.. // rest of code here

or remove precompiled header requireents.

Including that stdafix.h didnt fix it.. How do I remove the precompiled header requirements?

menu Project --> Settings, select the c++ tab, select Category of Precompiled Headers then select the radio button Not using precompiled headers

Hmmmmm....that didnt fix it either.. Fatal errors are by far the most annoying to debug >_<"

like I said before, you wil be spinning your wheels because you are attempting to compile a program that isn't c or c++. you might also make macros out of those funny-looking variable names to redefine then according to c and c++ rules.

#ifndef function

do you have a matching #endif for that???

Macros eh? Hmmm, how can I redefine them to C/C++ rules?
Thanks alot for your help so far, I appreciate it.
EDIT:
I didnt have an #endif, but when I placed one in it created 62 errors =\
EDIT 2: The 62 errors came from an #endif in the script file, it still has 1 error if i put the #endif function in.

I just tried it -- macors won't work either because the compiler doesn't like the '@' character. You will have to resort to brute force and manually make all the changes. For example, change $@db_count to db_count. you also will have to declare the data types because c will not let you use a variable before it is defined, line vb will do.

What do you mean 'line vb will do'?
Ok, Ive removed all the $ and @, and still have the error, what is it I have to define?

<<'line vb will do'

typo -- replace "line" with "like".

You do know how to write c/c++ programs don't you?

I don't think it will be very easy to port that code. What are you trying to do anyway? Why port it at all? there is a huge amount of code examples to follow if you want to access a database in c or c++. There are even some c++ classes on the net.

Its not really for porting, I just needed to find and fix the errors in it, thats all it was for. The last is proving to be remarkably difficult to solve.. And yes, I do know how to write c/c++ programs, Im just not an elite at it.

set $@array_size, getarraysize(getarg(0));

That is neither a standard C or C++ statement. You will have to find out what language it was written in, then learn what it does. my guess is that it is assigning the return value of function getarraysize() to variable $@array_size

int array_size = getarraysize(getarg(0));

now I have no clue what getarg(0) will return. you will need to find that out too.

All that stuff like OnInit, db_count and such is all already defined in the RO source code, its C++ but its been defined in another file, the file I posted just has some general debug errors, 2 of which I fixed. I looked up the fatal error C1004 on the msdn homepage, but it doesnt look to be much help.

its C++ .

No it is NOT c++. The code you posed is probably run through another language's preprocessor which translates it into c++ code. You cannot compile that code directly with a c++ compiler. It must be interpreted by anothr preprocessor first.

Many database 4GL programs are like that. The code is similar to c an c++, but isn't.

>>C1004
you can get that error several ways. mismatches braces, brackets #ifdef/#endif are a few. It can be a real bear sometimes to find the error. One of my debugging solutions to find it is to start commenting out large blocks of code until I find the problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.