Argument count mismatch?

New to FreeBASIC? Post your questions here.
Post Reply
falcron
Posts: 57
Joined: Jan 18, 2008 15:55

Argument count mismatch?

Post by falcron »

Can someone explain why I am receiving an an argument count mismatch with this sample code? There are 7 arguments, first 5 being integers, and last two being strings. The function returns a string, which I define "com" as. I don't see why this doesn't work.

I'm a decent FB programmer (by no means a master), but this is really elementary, and I know I'm making a stupid mistake somewhere.

Code: Select all

DECLARE FUNCTION GetInput (intType AS Integer, intLen AS Integer, intFGColor AS Integer, intBGColor AS Integer, intComma AS Integer, strDefaultValue AS String, strPrompt AS String) AS String

dim com as string

com = GetInput 1, 5, 15, 1, 1, "100", "Enter a string: "

FUNCTION GetInput (intType AS Integer, intLen AS Integer, intFGColor AS Integer, intBGColor AS Integer, intComma AS Integer, strDefaultValue AS String, strPrompt AS String) AS String

' All the code for this function is here

END FUNCTION
maddogg6
Posts: 824
Joined: Dec 07, 2005 22:58
Contact:

Post by maddogg6 »

maybe because COM is an FB keyword??
Try changing that to COMM or something...

My only hint was how the forum decorated that word.
falcron
Posts: 57
Joined: Jan 18, 2008 15:55

Post by falcron »

I'm sorry - I should have clarified - the variable doesn't matter.

I can just as easy replace com with "a"
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Post by MichaelW »

GetInput(1, 5, 15, 1, 1, "100", "Enter a string: ")

This is a fairly easy mistake to make, so I think the handling of it needs some work.
Last edited by MichaelW on Jun 12, 2008 5:06, edited 1 time in total.
falcron
Posts: 57
Joined: Jan 18, 2008 15:55

Post by falcron »

Told you it was a stupid mistake. Talk about a brain freeze.

Thank you MichaelW.
anonymous1337
Posts: 5494
Joined: Sep 12, 2005 20:06
Location: California

Post by anonymous1337 »

I thought that parenthesis were optional? What was the mistake?
falcron
Posts: 57
Joined: Jan 18, 2008 15:55

Post by falcron »

The parenthesis made it work. I think they were required. Were they supposed to be optional?
KristopherWindsor
Posts: 2428
Joined: Jul 19, 2006 19:17
Location: Sunnyvale, CA
Contact:

Post by KristopherWindsor »

anonymous1337 wrote:I thought that parenthesis were optional? What was the mistake?
I think they are required for functions.
krcko
Posts: 163
Joined: Jul 30, 2006 0:34
Location: Serbia
Contact:

Post by krcko »

parentheses are optional when you are just calling sub/function:

Code: Select all

mySubOrFunction a, b, c, d

but when you're assigning function's result to some variable than they are required:

Code: Select all

x = myFunction(a, b, c, d)
anonymous1337
Posts: 5494
Joined: Sep 12, 2005 20:06
Location: California

Post by anonymous1337 »

Alright. I gotcha now.
jevans4949
Posts: 1186
Joined: May 08, 2006 21:58
Location: Crewe, England

Post by jevans4949 »

com can be used as a variable name.

Code: Select all

dim com as string
com = "aaa"
print com
sleep
Should this be allowed?

EDIT: Even wierder:

Code: Select all

dim com as string
dim s as string
com="C:/AUTOEXEC.BAT"
open com for input as #1
while EOF(1) = 0
    line input #1,s
    print s
wend
close #1
sleep
cha0s
Site Admin
Posts: 5319
Joined: May 27, 2005 6:42
Location: USA
Contact:

Post by cha0s »

Yeah, some of the quirk functions don't actually reserve their keywords, like put's ALPHA or TRANS. In the case of OPEN, your symbol will take precedence.
Post Reply