Post Reply 
How do I use AFiles in an App?
07-14-2015, 01:56 AM
Post: #1
How do I use AFiles in an App?
The following code works if you paste it into a copy of the Function App
Here's the App:
Code:

//Variables... 
t;rh;
hi;hi2;tmp;

// Subroutine...
HeatIndex();

EXPORT HeatIndex1()
BEGIN
END;

VIEW "Start HeatIndex",START()

BEGIN
t:=AVars("t");rh:=AVars("rh");
STARTVIEW(-1,1);

WHILE GETKEY<>4 DO
    REPEAT
tmp:=INPUT({{t,[0],{60,20,1}},
       {rh,[0],{60,20,2}},
       {hi,[0],{60,20,4}},
       {hi2,[0],{60,20,5}}
},

       "Heat Index Input and Output",

       {"Temperature, Deg F  : ",
         "Relative Humidity, %  : ",
        "Heat Index, Deg F  :",
        "Heat Index, Deg F  :"
},

       {" Air Temperature (80 to 104 °F)",
        " Relative Humidity (40 to 100 %)",
        " Heat Index from www.weatherimages.org",
        " Heat Index from www.4wx.com"
},

       {t,rh,hi,hi2},
       {t,rh,hi,hi2});

AVars("t"):=t;AVars("rh"):=rh;

    IF tmp==0 THEN
    STARTVIEW(-4,1);
    MSGBOX("End of Program");
    RETURN;
    END;

    UNTIL t>=80. AND t<=104. AND rh>=40. AND rh<=100.; 

HeatIndex();

END; // While

STARTVIEW(-4,1);
MSGBOX("End of Program");
END;

HeatIndex()
BEGIN
// This is the 16 element equation used to convert
// dry bulb temperature (T) and relative humidity (RH)
// into the Heat Index. This equation works at
// dry bulb temperatures of 70°F and higher.
// The symbol  "^"   means  "raised to the power of".
//  Source: http://www.weatherimages.org/data/heatindex.html

//  Where:
//  hi = Heat Index
//  t = Temperature (° F)
//  rh = Relative Humidity (%)

tmp:=16.923;
tmp:=tmp+1.85212*10^(-1)*t;
tmp:=tmp+5.37941*rh;
tmp:=tmp-1.00254*10^(-1)*t*rh;
tmp:=tmp+9.41695*10^(-3)*t^2;
tmp:=tmp+7.28898*10^(-3)*rh^2;
tmp:=tmp+3.45372*10^(-4)*t^2*rh;
tmp:=tmp-8.14971*10^(-4)*t*rh^2;
tmp:=tmp+1.02102*10^(-5)*t^2*rh^2;
tmp:=tmp-3.8646*10^(-5)*t^3;
tmp:=tmp+2.91583*10^(-5)*rh^3;
tmp:=tmp+1.42721*10^(-6)*t^3*rh;
tmp:=tmp+1.97483*10^(-7)*t*rh^3;
tmp:=tmp-2.18429*10^(-8)*t^3*rh^2;
tmp:=tmp+8.43296*10^(-10)*t^2*rh^3;
hi:=tmp-4.81975*10^(-11)*t^3*rh^3;
hi:=ROUND(hi,0);

//  Source: http://www.4wx.com/wxcalc/formulas/heatIndex.php
tmp:=-42.379;
tmp:=tmp+2.04901523*t;
tmp:=tmp+10.14333127*rh;
tmp:=tmp-.22475541*t*rh;
tmp:=tmp-6.83783*10^(-3)*t^2;
tmp:=tmp-5.481717*10^(-2)*rh^2;
tmp:=tmp+1.22874*10^(-3)*t^2*rh;
tmp:=tmp+8.5282*10^(-4)*t*rh^2;
hi2:=tmp-1.99*10^(-6)*t^2*rh^2;
hi2:=ROUND(hi2,0);
END;
I want to take the subroutine HeatIndex(), and move it to the AFiles folder of this app. For me, the explanation in the AFiles help section of the emulator is inadequate. I need help in how to structure the code in order to run this App with the subroutine HeatIndex() in the AFiles folder. Thanks for any help you can provide.
rcf
Find all posts by this user
Quote this message in a reply
07-14-2015, 03:22 AM
Post: #2
RE: How do I use AFiles in an App?
What exactly do you want to do? each app has its own "script" place, the "Afiles" is (I believe) for external resources (in this moment probably text or images), not for script objects, like 'libraries'

My website: ried.cl
Visit this user's website Find all posts by this user
Quote this message in a reply
07-14-2015, 04:34 AM
Post: #3
RE: How do I use AFiles in an App?
Hello,

Application files are for data, not programs.

You can store 2 type of things in files using AFiles:Math "Objects" (anything that you can place in a variable) using AFiles("name"):= var (or directly object), and graphics (storing G0-G9).

You can not store a program in a file, sorry. At this point in time, your program still has to be one single unit of source code.

Cyrille
Find all posts by this user
Quote this message in a reply
07-14-2015, 09:39 PM
Post: #4
RE: How do I use AFiles in an App?
Thanks very much for your answers. I now have the answer to my question.
rcf
Find all posts by this user
Quote this message in a reply
Post Reply 




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