All functions improved, new functionality added and translations improved.
You will need to create an empty procedure (or comment out the call). - this procedure will be uploaded as a separate program in the next few days.
(Update: Z LIGHTS is now available, so you can install this instead of creating an empty procedure)
Code:
#pragma mode( separator(.,;) integer(h32) )
LOCAL ZIPPST:="ZIPP V 0.4 ";
LOCAL SG:=" StephenG1CMZ";
LOCAL CRID:=ZIPPST+"© 2015 "+SG;
LOCAL NL:=CHAR(10);
LOCAL SL:=1;
//IMPORT Z_LIGHTS();
LOCAL CDFROM,CDTO;
EXPORT ZIPPROUND;//USER ROUNDING
LOCAL THSPD_M;
LOCAL MEAS_INTERVAL_S;
LOCAL TOMI:=1.60344;//MILES UK
LOCAL TONM:=1.852;//NAUTI
//SI PREFIXES
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 LANGS:={"English","Français"};
LOCAL EN:=1; LOCAL FR:=2;
//e233
//WORDS
LOCAL WENTERZ:={"Enter","Entrez"};
LOCAL WHELP:={"Help","Aide"};
LOCAL WINTERVAL:={"Interval","Intervalle"};
LOCAL WLIGHTS:={"Lights","Lumières"};
LOCAL WUNITS:={"Units","Unités"};
LOCAL WTEMPE:={"Temperature","Température"};
LOCAL WCNVTT:={"Convert "+WTEMPE(EN),"Convertir la "+WTEMPE(FR)};
LOCAL WCNVTU:={"Convert Units","Convertir des Unités"};
LOCAL CHOICES:={{"ABOUT/"+WHELP(EN),WCNVTU(EN),WLIGHTS(EN),"Measure Interval s","Thunder Distance",LANGS,"EXIT"},
{"A PROPOS/"+WHELP(FR),WCNVTU(FR),WLIGHTS(FR),"Intervalle de Mesure s","Distance de Tonnere",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 Han for the CONVERT syntax.
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_C2F(CC)
BEGIN
RETURN (9/5)*CC+32;
END;
TEMP_K2C(KK)
BEGIN
RETURN KK-273.15;
END;
TEMP_C2K(CC)
BEGIN
RETURN CC+273.15;
END;
CONVERT_TEMP ()
BEGIN
LOCAL OK,TKIND;
LOCAL TEMP,TEMP_C,TEMP_F,TEMP_K;
LOCAL TTL:=WCNVTT(SL);
LOCAL LBL:={WUNITS(SL),WTEMPE(SL)};
LOCAL HLP:="";
OK:=INPUT({{TKIND,TKINDL},TEMP},TTL,LBL,HLP,1,1);
IF OK THEN
CASE
IF TKIND==1 THEN //C
TEMP_C:=TEMP;
TEMP_F:=TEMP_C2F(TEMP_C);
TEMP_K:=TEMP_C2K(TEMP_C);
END;
IF TKIND==2 THEN //F
TEMP_F:=TEMP;
TEMP_C:=TEMP_F2C(TEMP_F);
TEMP_K:=TEMP_C2K(TEMP_C);
END;
IF TKIND==3 THEN //K
TEMP_K:=TEMP;
TEMP_C:=TEMP_K2C(TEMP_K);
TEMP_F:=TEMP_C2F(TEMP_C);
END;
DEFAULT
END;
END;
RETURN {TEMP_C+TKINDL(1),TEMP_F+TKINDL(2),TEMP_K+TKINDL(3)};
END;
MSNK()
BEGIN
LOCAL SNK:=MOUSE();
END;
TRIMMENU(INL)
BEGIN
LOCAL II;
LOCAL OUTL:={};
FOR II FROM 1 TO SIZE(INL) DO
OUTL(II):=REPLACE(STRING(INL(II)),"1_","");
END;
RETURN OUTL;
END;
CONVERT_UNIT_GRP(unit,tname)
BEGIN
LOCAL x,menu,a1,a2,t;
LOCAL UF;
LOCAL TTL:={"To use SI prefixes: INPUT PREFIXNAME",
"SI préfixe: Saisissez le nom du préfixe"};
LOCAL EVUST:={
": Enter value(s) in: ",
":Entrez la/les valeur(s) avec: "};//FR:P
LOCAL HLP:=tname+EVUST(SL);
LOCAL TOST:={"To ","À "};
LOCAL CNVRT:={"Convert","Convertir"};
menu:=TRIMMENU(unit);//AUTO
CHOOSE(CDFROM,WUNITS(SL)+":"+tname,menu);
IF CDFROM THEN
UF:=REPLACE(STRING(unit[CDFROM]),"1_",""); //TRIM 1_
INPUT({{ x,[2],{45,20,3} }},TTL(SL),CNVRT(SL),HLP+UF);
//DETECT ESC
IF string(x,1) == "0" THEN RETURN; END;
CHOOSE(CDTO, TOST(SL)+WUNITS(SL)+":"+tname, menu);
a2 := unit[CDFROM];
a1 := unit[CDTO];
t := x + "*" + CONVERT(a2,a1);
RETURN expr(t);
END;
END;
CONVERT_UNITS_HP()
BEGIN
LOCAL CHSTYP;
LOCAL TTL:={"Unit types","Types d'unités"};
LOCAL UTYP:={{"Length","Area","Volume",
"Time","Speed","Acceleration","Mass","Force",
"Energy","Power","Pressure","Temperature:NO!",
"Electricity","Light","Angle","Viscosity","Radiation"},
{"Longueur","Surface","Volume",
"Heure","Vitesse","Accélération","Masse","Force",
"Energie","Puissance","Pression","Température:NON!",
"Electricité","Lumière","Angle","Viscosité","Radiation"}};
//TESTING:PUISSANCE(POWER) IS LONGEST INPUT STRING
LOCAL UL:={};
CHOOSE(CHSTYP,TTL(SL),UTYP(SL));
CASE
IF CHSTYP==1 THEN //LENGTH
//CONVERT_Length();
UL:={1_m,1_cm,1_mm,1_km,1_in,1_ft,1_yd,1_mile,1_nmi,1_au,1_lyr,1_pc,1_Å};
END;
IF CHSTYP==2 THEN //AREA
UL:={1_(cm²),1_(m²),1_(km²),1_(in²),1_(ft²),1_(yd²),1_(mile²),1_(miUS²),1_acre,1_ha,1_a,1_b};//A:Are B:Barn
//CONVERT_UNIT_GRP(UL);
END;
IF CHSTYP==3 THEN //VOLUME
UL:={1_(cm^3),1_(m^3),1_ml,1_l,1_(in^3),1_(ft^3),1_(yd^3),1_ptUK,1_galUK,1_galUS};
//CONVERT_UNIT_GRP(UL);
END;
IF CHSTYP==4 THEN //TIME
UL:={1_s,1_min,1_h,1_d,1_yr,1_Hz};
END;
IF CHSTYP==5 THEN //SPEED
UL:={1_(cm/s),1_(m/s),1_kph,1_(km/h),1_(ft/s),1_mph,1_(mile/h),1_knot,1_(rad/s),1_(tr/min),1_(tr/s)};
END;
IF CHSTYP==6 THEN //ACCEL
UL:={1_(m/s²),1_(ft/s²),1_grav,1_Gal,1_(rad/s²)};
END;
IF CHSTYP==7 THEN //MASS
UL:={1_g,1_kg,1_oz,1_lb,1_tonUK,1_tonUS,1_mol,1_u,1_t};
END;
IF CHSTYP==8 THEN //FORCE
UL:={1_(kg*m/s²),1_N,1_dyn,1_lbf,1_kip,1_gf,1_pdl};
END;
IF CHSTYP==9 THEN //ENERGY
UL:={1_(kg*m²/s²),1_J,1_Wh,1_kWh,1_(ft*lbf),1_kcal,1_cal,1_eV,1_MeV,1_Btu,1_erg,1_thermUK,1_thermEC,1_thermUS};
END;
IF CHSTYP==10 THEN //POWER
UL:={1_(kg*m²/s^3),1_W,1_MW,1_hp,1_(ft*lbf/s)};
END;
IF CHSTYP==11 THEN //PRESSURE
UL:={1_(kg/(m*s²)),1_Pa,1_bar,1_atm,1_psi,1_torr,1_mmHg,1_inHg,1_inH2O};
END;
IF CHSTYP==12 THEN //TEMP
//UL:={1_K,1_°C,1_°F};
END;
IF CHSTYP==13 THEN //ELEC
UL:={1_A,1_V,1_C,1_Ohm,1_F,1_Fdy,1_Wb,1_H,1_mho,1_T,1_(A*h),1_S};
END;
IF CHSTYP==14 THEN //LIGHT:HP MISSING MOST UNITS
UL:={1_cd,1_flam};
END;
IF CHSTYP==15 THEN //ANGL
UL:={1_rad,1_deg,1_arcmin,1_arcs,1_tr};
END;
IF CHSTYP==16 THEN //VISCOSITY
UL:={1_(m²/s),1_P,1_St};
END;
IF CHSTYP==17 THEN //RADIATION
UL:={1_Bq,1_Ci,1_Gy,1_rd,1_rem,1_Sv,1_R};
END;
DEFAULT
END;
IF SIZE(UL)>0 THEN //AND CHSTYP>0
MSGBOX(CONVERT_UNIT_GRP(UL,UTYP(SL,CHSTYP)),1);
END;
END;
EXPORT CONVERT_UNITS ()
BEGIN
LOCAL CHS;
LOCAL TTL:=WCNVTU(SL)+SG;
CHOOSE(CHS,TTL,{WCNVTT(SL),WCNVTU(SL)});
IF CHS THEN
CASE
IF CHS==1 THEN MSGBOX(CONVERT_TEMP(),1); END;
IF CHS==2 THEN CONVERT_UNITS_HP() END;
DEFAULT
END;
END;
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;
RETURN MEAS_INTERVAL_S:=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,5)+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 SIPRFX:={"
Values may include SI prefixes.
ENTER IN UPPERCASE: Selecting Units/Prefix (Shift C) will not work."+NL,
"Les valeurs peuvent inclure des SI préfixes. Entrez en majuscule: Selection Unites/Préfixe (Decalage C) ne marchant pas."+NL};
LOCAL SIPRFXEG:="
3NANO _m
3MILLI _inch";
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 CVT:={"
Note that not all units within a group can be converted. Conversion between groups (eg length*length to area) is not implemented here.
SI prefixes OK.
Lists and variables OK."+NL, "
Notez que toutes les unités d un groupe ne_peuvent pas etre convertis.
SI préfixes OK.
Listes et variables OK."+NL};
LOCAL LIGHTSPROG:={"LIGHTS may be installed separately",
"Lumières peut être installé séparément"};
LOCAL TRBY:="Traduit par "+SG+" et ......";
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 THEN
PRINT(CVT(SL));WAIT;
OK:=MSGBOX(SIPRFX(SL),1);
OK:=MSGBOX(SIPRFXEG,1);
END;
IF CHS==3 THEN PRINT(LIGHTSPROG(SL)) END;
IF CHS==6 THEN PRINT(TRBY) END;
IF CHS==8 THEN PRINT(ST(SL)+STEG) END;
DEFAULT
END;
WAIT;
END;
END;
SELECT_LANGUAGE()
BEGIN
LOCAL CHS;
CHOOSE(CHS,LANGS(SL),LANGS);//CURRENT
IF CHS THEN
SL:=CHS;
END;
END;
EXPORT G1CMZ_IMMENSELY_PRACTICAL_PACKAGE ()
BEGIN
LOCAL CHS;
REPEAT
CHOOSE(CHS,CRID,CHOICES(SL));
CASE
IF CHS==1 THEN ZIPP_HELP() END;
IF CHS==2 THEN CONVERT_UNITS() END;
IF CHS==3 THEN Z_LIGHTS() END;
IF CHS==4 THEN MSGBOX(MEASURE_INTERVAL_S()+" s",1) END;
IF CHS==5 THEN THUNDER_DISTANCE() 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;