HP Forums
local variable depending on another - 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: local variable depending on another (/thread-9267.html)



local variable depending on another - Ziz - 10-09-2017 06:00 PM

Hello,

How i can program a local variable that depend of another local variable and then discovery the value of on variable like function of another?
Basically this is my code:
///////////////////////////////////////////////////////////////////////////////////
LOCAL coef_A3,pol_3,pv_sat3,pp_vap2,Trosee;
LOCAL expressao2, conv_temp, pp_vap1;
conv_temp:=273;
pp_vap1:=101;

coef_A3=1-(Trosee+conv_temp)/647.096);

pol_3=-7.85951783*coef_A3+1.84408259*(coef_A3^1.5)-11.7866497*(coef_A3^3)+22.6807411*(coef_A3^3.5)-15.9618719*(coef_A3^4)+1.80122502*(coef_A3^7.5);

pv_sat2=(647.096/(Trosee+conv_temp))*pol_3)*22.064*10^6;

pp_vap2:=pp_vap1;

expr2=pv_sat2-pp_vap2;

CAS(solve(expr2=0,Trosee));
PRINT ("T de rosée2="+Trosee+"ºC");
///////////////////////////////////////////////////////////////////
Where coef_A3, pol_3, pv_sat2 are functions of Trosee that is unknown.

Thanks!


RE: local variable depending on another - webmasterpdx - 10-10-2017 12:46 AM

Your question isn't clear enough?
If what you are asking is how to resolve a dependency of one variable on another, I'd suggest you replace the second variable with a function call, where it derives the value from the first variable. Would that work?
-Donald


RE: local variable depending on another - cyrille de brébisson - 10-10-2017 07:31 AM

Hello,

if coef_A3 and the like are functions, why are you not declaring them as functions (implementing them in your program?)

If what you are trying to do si more on the formal calculation side of things, you might want to create a CAS program, which is able to handled undefined functions/variables rather than a Home program.

Cyrille