Why the right(); command returns both sides of an expression? (SOLVED!) - 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: Why the right(); command returns both sides of an expression? (SOLVED!) (/thread-3523.html) |
Why the right(); command returns both sides of an expression? (SOLVED!) - Spybot - 04-01-2015 03:45 AM Hi Guys! I have this code: EXPORT TEST() BEGIN LOCAL M,BY,S,y,x; INPUT(M,"Title","Label:"); BY:=CAS.y=M*CAS.x; S:=CAS.right(BY); MSGBOX(S); END; I'm trying to extract the right side of this expression (y=3x), using the right(); command, let's say I set M=3 ... then I expect to get: 3*x(no list format), but what I get is a list containing both sides of the equation. {y, 3*x} Any Idea? Spybot, RE: Why the right(); command returns both sides of an expression? - Spybot - 04-01-2015 04:05 PM I've been using the right(); command in CAS view and it works correctly, but within a program it starts to misbehave (see screenshots). [attachment=1849] [attachment=1850] I hope someone has an idea, why this command is behaving this way. Thank you. RE: Why the right(); command returns both sides of an expression? - DrD - 04-01-2015 05:29 PM The program is a HOME view construct, and right(BY) is following the rules as described in the help file for this verb. If your program was a CAS construct, your results would perform as they do at the CAS command line. Its the difference between HOME and CAS programs that create the results you see. RE: Why the right(); command returns both sides of an expression? - Spybot - 04-01-2015 07:22 PM Hi DrD! Is this what you mean? #cas test():= BEGIN LOCAL M,BY,S,y,x; INPUT(M,"TITLE","LABEL:"); BY:=CAS.y=M*CAS.x; S:=CAS.right(BY); MSGBOX(S); return 0; END; #end Well it doesn't even execute. I went to CAS view and created this piece of code and I also checked the CAS option. Why there's no much help about this command? RE: Why the right(); command returns both sides of an expression? - Spybot - 04-13-2015 04:49 PM Hi Guys!!! OK this is the way I found to solve my issue with the right(); command, from inside of a program, this command returns a list with both sides of the equation, all I did (after a long headache!) was taking the elements "Out of the list" that's it ... Done!. Thanks to you Guys, I've been learning a lot about the Prime. here's the code... as simple as this: EXPORT TEST() BEGIN LOCAL M,B,BY; INPUT({{M,[0]},{B,[0]}},"Title","m:","b:","Help"); BY:="y="+M+"*x+"+B+""; BY:=CAS(BY); BY:=CAS.right(BY); PRINT(); PRINT(" Eqn. input by User: "+exact(CAS("y="+M+"*x+"+B+""))+" left side of the equation: "+BY(1)+" //here is the trick. right side of the equation: "+BY(2)+" //here is the trick. Thanks for Watching!"); END; [attachment=1880] Spybot. |