Post Reply 
CONVERT and variables for arguments
10-16-2015, 01:14 PM (This post was last modified: 10-17-2015 01:55 PM by epp.)
Post: #7
RE: CONVERT and variables for arguments
Here's the final version. I've also done Volume and Weight conversions using this as a template.
Code:

EXPORT D2,D1;
EXPORT Distance()
BEGIN
    LOCAL x,lst,a1,a2,t;
    INPUT({{ x, [2], {45,20,3} }},"","Convert ");
    IF string(x,1) == "0" THEN RETURN; END;
    CHOOSE(D2, "Units", "mm","cm","m","km","inches","feet","yards","miles");
    CHOOSE(D1, "To",    "mm","cm","m","km","inches","feet","yards","miles");
    lst := { 1_mm, 1_cm, 1_m, 1_km, 1_inch, 1_ft, 1_yd, 1_mile };
    a2 := lst[D2];
    a1 := lst[D1];
    t := "simplify(" + x + "*" + CONVERT(a2,a1) + ")";
    CAS(t);
END;
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
CONVERT and variables for arguments - epp - 10-15-2015, 06:16 PM
RE: CONVERT and variables for arguments - epp - 10-16-2015 01:14 PM



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