It is beginning to work. Not all units proposed have been integrated.
Attached the program... but I doubt it will pass to the mailing list... so copying it in the message: /* Copyright 2024 Paul Dufresne (dufres...@zoho.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* This program is written in REXX... see https://rexxinfo.org/reference/index_reference.html for more information about this programming language. */ /* This program allows you to convert from one unit of measure to an other one. */ /* This program when named unitconv.rex can be executed with: regina unitconv.rex or rexx unticonv.rex */ /* I don't know if it was a good idea to remove the fromUnit of the toUnits menu, because that make units to number menu change between the 2 menus... changed! */ useAvoid=0 /* if 1, the fromUnit will not be in toUnit menu... which change menu numbers... bad */ Say 'Welcome to ConvREXXter v.0.5' Say call askConvertions Say 'Thank you for using my program!' Say Say 'If your plane crashed because your pilot used my program,' Say 'please send me the details...' Say 'so that I can eventually fix it in a future version.' Say Say 'Seriously, send your comments/bugs messages to dufres...@zoho.com' exit 0 askConvertions: procedure expose useAvoid finished = 0 do until finished call makeTopMenu say 'What kind of measurements you want to convert?' call showMenu select when RESULT='SPEED' then do call makeSpeedMenu,'' call showMenu fromUnit=RESULT if useAvoid then call makeSpeedMenu fromUnit else call makeSpeedMenu call showMenu toUnit=RESULT call doSomeConvertions fromUnit,toUnit,'SPEED' end when RESULT='DISTANCE' then do call makeDistanceMenu,'' call showMenu fromUnit=RESULT if useAvoid then call makeDistanceMenu fromUnit else call makeDistanceMenu call showMenu toUnit=RESULT call doSomeConvertions fromUnit,toUnit,'DISTANCE' end when RESULT='AREA' then do call makeAreaMenu,'' call showMenu fromUnit=RESULT if useAvoid then call makeAreaMenu fromUnit else call makeAreaMenu call showMenu toUnit=RESULT call doSomeConvertions fromUnit,toUnit,'AREA' end when RESULT='VOLUME' then do call makeVolumeMenu,'' call showMenu fromUnit=RESULT if useAvoid then call makeVolumeMenu fromUnit else call makevolumeMenu call showMenu toUnit=RESULT call doSomeConvertions fromUnit,toUnit,'VOLUME' end when RESULT='WEIGHT' then do call makeWeightMenu,'' call showMenu fromUnit=RESULT if useAvoid then call makeWeightMenu fromUnit else call makeWeightMenu call showMenu toUnit=RESULT call doSomeConvertions fromUnit,toUnit,'WEIGHT' end when RESULT='TEMPERATURE' then do call makeTemperatureMenu,'' call showMenu fromUnit=RESULT if useAvoid then call makeTemperatureMenu fromUnit else call makeTemperatureMenu call showMenu toUnit=RESULT call doSomeConvertions fromUnit,toUnit,'TEMPERATURE' end when RESULT='POWER' then do call makePowerMenu,'' call showMenu fromUnit=RESULT if useAvoid then call makePowerMenu fromUnit else call makePowerMenu call showMenu toUnit=RESULT call doSomeConvertions fromUnit,toUnit,'POWER' end otherwise say 'Unknown choice!' end Say 'Do others conversions?' pull answer if answer=='N' | answer=='NO' then finished=1 end return makeTopMenu: procedure queue 'SPEED' queue 'DISTANCE' queue 'AREA' queue 'VOLUME' queue 'WEIGHT' queue 'TEMPERATURE' queue 'POWER' return queueIf: procedure parse arg element,avoid if element <> avoid then queue element return showMenu: procedure drop menu. number = queued() Do i=1 to number PULL element call fancy element SAY i'. 'RESULT menu.i=element END pull answer return menu.answer makeSpeedMenu: procedure parse arg avoid call queueIf 'MPH',avoid call queueIf 'KMH',avoid call queueIf 'MPS',avoid call queueIf 'KN',avoid return makeDistanceMenu: procedure parse arg avoid call queueIf 'MILIMETER',avoid call queueIf 'CENTIMETER',avoid call queueIf 'METER',avoid call queueIf 'KM',avoid call queueIf 'YARD',avoid call queueIf 'FOOT',avoid call queueIf 'INCH',avoid call queueIf 'MILE',avoid return makeAreaMenu: procedure parse arg avoid call queueIf 'M2',avoid call queueIf 'KM2',avoid call queueIf 'CM2',avoid call queueIf 'MM2',avoid call queueIf 'MI2',avoid call queueIf 'YD2',avoid call queueIf 'FT2',avoid call queueIf 'IN2',avoid call queueIf 'HA',avoid return makeVolumeMenu: procedure parse arg avoid call queueIf 'CUBEMETER',avoid call queueIf 'CENTILITER',avoid call queueIf 'LITER',avoid call queueIf 'DECILITER',avoid call queueIF 'MILIMETER',avoid call queueIF 'GAL',avoid call queueIF 'PT',avoid call queueIF 'FLOZ',avoid return makeWeightMenu: procedure parse arg avoid call queueIf 'GRAM',avoid call queueIf 'KG',avoid call queueIf 'LB',avoid call queueIf 'OZ',avoid return makeTemperatureMenu: procedure parse arg avoid call queueIf 'C',avoid call queueIf 'F',avoid call queueIf 'K',avoid return makePowerMenu: procedure parse arg avoid call queueIf 'W',avoid call queueIf 'hp',avoid return doSomeConvertions: procedure parse arg fromUnits,toUnits,typeConv finished=0 do until finished call fancy fromUnits fancyFromUnits=RESULT call fancy toUnits fancyToUnits=RESULT say 'Convert how many 'fancyFromUnits'?' pull amount call convert amount,fromUnits,toUnits,typeConv say 'it is equivalent to 'RESULT' 'fancyToUnits'.' say 'Do more of that kind of conversions?' pull yesNo if yesNo == 'N' | yesNo == 'NO' | yesNo='Q' | yesNo='QUIT' | yesNO='STOP' then finished=1 end return convert: procedure parse arg amount,fromUnits,toUnits,typeconv /*say 'amount='amount' fromUnits='fromUnits' toUnits='toUnits' typeconv='typeconv */ select when typeConv=='SPEED' then do interpret 'CALL 'fromUnits'2'KMH amount interpret 'CALL KMH2'toUnits RESULT return RESULT end when typeConv=='DISTANCE' then do interpret 'CALL 'fromUnits'2'METER amount interpret 'CALL 'METER'2'toUnits RESULT return RESULT end when typeConv=='AREA' then do interpret 'CALL 'fromUnits'2'M2 amount interpret 'CALL 'M2'2'toUnits RESULT return RESULT end when typeConv=='VOLUME' then do interpret 'CALL 'fromUnits'2'LITER amount interpret 'CALL 'LITER'2'toUnits RESULT RETURN RESULT end when typeConv=='WEIGHT' then do interpret 'CALL 'fromUnits'2'KG amount interpret 'CALL 'KG'2'toUnits RESULT return RESULT end when typeConv=='POWER' then do interpret 'CALL 'fromUnits'2'W amount interpret 'CALL 'W'2'toUnits RESULT return rESULT end when typeConv=='TEMPERATURE' then do interpret 'CALL 'fromUnits'2'C amount interpret 'CALL 'C'2'toUnits RESULT return RESULT end otherwise say typeConv' is an unknown type of conversion!' end return fancy: procedure parse arg rawUnit select when rawUnit=='MPH' then return 'miles per hour' when rawUnit=='KMH' then return 'kilometers per hour' when rawUnit=='MPS' then return 'meters per hour' when rawUnit=='KN' then return 'knots' /*---*/ when rawUnit=='MILIMETER' then return 'milimeters' when rawUnit=='CENTIMETER' then return 'centimeters' when rawUnit=='METER' then return 'meters' when rawUnit=='KM' then return 'kilometers' when rawUnit=='YARD' then return 'yards' when rawUnit=='FOOT' then return 'feets' when rawUnit=='INCH' then return 'inches' when rawUnit=='MILE' then return 'miles' /*---*/ when rawUnit=='M2' then return 'square meters' when rawUnit=='KM2'then return 'square kilometers' when rawUnit=='CM2' then return 'square centimeters' when rawUnit=='MM2' then return 'square milimeters' when rawUnit=='MI2' then return 'square miles' when rawUnit=='YD2' then return 'square yards' when rawUnit=='FT2' then return 'square feets' when rawUnit=='IN2' then return 'square inches' when rawUnit=='HA' then return 'hectares' /*---*/ when rawUnit=='CUBEMETER' then return 'cube meters' when rawUnit=='CENTILITER' then return 'centiliters' when rawUnit=='DECILITER' then return 'deciliters' when rawUnit=='LITER' then return 'liters' when rawUnit=='MILILITERS' then retrun 'mililiters' when rawUnit=='GAL' then return 'gallons (imperial)' when rawUnit=='PT' then return 'pints' when rawUnit=='FLOZ' then return 'fluid ounces' /*---*/ when rawUnit=='GRAM' then return 'grams' when rawUnit=='KG' then return 'kilograms' when rawUnit=='OZ' then return 'ounces' when rawUnit=='LB' then return 'pounds' /*---*/ when rawUnit=='C' then return 'celsius' when rawUnit=='K' then return 'kelvins' when rawUnit=='F' then return 'farenheits' /*---*/ when rawUnit=='WATT' then return 'watts' when rawUnit=='hp' then return 'horse powers' /*---*/ otherwise return rawUnit end return rawUnit /* I/we need conversions functions from any units to the standard unit, and from the standard unit to any units. */ /* For speed, standard unit is KMH */ MPH2KMH: procedure parse arg MPH return 1.60934*MPH KMH2KMH: procedure parse arg KMH return KMH MPS2KMH: procedure parse arg MPS return MPS*3600/1000 KN2KMH: procedure parse arg knots return knots*1.852 KMH2MPH: procedure parse arg KMH return KMH/1.60934 KMH2MPS: procedure parse arg KMH return KMH*1000/3600 KMH2KN: procedure parse arg KMH return KMH/1.852 /* knots */ /* for distances, standard unit is the meter */ MILIMETER2METER: procedure parse arg milimeters return milimeters/1000 CENTIMETER2METER: procecure parse arg centimeter return centimeter/100 METER2METER: procedure parse arg meter return meter KM2METER: procedure parse arg km return km*1000 YARD2METER: procedure parse arg yard return yard*0.9144 FOOT2METER: procedure parse arg foot return foot/3.28 INCH2METER: procedure parse arg inch return inch*0.0254 MILE2METER: procedure parse arg mile return mile*1609.344 METER2MILIMETER: procedure parse arg meter return meter*1000 METER2CENTIMETER: procedure parse arg meter return meter*100 METER2KM: procedure parse arg meter return meter/1000 METER2YARD: procedure parse arg meter return meter/0.9144 METER2FOOT: procedure parse arg meter return meter*3.28 METER2INCH: procedure parse arg meter return meter/0.025 /* For areas, standard unit is M2 (square meter) */ M22M2: procedure parse arg m2 return m2 KM22M2: procedure parse arg km2 return km2*1000*1000 CM22M2: procedure parse arg cm2 return cm2*0.0001 MM22M2:procedure parse arg mm2 return mm2/1000000 MI22M2:procedure parse arg mi2 return mi2*2589988.110336 YD22M2:procedure parse arg yd2 return yd2*0.8361 FT22M2:procedure parse arg ft2 return ft2*0.09290304 IN22M2:procedure parse arg in2 return in2*0.00064516 HA2M2:procedure parse arg hectare return hectare * 10000 /*---*/ M22KM2: procedure parse arg m2 return m2/(1000*1000) M22CM2: procedure parse arg m2 return m2/0.0001 M22MM2:procedure parse arg m2 return m2*1000000 M22MI2:procedure parse arg m2 return m2/2589988.110336 M22YD2:procedure parse arg m2 return m2/0.8361 M22FT2:procedure parse arg m2 return m2/0.09290304 M22IN2:procedure parse arg m2 return m2/0.00064516 M22HA:procedure parse arg m2 return m2/10000 /* For volume, I choosed liter for standard unit */ M32LITER: procedure parse arg m3 return m3*1000 CENTILITER2LITER: procedure parse arg centiliter return centiliter/100 LITER2LITER: procedure parse arg liter return liter DECILITER2LITER: procedure parse arg deciliter return deciliter/10 MILILITER2LITER: procedure parse arg mL return mL/1000 GAL2LITER: procedure parse arg gal /* american gallon */ return gal*3.785 PT2LITER: procedure parse arg pint return pint * 0.473176 FLOZ2LITER: procedure parse arg floz /* fluid ounce */ return floz * 0.029574 /****/ LITER2M3: procedure parse arg liter return liter/1000 LITER2CENTILITER: procedure parse arg liter return liter*100 LITER2DECILITER: procedure parse arg liter return liter*10 LITER2MILILITER: procedure parse arg liter return liter*1000 LITER2GAL: procedure parse arg liter return liter/3.785 LITER2PT: procedure parse arg liter return liter/0.473176 /* pints */ LITER2FLOZ: procedure parse arg liter return liter / 0.029574 /* For weight measures, KG was chosen as the standard unit by me */ GRAM2KG: procedure parse arg gram return gram / 1000 KG2KG: procedure parse arg kg return kg LB2KG: procedure parse arg lb return lb * 0.45359237 OZ2KG: procedure parse arg oz return oz * 0.028349523 /*---*/ KG2GRAM: procedure parse arg kg return kg * 1000 KG2LB: procedure parse arg kg return kg / 0.45359237 KG2OZ: procedure parse arg kg return kg / 0.028349523 /* For temperature measurements, C(elsius) was chosen as standard unit */ C2C: procedure parse arg celsius return celsius F2C: procedure parse arg farenheit return (farenheit - 32)*5/9 K2C: procedure parse arg kelvin return kelvin - 273.15 /*-----------*/ C2F: procedure parse arg celsius return (9/5)* celsius + 32 C2K: procedure parse arg celsius return celsius + 273.15 /* For power measurements, I have chosen the Watt for standard unit */ W2W: procedure parse arg watt return watt HP2W: procedure parse arg hp /* horse power! */ return hp * 746 /*------*/ W2HP: procedure parse arg watt return watt / 746
ConvREXXter_v0.5.rex
Description: Binary data
_______________________________________________ Freedos-devel mailing list Freedos-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freedos-devel