Midrange News for the IBM i Community

Posted by: Tim Brinker
Variable Expression
has no ratings.
Published: 10 May 2012
Revised: 23 Jan 2013 - 2246 days ago
Last viewed on: 18 Mar 2019 (4182 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Variable Expression Published by: Tim Brinker on 10 May 2012 view comments(5)

Is it possible to have a variable expression in RPG?


For example I can do the following:


          Result = %Dec(5+2*2: 10: 3);


I want to do the following:


          Equation = '5+2*2';
          Result = %Dec(%Trim(Equation): 10: 3);       


This fails with the following error "A character representation of a numeric value is in error (C G D F)."  The string is being converted to a numeric value instead of being solved.


Any ideas on how to accomplish this?




Return to midrangenews.com home page.
Sort Ascend | Descend