In ZIPP 0.6, the unit conversions are moved to a standalone program (Z UNITS), callable from ZIPP. Compiled using Android emulator 1.0.9.
Code:
#pragma mode( separator(.,;) integer(h32) )
LOCAL ZIPPST:="ZIPP V 0.6 ";
LOCAL SG:=" StephenG1CMZ";
LOCAL CRID:=ZIPPST+"© 2015 "+SG;
LOCAL NL:=CHAR(10);
LOCAL DEFLT_LANG();
LOCAL SL:=DEFLT_LANG();
//IMPORT Z_LIGHTS();
//IMPORT Z_UNITS();
EXPORT ZIPPROUND;//USER ROUNDING
LOCAL THSPD_M;
LOCAL MEAS_INTERVAL_S;
LOCAL TOMI:=1.60344;//MILES UK
LOCAL TONM:=1.852;//NAUTI
//SI PREFIXES:UNUSED
LOCAL YOTTA:=1ᴇ24;
LOCAL ZETTA:=1ᴇ21;
LOCAL EXA :=1ᴇ18;
LOCAL PETA :=1ᴇ15;
LOCAL TERA :=1ᴇ12;
LOCAL GIGA :=1ᴇ9;
LOCAL MEGA :=1ᴇ6;
LOCAL KILO :=1ᴇ3;
LOCAL HECTO:=1ᴇ2;
LOCAL DECA :=1ᴇ1;
LOCAL DECI :=1ᴇ−1;
LOCAL CENTI:=1ᴇ−2;
LOCAL MILLI:=1ᴇ−3;
LOCAL MICRO:=1ᴇ−6;
LOCAL NANO :=1ᴇ−9;
LOCAL PICO :=1ᴇ−12;
LOCAL FEMTO:=1ᴇ−15;
LOCAL ATTO :=1ᴇ−18;
LOCAL ZEPTO:=1ᴇ−21;
LOCAL YOCTO:=1ᴇ−24;
//UNITS
LOCAL NMST:={" Nautical Miles",""," Miles Nautique"};
LOCAL TKINDL:={"Celcius (Centigrade)","Fahrenheit","kelvin"};
LOCAL WSYS:={"System","","Système"};
LOCAL LANGS:={"English","","Français"};
LOCAL EN:=1; LOCAL FR:=3;
//e233
//WORDS
LOCAL WENTERZ:={"Enter","","Entrez"};
LOCAL WHELP:={"Help","","Aide"};
LOCAL WINTERVAL:={"Interval","","Intervalle"};
LOCAL WLIGHTS:={"Lights","","Lumières","Światła"};
LOCAL WTIME:={"Time","","Temps"};
LOCAL WUNITS:={"Units","","Unités"};
LOCAL WTEMPE:={"Temperature","","Température"};
LOCAL WVALU:={"Value","","La valeur"};
LOCAL CHOICES:={{"ABOUT/"+WHELP(EN),WLIGHTS(EN),"Measure Interval s","Thunder Distance",WUNITS(EN),LANGS,"EXIT"},
{},
{"A PROPOS/"+WHELP(FR),WLIGHTS(FR),"Intervalle de Mesure s","Distance de Tonnere",WUNITS(FR),LANGS,"QUITTER"}};//FR:P
EXPORT ABOUT ()
BEGIN
LOCAL ST:="StephenG1CMZ is a programmer and can work to your requirements."+NL;
LOCAL SZ:="ZIPP provides useful practical results.
Ask, if you need technical results."+NL;
LOCAL THANX:="Thanks Primer."+NL;
LOCAL LGL:="No liability is accepted.";
PRINT(); PRINT(CRID);
PRINT(ST+NL+SZ);
PRINT(THANX);
PRINT(LGL);
WAIT;
END;
TEMP_F2C (FF)
BEGIN
RETURN (FF-32)*5/9;
END;
TEMP_K2C(KK)
BEGIN
RETURN KK-273.15;
END;
MSNK()
BEGIN
LOCAL SNK:=MOUSE();
END;
INPUT_INTERVAL_H(TTL)
BEGIN
LOCAL HH,MM,SS,OK;
LOCAL LBL:={WINTERVAL(SL)+" HH",WINTERVAL(SL)+" MM",WINTERVAL(SL)+" SS"};
LOCAL HLP1:={"Decimals & Fractions allowed","",
"Décimaux et fractions autorisés"};//FR:P
LOCAL HLP:={HLP1(SL),HLP1(SL),HLP1(SL)};
OK:=INPUT({HH,MM,SS},TTL,LBL,HLP,0,0);
IF OK THEN
RETURN HH+(MM/60)+(SS/3600);
ELSE
RETURN 0; //CANCEL
//HOW TO SIGNAL CANCEL?
END;
END;
EXPORT MEASURE_INTERVAL_S()
BEGIN
LOCAL TICKB,TICKE,TICKL;
LOCAL TS,KK;
LOCAL MI:=0;
LOCAL MST:={"MEASURE SHORT INTERVAL"+NL,"",
"MESURE COURT INTERVALLE"+NL};
LOCAL MST1:={"OK or Enter: Start"+NL,"",
"OK ou Entrer: Commencez"+NL};
LOCAL MST2:={"Enter:Enter HMS numerically"+NL,"",
"Entrer: Entrez HMS numeriquement"+NL};
LOCAL MST3:={"ANY KEY: End"+NL,"",
"N importe quelle clé: Terminer"+NL};
//LOCAL CNW:="CONNECTIVITY:NO HP DATA";
TICKB:=MSGBOX(MST(SL)+MST1(SL)+MST2(SL)+MST3(SL),1);
IF TICKB THEN
RECT();
TICKB:=Ticks; TS:=Time;
TICKL:=TICKB;
REPEAT
MSNK;
IF Ticks-TICKL≥1000 THEN
TICKL:=Ticks;
RECT();
TEXTOUT_P(→HMS(ROUND((Ticks-TICKB)/1000,0)/3600),0,20);
MSNK;
TEXTOUT_P(TS+MST(SL),0,180);
TEXTOUT_P(MST2(SL),0,200);
TEXTOUT_P(MST3(SL),0,220);
END;
WAIT(0.001);
MSNK;
KK:=GETKEY;
UNTIL KK≥0;
TICKE:=Ticks;
MI:=(TICKE-TICKB)/1000;
IF KK==30 THEN //ENTER
MI:=3600*INPUT_INTERVAL_H(WENTERZ(SL)+" "+WINTERVAL(SL));
//IDEALLY IF A CANCEL IS DETECTED
//OUGHT TO RESUME MEASURED TIMING
END;
END;
MEAS_INTERVAL_S:=MI;
RETURN ROUND(MI,ZIPPROUND);
END;
THUNDER_DISTANCE_CALC_M(INTERVAL_S,TEMP_C)
//INTERVAL
//CELCIUS (NORMAL RANGE)
BEGIN
LOCAL DISTM;
THSPD_M:=331.4+0.6*TEMP_C;//M/S
DISTM:=INTERVAL_S*THSPD_M;
RETURN ROUND(DISTM,ZIPPROUND);
END;
EXPORT THUNDER_DISTANCE()
BEGIN
LOCAL OK;
LOCAL THDST:={};
LOCAL THDM,THDKM,THDMI,THDNM;
LOCAL INTERVAL_S,TEMP_C,TEMP;
LOCAL TKIND;
LOCAL TTL:=CHOICES(SL,4)+SG;
LOCAL LBL:={WINTERVAL(SL)+" s",WUNITS(SL),WTEMPE(SL)};
LOCAL HLP:={{"Interval sound-light. (0:use measured value)","","EG Temp C 0..20:Ground −57: Aircraft"},{},
{"Intervalle son-lumière. 0:La valeur mesurée","","ex Temp C 0..20:Terre −57:Avion"}};//FR:P
OK:=INPUT({INTERVAL_S,{TKIND,TKINDL},TEMP},TTL,LBL,HLP(SL),MEAS_INTERVAL_S,0);
IF OK THEN
CASE
IF TKIND==1 THEN TEMP_C:=TEMP END;
IF TKIND==2 THEN TEMP_C:=TEMP_F2C(TEMP) END;
IF TKIND==3 THEN TEMP_C:=TEMP_K2C(TEMP) END;
DEFAULT
END;
IF INTERVAL_S≤0 THEN //IMPORT VALUE
INTERVAL_S:=MEAS_INTERVAL_S;
END;
THDM:=THUNDER_DISTANCE_CALC_M(INTERVAL_S,TEMP_C);
THDKM:=THDM/1000;
THDMI:=THDKM/TOMI;
THDNM:=THDKM/TONM;
THDST(1):=ROUND(INTERVAL_S,0)+" s"+" @ "+ROUND(THSPD_M,ZIPPROUND)+" m/s"+NL;
THDST(2):=THDM+" m "+ROUND(THDKM,ZIPPROUND)+" km"+NL;
THDST(3):=ROUND(THDMI,ZIPPROUND)+" milesUK"+NL;
THDST(4):=ROUND(THDNM,ZIPPROUND)+NMST(SL);
MSGBOX(THDST(1)+THDST(2)+THDST(3)+THDST(4));
RETURN THDST(2);
END;
END;
ZIPP_HELP ()
BEGIN
LOCAL CHS,OK;
LOCAL HLPCHO:={"VARIABLES"};
LOCAL HC:=CONCAT(CHOICES(SL),HLPCHO);
LOCAL ST:={"
To change the number of digits displayed:","","
Pour changez la précision affichée:"};//FR:P
LOCAL STEG:="
@Home:
ZIPPROUND:=n [n=−12..12]"+NL;
LOCAL MAYBIS:={" may be installed separately","",
" peut être installé séparément"};
LOCAL TRBY:="Traduit par "+SG+" et ......";
REPEAT
PRINT(); PRINT(CRID);
OK:=CHOOSE(CHS,WHELP(SL),HC);
IF CHS THEN
PRINT(HC(CHS));
CASE
IF CHS==1 THEN ABOUT() END;
IF CHS==2 OR CHS==5 THEN PRINT(MAYBIS(SL)) END;
IF CHS==6 THEN PRINT(TRBY) END;
IF CHS==8 THEN PRINT(ST(SL)+STEG) END;
DEFAULT
END;
WAIT;
END;
UNTIL CHS==0;
END;
DEFLT_LANG()
BEGIN
LOCAL DEF:=1;//PROG DEFAULT
IF Language==1 OR Language==3 THEN
DEF:=Language;
END;
RETURN DEF;
END;
SELECT_LANGUAGE()
BEGIN
LOCAL CHS;
//LOCAL DEF:=1;//PROG DEFAULT IF LANG UNKNOWN
CHOOSE(CHS,LANGS(SL),CONCAT(LANGS,{WSYS(SL)}));//CURRENT
IF CHS AND CHS≠2 THEN
SL:=CHS;
IF CHS==4 THEN SL:=DEFLT_LANG(); END;
END;
END;
EXPORT G1CMZ_IMMENSELY_PRACTICAL_PACKAGE ()
BEGIN
LOCAL CHS;
SL:=DEFLT_LANG();
REPEAT
CHOOSE(CHS,CRID,CHOICES(SL));
CASE
IF CHS==1 THEN ZIPP_HELP() END;
IF CHS==2 THEN Z_LIGHTS() END;
IF CHS==3 THEN MSGBOX(MEASURE_INTERVAL_S()+" s",1) END;
IF CHS==4 THEN THUNDER_DISTANCE() END;
IF CHS==5 THEN Z_UNITS() END;
IF CHS==7 THEN CHS:=0 END;
IF CHS==6 THEN SELECT_LANGUAGE() END;
DEFAULT
END;
UNTIL CHS==0;
END;
EXPORT ZIPP()
BEGIN
G1CMZ_IMMENSELY_PRACTICAL_PACKAGE();
END;