Using function in program
|
01-26-2014, 06:56 PM
Post: #1
|
|||
|
|||
Using function in program
Im trying to use a function in a program. Always getting some syntax error. Just trying to send 2 variables to a function and add them , then sending the result back . The function only needs to be accessible from the main program. Probably some error with declarations or something, but I don't get it.
Code:
|
|||
01-26-2014, 07:25 PM
Post: #2
|
|||
|
|||
RE: Using function in program
Remove the ; from the func declaration, and add BEGIN
My website: ried.cl |
|||
01-26-2014, 07:27 PM
Post: #3
|
|||
|
|||
RE: Using function in program
I think you need a BEGIN and END in the function and I dont think you need the a,b variables in Local and I believe result should be RETURN (c)
|
|||
01-26-2014, 07:36 PM
Post: #4
|
|||
|
|||
RE: Using function in program
I will show 3 versions. All of them will behave identically.
Code: Func3(a,b) Code: Func3(a,b) Code: Func3(a,b) Note that the reason these all behave the same is that there is *always* an implicit return on the last item in the runstream of the program. A function must return a single result. That result might not be used for anything, but it must return at least one thing. TW Although I work for HP, the views and opinions I post here are my own. |
|||
01-26-2014, 09:27 PM
(This post was last modified: 01-26-2014 09:28 PM by Graan.)
Post: #5
|
|||
|
|||
RE: Using function in program
Ok Func3(a,b); was wrong (no semicolon) and I needed a BEGIN. RESULT is pascal syntax should be: return. Seems as return c; and return(c); both works.
Thank you for the replies. |
|||
01-26-2014, 09:28 PM
Post: #6
|
|||
|
|||
RE: Using function in program
When creating a function with input variables, those variables are implicitly declared as local. Therefore, you would not use a LOCAL statement with them. For example,
Code:
The variables a and b do not need a LOCAL a,b statement inside the BEGIN END pair. Graph 3D | QPI | SolveSys |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)