Jump to content


Photo

39Dll and GM8.1


  • Please log in to reply
5 replies to this topic

#1 Joe H

Joe H

    GMC Member

  • GMC Member
  • 352 posts
  • Version:Unknown

Posted 26 April 2012 - 10:20 PM

I've imported a script from an older version of GM which used 39dll. I am now trying to use that script with my GM version 8.1. I've run into an issue where I have gotten a bunch of "Wrong number of arguments" error messages. I've been able to simply adjust the inputs to correct many of these errors, but this one in particular has hung me up. When I use the 39dll script "receivemessage", It asks for 3 arguments (although the script says you only really need 1).

The 39dll script "receivemessage" has the following:

/*
Receives data from the selected tcp or udp socket and copies to the 
internal buffer.
Argument0 = Socket to recieve from.
[Argument1] = Amount of bytes to receive. Optional. Overrides the format
mode if used.
[Argument2]: The buffer id to receive to. Leave out this argument or set
it to 0 to use the default buffer.

returns the amount of bytes recieved
NOTE:
If you dont want to save the data to the defualt buffer, than do it like this:
receivemessage(sockid, 0, bufferid);
*/
return external_call(global._SokE, argument0, argument1, argument2);

The calling code that uses the "receivemessage" script is as such:

vAmount = receivemessage(argument0); //Receive one line, remember the amount of characters
    //If the amount of characters is larger than 0, proceed

The issue is that the calling code only has one argument. It would seem that the 39dll script "receivemessage" would handle this, but I am getting errors of "only 1 argument supplied, script requires 3 arguments."

Question 1:
- Do I need to include all of the arguments in order to use 39dll with GM8.1?

Question 2:
- Has someone already given a "quick fix" for this somewhere that I simply do not know about.

Any help is appreciated. Thank you.

Edited by Joe H, 26 April 2012 - 10:22 PM.

  • 0

#2 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5402 posts
  • Version:GM:Studio

Posted 27 April 2012 - 01:52 AM

yeah, that change is realy annoying ..

game options > errors tab > uncheck "throw an error when arguments arn't initialised correctly"
  • 1

#3 Joe H

Joe H

    GMC Member

  • GMC Member
  • 352 posts
  • Version:Unknown

Posted 27 April 2012 - 04:28 AM

yeah, that change is realy annoying ..

game options > errors tab > uncheck "throw an error when arguments arn't initialised correctly"



Your sir are a gentleman and a scholar. It works without forcing me to debug these inputs one at a time. You've saved me a bunch of time. Thank you.

Just as a side bar, why the change? Does it burden the program to ignore missing arguments or is this a "best practice" sort of thing?
  • 0

#4 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5402 posts
  • Version:GM:Studio

Posted 27 April 2012 - 06:45 AM

Many other programming languages does support inputs of unknown range of arguments, so I realy don't know why GM tries to limit it <>;;
  • 0

#5 A saurus1

A saurus1

    GMC Member

  • Sandbox Moderators
  • 1593 posts
  • Version:GM8.1

Posted 24 August 2012 - 01:51 AM

Also quick tip. Putting the arguments in brackets (an array) prevents them from being checked. So for example.

xx = argument0;
yy = argument1;
zz = argument[2];

will only require that arguments 0 and 1 be filled. If argument2 is left unfilled it defaults to zero but doesn't cause an error.
  • 0

#6 filulilus

filulilus

    GMC Member

  • GMC Member
  • 928 posts
  • Version:GM:Studio

Posted 24 August 2012 - 08:10 AM

The change they made so that arguments can be used as arrays is veeery usefull.
Example:

add_points()
for(i = 1; i < argument0 * 2; i += 2)
{
add_point(argument[i], argument[i +1])
}

add_points(3, 10, 10, 20, 20, 10, 20)
//add_points(points, x1, y1, xn, yn, ...)

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users