Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (NewbieZorro, TipmyPip, 1 invisible), 19,045 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Possibly Noob help needed on Overload Functions [Re: DJBMASTER] #225949
09/06/08 20:53
09/06/08 20:53
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
Quoting DJBMASTER.
Quote:
Not sure if this is relevant, but its worth a try.

Seems relevant from over here.
Nicely done, if it is.


Guesses:
If Lite-C has a quick STRING* conversion macro (i.e. string() ), 'you' might trying passing char* constants wrapped in that macro.
Alternately, you might try to write additional overloaded functions which accept char* constants instead of STRING*.
Wait, is there an additional * in each function prototype / definition!?
Should ReturnPanel be a pointer to a pointer!?
tmpPanel doesn't look like a pointer to a pointer from over here.


Code:
//Declares/Prototypes (new)
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);
void PopupMenu(PANEL* ReturnPanel, char* SourceData, var layer);
void PopupMenu(PANEL* ReturnPanel, char* SourceData, var layer, var pos_x, var pos_y);
void PopupMenu(PANEL* ReturnPanel, char* SourceData, var layer, var pos_x, var pos_y, char* font);



Last edited by testDummy; 09/06/08 21:22.
Re: Possibly Noob help needed on Overload Functions [Re: DJBMASTER] #226028
09/07/08 13:20
09/07/08 13:20
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Hmm, interesting..... (bing! shocked!)
The snippet you sent works fine, but for some reason Im now thinking of this problem a different way...

Multiple times in this thread, people have been finicky about my typecasting, and Ive been shrugging
them off as I (mistakenly) believed that the Number-of-params would override typecasting.
IE I thought that typecasting is only important IF number of parameters MATCH.

Now, after everyones input, Im thinking that the overload will only be run
if BOTH type-casts AND Number-of-params Match, if theres no PERFECT match, then first
function/prototype is executed, AND if its Number-of-params is wrong, will generate a compile error.


So I NOW need to be picky about my type-cast BEFORE compile times. I normally leave
typecasting sloppy and fix then once the compile succeeds, but thats been screwing me here.

I'll be doing tests on this shortly, and I thank ALL who have contributed to this thread,
even if I did not take your advice before, it has finally gotten through my thick skin/Ego.
blush


"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] #226042
09/07/08 14:54
09/07/08 14:54
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Finally, thanks to everyones help, Ive got it.
Here are the working prototypes for the functions.
Code:
//Declares/Prototypes
void PopupMenu(PANEL* ReturnPanel, STRING* SourceData, int layer);  
void PopupMenu(PANEL* ReturnPanel, STRING* SourceData, int layer, int pos_x, int pos_y);
void PopupMenu(PANEL* ReturnPanel, STRING* SourceData, int layer, int pos_x, int pos_y, STRING* font);
and I dont need to put any typecasting in the calls except for _str() to use char constants.
Code:
PANEL* NewPanel=NULL;
...
PopupMenu(NewPanel, _str("SendThisAsString"), 1, 100, 200);
...  Gives me 
......'ReturnPanel' is a pointer to NewPanel, 
......'SourceData'  is a string containing "SendThisAsString", 
......'layer'       in an int containing '1', 
......'x_pos'       in an int containing '100', 
......'y_pos'       in an int containing '200'
Exactly what I wanted, and I now understand fully what I was doing wrong.

Another couple of things I leaned today were
1> if you pass a char constant parameter (eg func("xx");) it is converted to string automatically,
BUT GETS TREATED AS A CHAR ARRAY for deciding which overload to run.
2> Numeric constant parameters default to "int" in the call (ie func(15); == func((int)15);)
but the end function MUST specify that it is expecting an "int". ie func( int InValue ) {...}

I hope my problems here are of help to someone else.
And once again, thanks to ALL who helped me over this mental block.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Page 2 of 2 1 2

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

Gamestudio download | 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