not enough arguments

I’ve learned xojo for a month now and have tried to use functions in my code. But when I run the app, it says there’s’ not enough arguments '. Can someone explain how to use functions and how I can tackle this error

Does it show a line of code for this error?

Methods and Functions have arguments…

Functions also returns a value.

Method_Name(Arg1,Arg2,Arg3) [and Function_Name(Arg1,Arg2,Arg3)] have - most of the time - to have the same number of arguments (arg1, arg2, arg3) than what is declared in the Method / Function declaration.

As Christian wrote above, you get the error and a line of code where the error lies. A click in that line (below the Code Editor) display the line where the error resides. Add there the correct and missing argument(s)…

what is an argument?

Ive inserted the arguments as you’ve said in brackets, and then it says “you must use the value returned by this function”

You need to have a good look at the documentation.

In former times (for instance VBS) you had subs and functions. subs don’t have a return argument, functions do.

In Xojo there are only functions. They either return something or not. You must have a return argument like string. Calling a function with a return argument is done with:

dim Result as string = myFunction(argument)

When you don’t have a return argument only do

myFunction(argument)

[quote]In Xojo there are only functions. They either return something or not. You must have a return argument like string. Calling a function with a return argument is done with:

dim Result as string = myFunction(argument)
When you don’t have a return argument only do

myFunction(argument)[/quote]

In XOJO, A Sub() or a Function() are both METHODS

If a Method has a return type in its definition, then Xojo treats it as a Function.
(And indeed to exit the code before the end, you can say ‘Exit’ or ‘Exit Function’)

If a Method has no return type defined, it is the same as a Vb SUB
(and indeed to exit that code, you either say ‘Exit’ or ‘Exit Sub’ … you get an error if you mix up Function / Sub here)

Anything you pass into a Method is an argument.

Example Display (“Hello World”)
has a string argument (maybe s as string)
It has no return type
So it is a Sub routine.

But MultiplyTwoNumbers( 8,9)
needs a return type, because you expect a value back
That makes it a Function

And you must use the return value, so typing MultiplyTwoNumbers( 8,9) will generate an error
But

MyVariable =MultiplyTwoNumbers( 8,9)
is fine

and so is

Call MultiplyTwoNumbers( 8,9)
… this last version throws the result away.

Couldn’t resist

so are arguments kind of like the same thing as parameters since you pass those around too?

Yes. 2 names for the same thing.

function setLED(RLEDPin as integer = 22, YLEDPin as integer=27, GLEDPin as integer = 17) as double
return setLED
GPIO.DigitalWrite(GLEDPin, GPIO.ON)
App.DoEvents(750)

GPIO.DigitalWrite(GLEDPin, GPIO.OFF)
App.DoEvents(500)
 exit function[setLED]

when I run the above it says ‘not enough arguments’ and ‘GLEDPin does not exist’ though I’m pretty sure I’ve done right. I’ve also created a method called setLED with “RLEDPin as integer, YLEDPin as integer, GLEDPin as integer” as its parameters. What seems to be the problem?

LIne #2 is returning a value that doesn’t exist … unlike VB… you return a literal (look it up), or a variable, not the name of the function

App.DoEvents does not do what VB does, and should be avoided except for special circumstances

And lastly… this function doesn’t create a value TO be returned…
It would be expected that the function/method use all the passed parameter (arguments), yet RLEDPin and YLEDPin are not ever used

As to the GPIO class… where is it defined? how is it defined? and what parmeters is it actually expecting?

And also from VBA: exit function isn’t needed.

The above code was only to test my sensor. I wanted to make sure that the code could light up an LED. I would add on the codes for the other LEDs later, but thanks @Dave S . I had the " GPIO.setupGPIO " code which wasn’t included.