HP Forums
New to programming - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: New to programming (/thread-4123.html)



New to programming - Clod - 06-10-2015 01:24 AM

Hi everyone! I've recently purchased the HP-Prime and I'm struggling to get a program of my own to work. First I did the following one:

Code:

#cas
tvf(H,Xi):=
BEGIN
  LOCAL ans;
  ans:=limit(H*Xi,x,0);
  return ans;
END;
#end

Which works just fine... Howeeeeeeeeeeeeeeeeeeever, it seems I'm not able to use the "EXPORT XXX()" command which would allow me not to write "tvf()" manually (which is a pain in the ass). So, I t[/code][/php]ried to do this next:

Code:

EXPORT PROGRAMS(H,Xi)
BEGIN
  LOCAL ans;
  ans:=CAS.limit(H*Xi,X,0);
  return ans;
END;

This one has two problems. The first one, it won't allow you to use the "x" in lowercase (so I have to use the uppercase one, which is bothersome) aaaaaaand whenever the answer is infite or zero it just return an "undefine"... Could someone help me out please? Big Grin


RE: New to programming - Clod - 06-10-2015 04:56 AM

Got the answer by myself. Just read some of the old posts, sorry for not doing it sooner :C

Hope this helps other lazy people like me Tongue

Code:

EXPORT tvf(H,Xi)
BEGIN
  LOCAL ans:= CAS.limit(H*Xi,"x",0);
  return ans;
END;



RE: New to programming - Didier Lachieze - 06-10-2015 06:32 AM

(06-10-2015 01:24 AM)Clod Wrote:  Howeeeeeeeeeeeeeeeeeeever, it seems I'm not able to use the "EXPORT XXX()" command which would allow me not to write "tvf()" manually (which is a pain in the ass).

The CAS programs are not visible as other programs in the Toolbox > User menu but they are listed in the Vars > CAS menu, so you can access them without having to spell them on the keyboard.

On this topic, there is a great article from Han in the Article Forum section: HP Prime CAS Programming.


RE: New to programming - Angus - 06-10-2015 06:33 AM

Did you know that if you write a cas program it is listed under Vars/CAS/Program not in the Toolbox/User section? I think that is not too clearly arranged, but in an other post Tim pointed out that they chose that until they find a perfect solution for the filesystem.

I am not sure if you knew because of
Quote: "EXPORT XXX()" command which would allow me not to write "tvf()" manually (which is a pain in the ass).



RE: New to programming - Clod - 06-11-2015 02:19 AM

(06-10-2015 06:32 AM)Didier Lachieze Wrote:  
(06-10-2015 01:24 AM)Clod Wrote:  Howeeeeeeeeeeeeeeeeeeever, it seems I'm not able to use the "EXPORT XXX()" command which would allow me not to write "tvf()" manually (which is a pain in the ass).

The CAS programs are not visible as other programs in the Toolbox > User menu but they are listed in the Vars > CAS menu, so you can access them without having to spell them on the keyboard.

On this topic, there is a great article from Han in the Article Forum section: HP Prime CAS Programming.

(06-10-2015 06:33 AM)Angus Wrote:  Did you know that if you write a cas program it is listed under Vars/CAS/Program not in the Toolbox/User section? I think that is not too clearly arranged, but in an other post Tim pointed out that they chose that until they find a perfect solution for the filesystem.

I am not sure if you knew because of
Quote: "EXPORT XXX()" command which would allow me not to write "tvf()" manually (which is a pain in the ass).

Thanks for your responses. By the way, I'm having trouble trying to add this:

LOCAL ans:= CAS.limit(H*Xi*x,"x",0);

I dunno why it doesn't work the way I want to... :C
It won't compile... and changing it to "x" will return a "Bad Argument Value"

From the link you people provided, I could make this one work just fine:

Code:
EXPORT TVF(H,Xi)
BEGIN
  LOCAL cmd:= "limit(" +H*Xi+ "*x,x,0)";
  CAS(cmd)
END;

But I find that kind of coding messy and ugly :/


RE: New to programming - Han - 06-11-2015 03:07 AM

(06-11-2015 02:19 AM)Clod Wrote:  
(06-10-2015 06:32 AM)Didier Lachieze Wrote:  The CAS programs are not visible as other programs in the Toolbox > User menu but they are listed in the Vars > CAS menu, so you can access them without having to spell them on the keyboard.

On this topic, there is a great article from Han in the Article Forum section: HP Prime CAS Programming.

(06-10-2015 06:33 AM)Angus Wrote:  Did you know that if you write a cas program it is listed under Vars/CAS/Program not in the Toolbox/User section? I think that is not too clearly arranged, but in an other post Tim pointed out that they chose that until they find a perfect solution for the filesystem.

I am not sure if you knew because of

Thanks for your responses. By the way, I'm having trouble trying to add this:

LOCAL ans:= CAS.limit(H*Xi*x,"x",0);

I dunno why it doesn't work the way I want to... :C
It won't compile... and changing it to "x" will return a "Bad Argument Value"

From the link you people provided, I could make this one work just fine:

Code:
EXPORT TVF(H,Xi)
BEGIN
  LOCAL cmd:= "limit(" +H*Xi+ "*x,x,0)";
  CAS(cmd)
END;

But I find that kind of coding messy and ugly :/

I don't have my Prime in front of me and I don't have the emulator on this machine, either. That said, does:

CAS.limit("H*Xi*x","x",0);

work?


RE: New to programming - Clod - 06-11-2015 04:20 AM

(06-11-2015 03:07 AM)Han Wrote:  
(06-11-2015 02:19 AM)Clod Wrote:  Thanks for your responses. By the way, I'm having trouble trying to add this:

LOCAL ans:= CAS.limit(H*Xi*x,"x",0);

I dunno why it doesn't work the way I want to... :C
It won't compile... and changing it to "x" will return a "Bad Argument Value"

From the link you people provided, I could make this one work just fine:

Code:
EXPORT TVF(H,Xi)
BEGIN
  LOCAL cmd:= "limit(" +H*Xi+ "*x,x,0)";
  CAS(cmd)
END;

But I find that kind of coding messy and ugly :/

I don't have my Prime in front of me and I don't have the emulator on this machine, either. That said, does:

CAS.limit("H*Xi*x","x",0);

work?

Nope, it returns 0, no matter what the inputs are :C