Calcpad icon indicating copy to clipboard operation
Calcpad copied to clipboard

[Request/Feature] Feet-Inches Units

Open iSuckAtCoding8 opened this issue 1 year ago • 3 comments

This would be added under Insert > Units > Imperial/US.

The notations supported would probably include

  • 12' [feet only]
  • 144" [inches only]
  • 12'5" [feet and inches]
  • 12' 5 3/8" [feet and inches and fractions of inches]

I know both " and ' are reserved for title and text, so maybe this is impossible because parsing it would be a nightmare.

MathCAD does it with the FIF() function. Something like FIF(" 12'3 3/4" ") would give 12' 3 3/4". I know it's hard to read and tedious to type, so not sure how viable this is.

iSuckAtCoding8 avatar Nov 18 '24 07:11 iSuckAtCoding8

Actually this problem happens also with the Italian language when we need to use ' as apostrophe

sononicola avatar Nov 20 '24 14:11 sononicola

@iSuckAtCoding8 Adding such kind of units is very difficult to do now. Maybe it is possible for output only.

@sononicola As a workaround you can use ' in comments and prime symbol for variables. What occurs to me now is that we can escape these symbols with a slash, like in other languages, e.g.: \' and \". In this case, they will not be treated as text/title comment breaks.

Proektsoftbg avatar Nov 21 '24 09:11 Proektsoftbg

Try this following code:

#def ftin$(measure$)
#hide
feet = (measure$\1ft)*ft
inch = measure$ - (measure$\1ft)*ft|in
#show
#novar
#if feet > 0ft ∧ inch < 1*10^-6in
feet
#else if feet ≡ 0ft ∧ inch > 0in
inch
#else
feet' 'inch
#end if
#varsub
#end def

'12ft[feet only]
ftin$(12ft)

'144in [inches only]
ftin$(144in)

'12ft 5in [feet and inches]
ftin$((12ft + 5in))

'12ft 5 3/8in [feet and inches and fractions of inches]
ftin$((12ft + 5in + (3/8)*in))

It's only meant to display final results, so you can't perform calculations with it.

These are the results I've got using the code above: image

marcostrmuniz avatar Nov 22 '24 13:11 marcostrmuniz