CONVERT and variables for arguments
10-18-2015, 01:19 AM
Post: #11
 Han Senior Member Posts: 1,882 Joined: Dec 2013
RE: CONVERT and variables for arguments
(10-17-2015 10:03 PM)epp Wrote:  Added the list for the menu, called expr instead of CAS (is CAS a better alternative here?), and simplified by removing "simplify".

Code:
 EXPORT CD2,CD1; EXPORT Distance() BEGIN   LOCAL x,menu,unit,a1,a2,t;   INPUT({{ x,[2],{45,20,3} }},"","Convert ");   IF string(x,1) == "0" THEN RETURN; END;   unit := { 1_mm, 1_cm, 1_m, 1_km, 1_inch, 1_ft, 1_yd, 1_mile };   menu := { "mm","cm","m","km","inches","feet","yards","miles" };   CHOOSE(CD2, "Units", menu);   CHOOSE(CD1, "To", menu);   a2 := unit[CD2];   a1 := unit[CD1];   t := x + "*" + CONVERT(a2,a1);   expr(t); END;

You don't want to use EXPR() -- you want CAS() because it will allow for undefined variables in addition to defined variables and numerical values for x. EXPR() expects everything to be resolvable and will return an error if there is a reference that cannot be resolved. On the other hand, if you know that you will never want to create something like t_m where t is an undefined variable, then stick with EXPR().

Graph 3D | QPI | SolveSys
 « Next Oldest | Next Newest »

 Messages In This Thread CONVERT and variables for arguments - epp - 10-15-2015, 06:16 PM RE: CONVERT and variables for arguments - eried - 10-15-2015, 07:05 PM RE: CONVERT and variables for arguments - Han - 10-15-2015, 07:08 PM RE: CONVERT and variables for arguments - epp - 10-15-2015, 07:46 PM RE: CONVERT and variables for arguments - StephenG1CMZ - 10-15-2015, 09:25 PM RE: CONVERT and variables for arguments - Han - 10-15-2015, 09:31 PM RE: CONVERT and variables for arguments - epp - 10-16-2015, 01:14 PM RE: CONVERT and variables for arguments - eried - 10-17-2015, 01:40 PM RE: CONVERT and variables for arguments - epp - 10-17-2015, 02:13 PM RE: CONVERT and variables for arguments - StephenG1CMZ - 10-19-2015, 01:18 PM RE: CONVERT and variables for arguments - epp - 10-17-2015, 10:03 PM RE: CONVERT and variables for arguments - Han - 10-18-2015 01:19 AM RE: CONVERT and variables for arguments - epp - 10-18-2015, 05:52 AM RE: CONVERT and variables for arguments - StephenG1CMZ - 10-21-2015, 09:26 AM RE: CONVERT and variables for arguments - epp - 10-21-2015, 10:14 AM RE: CONVERT and variables for arguments - StephenG1CMZ - 10-21-2015, 11:26 AM RE: CONVERT and variables for arguments - epp - 10-21-2015, 01:14 PM RE: CONVERT and variables for arguments - StephenG1CMZ - 10-21-2015, 01:23 PM RE: CONVERT and variables for arguments - epp - 10-21-2015, 03:06 PM RE: CONVERT and variables for arguments - StephenG1CMZ - 10-21-2015, 03:50 PM RE: CONVERT and variables for arguments - StephenG1CMZ - 10-21-2015, 06:59 PM Conversions Implemented as a Function - epp - 10-22-2015, 11:35 AM RE: CONVERT and variables for arguments - StephenG1CMZ - 10-22-2015, 11:12 PM RE: CONVERT and variables for arguments - epp - 10-24-2015, 09:35 PM RE: CONVERT and variables for arguments - StephenG1CMZ - 10-30-2015, 08:26 AM

User(s) browsing this thread: