Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Parameter Mismatch Error

Author
Message
Dabrits Entertainment
10
Years of Service
User Offline
Joined: 6th Oct 2014
Location: Florida
Posted: 12th Oct 2014 00:56
Hello!

First thread! I apologize if this is posted in the wrong section...please be gentle in your reprimands...

I'm trying my hand at developing a few game ideas using AGK. I enjoy the platform so far. I purchased the Hands on AppGameKit and the Teach Yourself Stuff books and am using those as guides.

My first real project for me was to replicate Daniel's Space Fighter Project Alpha; however, I've run into a parameter mismatch error I haven't been able to figure out.

While it would be great if someone familiar with the game could comment on the code specifically (pasted below for your convenience), that wouldn't necessarily help me learn. So one thing I'd really appreciate from you AppGameKit pros is tips/strategies for troubleshooting similar types of errors in the future.

The specific problem I'm receiving when I try to compile (f5), is "Parameter mismatch in expression 'MakeText' at line 40 inside media.agc"

Here's the code:


If there's more parts of the code I need to paste in here, please advise.

In my research of commands, I couldn't find the "MakeText" command. Is it defunct, or is my understand of commands and functions flawed? I also tried replacing "MakeText" with "CreateText" and that didn't work either.

Anyway, any thoughts or help would be greatly appreciated by this newb. Thanks in advance!

DE
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 12th Oct 2014 23:14 Edited at: 12th Oct 2014 23:15
Firstly, a parameter mismatch means one of two things:

1. A different number of parameters has been passed to what was expected
2. A different parameter type was passed.

The first is easy, you simply need to count your parameters passed, and compare to the number of parameters you set the function up with.

The second means you passed an integer when it expected a string, or a similar mismatch of parameter types. Again, you need to hunt it down. It is the line where you call the function, not the function itself, where the error is highlighted.

There's not really any tips for this kind of bug, other than to look at the error message and break it down to understand it's meaning. In this case you know the expression MakeText is a function...then it has something to do with it's parameters...and the problem is a mismatch. I know this sounds very basic, but sometimes frustration overrides the ability to sit back and ponder the error message. Then you just stare at line 40, and try to come to your own conclusions.

For runtime debugging issues, it is often a good idea to write text to the screen to track where you are and whether your parameter values make sense. Create a debug() function, fill it with print() commands and call it before every sync().

Personally, I write my debug statements out to a text file, then I can review the steps that lead me to the error.

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 13th Oct 2014 02:44 Edited at: 13th Oct 2014 02:45
the bracket is wrong u used ) after SetTextColor
Quote: "
System.iScreen_H * 0.21 , 1 ) : SetTextColor) Text.iHighscore_rating , Cyan, 255 )
System.iScreen_W * 0.575, System_H * 0.21, 1 ) : SetTextColor( Text.iHighscore_accuracy, Cyan, 255 )
"


AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini
Dabrits Entertainment
10
Years of Service
User Offline
Joined: 6th Oct 2014
Location: Florida
Posted: 13th Oct 2014 17:16
@BatVink

Thanks. That was all very helpful.

You pretty much described every evening this week for me, " sometimes frustration overrides the ability to sit back and ponder the error message. Then you just stare at line 40, and try to come to your own conclusions."

Based on your suggestions, I went back and tried to find the reason for the parameter mismatch. I took a harder look at the code I quoted above and discern how many parameters i was passing it. But I think the issue was actually I am trying to pass it parameters it isn't expecting. So I searched the rest of the code for anything to do with "MakeText" and found where I told the program what/how many parameters I was passing (pasted below). And this leads me to my follow-up question.

Is it correct to use commas [,] to separate pieces of information and the distinct parameters like I did in my code in my original post?




@Markus

Thanks for the catch! Fixed it.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 13th Oct 2014 17:48
Yes, that's exactly how you do it.

Markus, you have good eyesight, I don't know how you saw that!

Quidquid latine dictum sit, altum sonatur
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 13th Oct 2014 18:45 Edited at: 13th Oct 2014 18:46
@Dabrits Entertainment
i think you should return the id you had created
(and avoid global vars.)


@BatVink
Quote: "I don't know how you saw that!"

copied to notepad and just indent for each comma each row.
you have a better overview.

AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini
Dabrits Entertainment
10
Years of Service
User Offline
Joined: 6th Oct 2014
Location: Florida
Posted: 14th Oct 2014 05:24
@Markus

Thanks for the tip! I fixed that error (and about 40 more) and I'm now at least able to project the program on the screen and play.

There are still plenty more bugs to work out, but I'm making progress.

@BatVink

Thanks again for the help. I really appreciate the solid!

DE
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 14th Oct 2014 14:01
my experience,
it is better to write properly source code always,
you save much time for searching for errors/bugs also for later needed modifications

AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini

Login to post a reply

Server time is: 2024-11-25 09:49:15
Your offset time is: 2024-11-25 09:49:15