I don't have a blog site so here is a pictoral essay on an APP that I am creating in HPPL.
The code is bulky as I get a handle on routines, loops, branching, testing and calling but it gives an example that hopefully other beginners may find it helpful.
Fristly, I use Notepad and 'save as unicode' instead of 'ANSI' as that gives an almost directly copyable text from the PRIME to this site. Of course the connectivity kit is used for programming as well as the Prime for programming.
*********
The text below, Info and Program are NOT exactly copy and paste transferrable to your Prime using the connectivity kit. The ->HMS command must be input from your calculator as it is not recognized in notepad:
*********
INFO SECTION
Break schedules:
-calculates break periods.*Initialize:
-this menu.
-variables ending in A are HMS format.
-variables ending in B are decimal format.*Input times.
-prompts for "off and on" times.
these are the airborne and landing times.
-break "out and in" times.
these are the delay and early return
times in minutes after takeoff and
before landing.
-number of breaks.*equal breaks:
-4, 6 typically.
-E,E,E,E or E,E,E,E,E,E*weighted breaks:
-input desired long break.
-front or back.
allows the front half or rear half of the
breaks to be longer by choice.
-4 or 6 typically.
S,S,L,L or L,L,S,S or S,S,S,L,L,L or L,L,L,S,S,S*2 short followed by 3 long and short:
-places the sleep period outside the dinner
service.
-S,S,L,L,L,Swhere E=Equal, S=Short and L=Long
And now the code. Super programmers, please excuse the bulky code as I am still learning. Since I got the code to work and display I am now going to enhance the input and output displays. Also clean up the routines, branches and testing. So:
1 working code first,
2 then make it effecient,
3 then pretty.
APP SECTION CODE:
//Midnight is a routine called by this APP
MIDNIGHT();//All variables ending in A
//are hexagesimal, decimals
//end in B.//declare variables.
EXPORT IN,OUT,NUM,EQL,TIM;
EXPORT OFA,OFB,ONA,ONB;
EXPORT TOA,TOB,CAA,CAB;
EXPORT SHA,SHB,LGA,LGB;
EXPORT WTA,WTB,WTC;//title of program within app
EXPORT Break_schedules()
BEGIN
END;//menu display for prepping the calculator.
VIEW "Initialize",IT()
BEGIN
HFormat:=1;
HDigits:=4;
HAngle:=1;
STARTVIEW(6,1);
LOCAL A;
END;//input times
VIEW "Input times/# of breaks",OO()
BEGIN
INPUT(OFA,"Wheels off time","off time = ","off time");
INPUT(ONA,"Wheels on time","on time = ","on time");
INPUT(OUT,"Out time","out time = ","out time");
INPUT(IN,"In time","in time = ","in time");
INPUT(NUM,"# of breaks","# of breaks = ","# of breaks");//convert times to decimal.
OFB:=(FP(OFA)/60)*100+IP(OFA);
ONB:=(FP(ONA)/60)*100+IP(ONA);
OUT:=(FP(OUT)/60)*100+IP(OUT);
IN:=(FP(IN)/60)*100+IP(IN);//correct for landing time less then takeoff time,
//that is flight passes through midnight GMT.IF OFB>ONB
THEN ONB:=ONB+24
ELSE ONB:=ONB;
END;//calculate common variables used by each section.
ONB:=ONB-IN;
OFB:=OFB+OUT;
TOB:=ONB-OFB;
TOA:=->HMS(TOB);
EQL:=->HMS(TOB/NUM);
MSGBOX("Equal = "+EQL);
MSGBOX("Total = "+TOA);
END;//Equal break section of the the app
//accessed via "View"VIEW "EQUAL BREAK",EQ()
//loop the following by NUM to display each
//consecutive time.BEGIN
FOR N FROM 1 TO NUM DO
TIM:=->HMS(OFB+EQL);
TIM:=MIDNIGHT(TIM);
OFB:=TIM;
MSGBOX("Time = " +TIM+"");
END;
END;//end loop
//Weighted break section of the the app
//accessed via "View"VIEW "WEIGHTED BREAK",WB()
//label screen title, variable title, variable.
//ask for specific variable to this section and
//display.BEGIN
INPUT (WTA,"Weighted time","weighted time = ","weighted time");
WTB:=(FP(WTA)/60)*100+IP(WTA);
CAB:=(TOB-(NUM/2*WTB))/(NUM/2);
CAA:=->HMS(CAB);
MSGBOX("Calculated = " +CAA+"");//Choose menu for placing weighted break at
//front or back of the break periods.CHOOSE(A,"Period","Front","Back");
//test and loop for creating the period with specified
//break time based on choose menu.IF A==1
THEN WTC:=WTB
ELSE WTC:=CAB;
END;FOR N FROM 1 TO NUM/2 DO
TIM:=->HMS(OFB+WTC);
TIM:=MIDNIGHT(TIM);
OFB:=HMS->(TIM);
MSGBOX("Time = " +TIM+"")
END;//test and loop for finishing the period with remaining
//break time.IF A==2
THEN WTC:=WTB
ELSE WTC:=CAB;
END;FOR N FROM 1 TO NUM/2 DO
TIM:=->HMS(OFB+WTC);
TIM:=MIDNIGHT(TIM);
OFB:=TIM;
MSGBOX("Time = " +TIM+"");
END;
END;//long and short break section of the the app
//accessed via "View".VIEW "LONG SHORT BREAK",LS()
//label screen title, variable title, variable.
//ask for specific variable to this section and
//display.BEGIN
INPUT (LGA,"Long","long time = ","long time");
LGB:=(FP(LGA)/60)*100+IP(LGA);
SHB:=(TOB-(LGB*3))/3;
SHA:=->HMS(SHB);
MSGBOX("Short = " +SHA+"");//loop for first 2 short breaks.
FOR N FROM 1 TO 2 DO
TIM:=->HMS(OFB+SHB);
TIM:=MIDNIGHT(TIM);
OFB:=TIM;
MSGBOX("Time = " +TIM+"")
END;//loop for 3 long breaks.
FOR N FROM 1 TO 3 DO
TIM:=->HMS(OFB+LGB);
TIM:=MIDNIGHT(TIM);
OFB:=TIM;
MSGBOX("Time = " +TIM+"")
END;//final short break added to end.
TIM:=->HMS(OFB+SHB);
TIM:=MIDNIGHT(TIM);
OFB:=TIM;
MSGBOX("Time = " +TIM+"")
END;
END;
The routine MIDNIGHT converts time addition past midnight to the next day format. Example: 2200 hours plus 4 hours equals 2600 hours which is converted to 0200 hours for display
EXPORT MIDNIGHT(TIM)
BEGIN
IF TIM>24 THEN TIM:=->HMS(TIM-24)
ELSE TIM:=TIM;
END;
END;
and now a series of step by step images of the App at work:
Select the App and press View and get a menu:
select initialize and get notes:
select "input times/#number of breaks and you are prompted for input data:
The data input in hours.minutes is as follows:
off time 21.40
on time 08.30
out time .20
in time .30
# of breaks 4
Output after the last input placed (#number of breaks) calculates the entire period IF divided into equal breaks. This is handy as it gives a heads up mentally of what an long versus short break might be composed of:
Then it displays the total amount of time available for breaks:
Back to the view button and up pops a selection menu, today we highlight the Weighted section:
This section asks for a Long break time period:
and then calculates the remaining period lenghts:
and then where would you like the long periods, front two of the four or back two of the four (this example at the back):
It then calculates the times based on the intitial time to leave the flight deck, in this case the next period commences at 24:00:
The next period:
...
...
So you can see the next step after cleaning up the excess redundant code is to clean up the displays.
Hopefully I will end up with an input display such as this:
off time:and output such as this:
on time:
out time:
in time:
number of breaks:
leave at 22:00 return at 24:00
leave at 24:00 return at 02:00
leave at 02:00 return at 05:00
leave at 05:00 return at 08:00
Hope this helps someone as it is fun to document the steps, it is how I learn and memorize!
cheers, Geoff
Edited: 28 Oct 2013, 5:45 p.m.