Post Reply 
define questions
06-21-2017, 02:04 PM
Post: #2
RE: define questions
Your functions are being defined as such in essence:

auto INC(auto X)
{
return X=X+1; //global X is masked, only local variable is modified
}

There is no reference being passed here, and X is local to the function. It is not a macro in any way shape or form. You are passing the value of something, and returning the value.

Now if you are wanting to increment the "global" X value, defining your function should be done like so instead:

X:=N+1;

Then uncheck the X as an input value. That would give you:

auto INC(auto N)
{
return X=N+1; //global N is masked, global X real variable modified
}


Defined functions through the interface are meant to be a way for new users to define algebraic functions for use during calculations primarily. Honestly, I'm not sure why you are seeing the error message when calling it from the CAS. We'll check into this. However, the CAS is a functional runtime language and defining a function in the CAS is directly done by just typing this on the command line:

myfunc(a):=begin a:=a+1; end;

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
define questions - webmasterpdx - 06-21-2017, 12:31 PM
RE: define questions - Tim Wessman - 06-21-2017 02:04 PM
RE: define questions - DrD - 06-21-2017, 02:14 PM
RE: define questions - webmasterpdx - 06-21-2017, 03:17 PM
RE: define questions - Didier Lachieze - 06-21-2017, 11:07 PM
RE: define questions - DrD - 06-21-2017, 09:19 PM
RE: define questions - AlexFekken - 06-22-2017, 02:12 AM
RE: define questions - webmasterpdx - 06-22-2017, 12:05 PM



User(s) browsing this thread: 2 Guest(s)