Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (lijoyi2011), 1,034 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Possibly Noob help needed on Overload Functions #216295
07/16/08 11:32
07/16/08 11:32
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Hi all, can someone please point out what Im doing wrong here.

Ive read overloaded functions work fine, and I think Ive got
it right according to the manual, so what am I doing wrong?

If I use ANY but the first declared function, I get error
Quote:
'PopupMenu'. Wrong number/type of parameters

at compile time.

Code:
//Declares/Prototypes
void PopupMenu(PANEL* *ReturnPanel, STRING* SourceData, var layer);  //Want to keep this "default" if I can
void PopupMenu(PANEL* *ReturnPanel, STRING* SourceData, var layer, var pos_x, var pos_y);
void PopupMenu(PANEL* *ReturnPanel, STRING* SourceData, var layer, var pos_x, var pos_y, STRING* font);

//Usage  (FAILS unless I kill the first two prototypes and stick with the third)
PANEL* tmpPanel;
...
PopupMenu(tmpPanel,"Dummy_string_to_test_funtion",100,10,15,"Times New Roman#24b");
...

//Actual Functions
void PopupMenu(PANEL* *ReturnPanel, STRING* SourceData, var layer)
{   PopupMenu(ReturnPanel, SourceData, layer, 0, 0, ,"Times New Roman#12b");  }
//
void PopupMenu(PANEL* *ReturnPanel, STRING* SourceData, var layer, var pos_x, var pos_y)
{   PopupMenu(ReturnPanel, SourceData, layer, pos_x, pos_y, ,"Times New Roman#12b");   }
////
void PopupMenu(PANEL* *ReturnPanel, STRING* SourceData, var layer, var pos_x, var pos_y, STRING* font) 
{   ...performed code (eventually) by all overloads...   }


PS Ive tried with functions as VOID and FUNCTION and INT.

Thanks in advance


Last edited by EvilSOB; 07/17/08 02:14.

"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Possibly Noob help needed on Overload Functions [Re: EvilSOB] #216329
07/16/08 14:16
07/16/08 14:16
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Quote:

If I use ANY but the first declared function, I get error
Quote:
'PopMenu'. Wrong number/type of parameters

at compile time.

PopMenu or PopupMenu?

What is the line of code that causes the error?


Click and join the 3dgs irc community!
Room: #3dgs
Re: Possibly Noob help needed on Overload Functions [Re: Joozey] #216430
07/17/08 02:09
07/17/08 02:09
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
"PopupMenu" sorry, typo in posting. (will be edited)

PopMenu is a global panel pointer being used by the calling function
(which I'll also edit into original post)

Ive changed both the "PopMenu" pointer to "tmpPanel" in the code and changed the
string parameter contents to dummy data, to help remove possibly confusing looking names.

Hope this helps, and thanks for looking.

Last edited by EvilSOB; 07/17/08 02:17.

"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Possibly Noob help needed on Overload Functions [Re: EvilSOB] #217077
07/21/08 08:15
07/21/08 08:15
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Still no luck, tried puuting my functions in an include
and dropped the prototyping and no change, both as a
'.c" and a ".h" include.

Still no ideas from anyone else? This is really bugging me.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Possibly Noob help needed on Overload Functions [Re: EvilSOB] #225852
09/06/08 12:15
09/06/08 12:15
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
"bump"

Any fresh eyes have any ideas?

Or should I try dropping this issue into the "Ask Conitec" forum?


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Possibly Noob help needed on Overload Functions [Re: EvilSOB] #225880
09/06/08 14:50
09/06/08 14:50
Joined: Apr 2004
Posts: 516
USA
Trooper119 Offline
User
Trooper119  Offline
User

Joined: Apr 2004
Posts: 516
USA
Well most of your code looks pretty good, I think your looking to far into it though. It is possible your values your inputting it may be read as int's, double's, float's etc. To avoid this you should always define your variables you put into the functions you call.

ex:
Code:
var numA = 10;
var numB = 40;
var numC = 85;
STRING* charA, charB;
charA = "A message of sorts";
charB = "Another message";
//Then put those in the function


Otherwise make more functions with more combinations, it is also possible that your strings are being read as char's but I don't think that's likely.


A clever person solves a problem.
A wise person avoids it.
--Einstein

Currently Codeing: Free Lite-C
Re: Possibly Noob help needed on Overload Functions [Re: Trooper119] #225912
09/06/08 17:11
09/06/08 17:11
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Sorry Troop, but its failing at compile time, so values are immaterial.

To my way (possibly flawed) of thinking, the fact that my different overloads
have a different quantity of parameters should force through any type-cast issues.

This is the case in C.net anyway, and I think it was in C++ too.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Possibly Noob help needed on Overload Functions [Re: EvilSOB] #225920
09/06/08 17:50
09/06/08 17:50
Joined: Apr 2004
Posts: 516
USA
Trooper119 Offline
User
Trooper119  Offline
User

Joined: Apr 2004
Posts: 516
USA
To overload a function in C++ you have the same name but different variables (this can be different variables as in an int instead of double) or a different number of variables present. Any combination of these two works as well. If the error is correct (not holding my breath) it means your inputting the wrong variables compared to what is expected.

EDIT: Please note if the error is what I said it is, it would fail at compile time, if it is within the game, then the error would possibly occur when you first try to use the function, assuming at least one of those functions work.

My original suggestion I believe is still valid (unless you tried it already) please humor me and create a function that accepts doubles and ints and if they don't work, the error is incorrect. Then you'll have to look at other options.

In response to an earlier comment of yours, I'm not sure what function does but putting void, int, double etc. in front of your function simply tells the function that you are returning that kind of variable within the function. Unless you are returning something I suggest you stick with function or void. But you previously said you've tried both options so this is just an FYI to anyone who is confused on the matter.

EDIT: What call works and what call doesn't by the way? I'm curious.

EDITx2: The reason it may be bugging out on you is when you simply input 15 or "a message" into a function, the compiler is up to its own devices to figure out what that is, just because you want it to be a var doesn't mean it will be passed as such (in this case it should be an int I believe)

Last edited by Trooper119; 09/06/08 17:54.

A clever person solves a problem.
A wise person avoids it.
--Einstein

Currently Codeing: Free Lite-C
Re: Possibly Noob help needed on Overload Functions [Re: Trooper119] #225940
09/06/08 19:50
09/06/08 19:50
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
I tried changing to ints and it didnt make any difference, still fails on compile, "Wrong number/type of parameters".
ALL the overloads have a different NUMBER of parameters, and this number of parameters is unique to each overload variant, as in
the example in my original post. So shouldnt this 'number of parameters' variation override any type-casting issues?

FYI : I get the same problem whether I use prototypes for my overloaded functions or not.

What work and what doesnt is as follows, using these prototypes
Code:
//Prototypes
void PopupMenu(PANEL* *ReturnPanel, STRING* SourceData, var layer);
void PopupMenu(PANEL* *ReturnPanel, STRING* SourceData, var layer, var pos_x, var pos_y);
void PopupMenu(PANEL* *ReturnPanel, STRING* SourceData, var layer, var pos_x, var pos_y, STRING* font);
All compiles OK as long as I only call PopupMenu with three parameters (ie first overload).
Any other number of parameters and I get the compile error
Quote:
'PopupMenu'. Wrong number/type of parameters

But if I change the order to say
Code:
//Prototypes
void PopupMenu(PANEL* *ReturnPanel, STRING* SourceData, var layer, var pos_x, var pos_y);
void PopupMenu(PANEL* *ReturnPanel, STRING* SourceData, var layer, var pos_x, var pos_y, STRING* font);
void PopupMenu(PANEL* *ReturnPanel, STRING* SourceData, var layer);
All NOW compiles OK as long as I only call PopupMenu with FIVE parameters (ie new first overload).

Any ideas?


PS again please remember I get the same problem whether I use prototypes for my overloaded functions or not.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Possibly Noob help needed on Overload Functions [Re: EvilSOB] #225947
09/06/08 20:28
09/06/08 20:28
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
hmmmm maybe is has something to do with you sending char* datatypes instead of string*.

manual...

Code:
When the argument types don't match any of the overloaded functions, the first function is automatically used! 
This can happen when it expects a STRING* and a char* is passed. 
This is important when passing constants to overloaded functions: Text constants like "this is a text" are of type char*,not STRING*. 


so when you use...

PopupMenu(tmpPanel,"Dummy_string_to_test_funtion",100,10,15,"Times New Roman#24b");

wouldn't "Dummy_string_to_test_funtion" and "Times New Roman#24b" be passed as char* and not string*, causing a crash?

Not sure if this is relevant, but its worth a try.

If you have tried using ints and it still isn't working then your function must be wrong...

Try and compile this piece of code...

Code:
#include <acknex.h>
#include <default.c>
var c = 0;

function hello(int i, int j)
{
	for(c=0; c<(i+j); c++)
	{
		beep();
		wait(-1);
	}
	
}

function hello(int i, int j, int k)
{
	
	for(c=0; c<(i+j+k); c++)
	{
		beep();
		wait(-1);
	}
	
}

function hello(int i, int j, int k, int l)
{
	for(c=0; c<(i+j+k+l); c++)
	{
		beep();
		wait(-1);
	}
	
}

void main()
{
hello(3,5,2);
wait(-15);
hello(2,3,4,1);
}


Last edited by DJBMASTER; 09/06/08 20:46.
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1