I created the program below is GCGB to test creating a function that adds two numbers.
When I compile I get the error:
"Error in addtwo at -1: Invalid variable name: IN DOG2"
Is this a bug or am I doing something wrong?
;Chip Settings
#chip 16F886,4
;Variables
Dim temp As byte
start:
temp = addtwo (2 , 3)
Goto start
'''@param dog1 1st Number
'''@param dog2 2nd number
Function addtwo (In dog1, In dog2)
addtwo = dog1 + dog2
Exit Sub
End Function
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you write Function (In_Dog1 , In_Dog2) I think your problem will be solved . Because you never have any space in your variables .
In GCGB help , at " Variables " Chapter , you can read :
"Each variable must be given a name, such as "MyVariable" or "PieCounter". Choosing a name for a variable is easy - just don't include spaces or any symbols (other than _), and make sure that the name is at least 2 characters (letters and/or numbers) long."
Regards
GC
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
One additional precision : your complete function will be :
Function Addtwo (In_Dog1 , In_Dog2) addtwo= In_Dog1 + In_Dog2 End function
"Exit sub" is not necessary because you'll exit the function and return just AFTER "end function" .If it's the end of the program then it stops !!
GC
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
GCGB created the space automatically. The parameter names don't have a space in them. The "In" represents input and then the variable dog1 and dog2.
I tried the underscore and still got the error.
I removed the Exit sub and still got the error.
Is there an example of a working function with two input parameters somewhere?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In GCBASIC, parameters for functions can only ever be in, so specifying a direction isn't needed. The function compiling code in GCBASIC doesn't know what to do with In or Out. However, GCGB was always putting an "In" before function parameters.
I created the program below is GCGB to test creating a function that adds two numbers.
When I compile I get the error:
"Error in addtwo at -1: Invalid variable name: IN DOG2"
Is this a bug or am I doing something wrong?
;Chip Settings
#chip 16F886,4
;Variables
Dim temp As byte
start:
temp = addtwo (2 , 3)
Goto start
'''@param dog1 1st Number
'''@param dog2 2nd number
Function addtwo (In dog1, In dog2)
addtwo = dog1 + dog2
Exit Sub
End Function
;Chip Settings
#chip 16F886,4
;Variables
Dim temp As byte
start:
temp = addtwo (2 , 3)
Goto start
'''@param dog1 1st Number
'''@param dog2 2nd number
Function addtwo (In dog1, In dog2)
addtwo = dog1 + dog2
Exit Sub
End Function
Hi,
If you write Function (In_Dog1 , In_Dog2) I think your problem will be solved . Because you never have any space in your variables .
In GCGB help , at " Variables " Chapter , you can read :
"Each variable must be given a name, such as "MyVariable" or "PieCounter". Choosing a name for a variable is easy - just don't include spaces or any symbols (other than _), and make sure that the name is at least 2 characters (letters and/or numbers) long."
Regards
GC
One additional precision : your complete function will be :
Function Addtwo (In_Dog1 , In_Dog2) addtwo= In_Dog1 + In_Dog2 End function
"Exit sub" is not necessary because you'll exit the function and return just AFTER "end function" .If it's the end of the program then it stops !!
GC
GCGB created the space automatically. The parameter names don't have a space in them. The "In" represents input and then the variable dog1 and dog2.
I tried the underscore and still got the error.
I removed the Exit sub and still got the error.
Is there an example of a working function with two input parameters somewhere?
That's a bug in GCGB, thanks for posting!
In GCBASIC, parameters for functions can only ever be in, so specifying a direction isn't needed. The function compiling code in GCBASIC doesn't know what to do with In or Out. However, GCGB was always putting an "In" before function parameters.
Please try downloading and installing this version:
http://gcbasic.sourceforge.net/newfiles/GCGB_Installer.exe
That should fix the problem.
Can I just install it over the existing version and will it keep all my PICkit 2 settings and sample files or do I have to do all that over again.
I just tried it. It lloks like it wrote over the PICkit2 setup but left all my programs alone in the demos folder.