Solved

Display imperial units .

Posted on 1998-07-13
11
443 Views
Last Modified: 2010-04-04
We have a requirement to Display Feet and Inches, it must be displayed in fractions not decimal.

Is there a component which will provide this?
0
Comment
Question by:terryamy
  • 3
  • 3
  • 3
  • +2
11 Comments
 
LVL 3

Expert Comment

by:Matvey
ID: 1357774
0
 

Author Comment

by:terryamy
ID: 1357775
The Question is not on the default units but How can you ensure that the operator inputs a distance in Feet and Inches.

We have Edit Boxes and Mask Edit Boxes is there an component that will take an input of say

       3' 5½"

sorry if the original question was not clear
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1357776
What about using a mask?
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1357777
I haven't seen anything specific for this task. As ZifNab says - you should use some kind of a mask-edit-box.

I found some interesting once though:

                      http://bes.trendline.co.il/torry/vcl/edits/validat.zip

"TValidatorEdit works like a normal TEdit, except that it validates your inputs while you type. You can specify the characters that may not or may exclusively be entered."

                      http://www.prodat.no/fnp/fnpnumed.zip

" TFnpNumericEdit is an enhanced version of the standard edit control, that is designed specifically for entering numbers. This component is ideal for data entry applications and other situations where you want to restrict user input to a certain range of numbers. You may specify from 0 to 9 decimals. This component gives you the ability to define minimum and maximum values that are allowed. If an invalid entry is made, an event is fired when the component loses the focus. "

                      http://bes.trendline.co.il/torry/vcl/edits/juniornm.zip
"Number edit."

                      http://bes.trendline.co.il/torry/vcl/edits/skedit.zip

"SKEdit descended from TEdit. Allows you to only enter numerical values, '.', '-'. Still allows for the use of the delete and backspace keys."

                      http://bes.trendline.co.il/torry/vcl/edits/tb97addon.zip

"Five components to work with famous ToolBar97. Contains enhanced TEdit97, TSpin97, TSpinEdit97, TNumEdit97 and TLinkEdit97."

                      http://bes.trendline.co.il/torry/vcl/edits/maskedex.zip

.

Hope this isn't just a big mass a'crap...
0
 

Author Comment

by:terryamy
ID: 1357778
Thank you for the locations I will look at them with interest.

How do the USA operators input FEET and INCHES for there software applications?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 3

Expert Comment

by:Matvey
ID: 1357779
I'm not from the US, and inches and feet make dizzy :)
0
 
LVL 1

Expert Comment

by:Greedy
ID: 1357780
every input I've seen uses decimals...in fact the only place that I've ever sean that you can enter fractions was in Maple.  Maple is a math program for solving complex calculas operation.  If it fits within your user interface you just might want to use two edit boxes with feet and inches.  It might be a cool option (selling point that never really gets used) to have a tricked out graphical entry field that can do fractions but any engineer will use decimals and if they are a scientist they will most likly use the metric system.  When I was in school it was always 9.81 m/s for g.  Never have I used 32 ft/s except to quickly figure out how fast a penny will be traveling after I launch it off a building into the skull of some clueless policeman :)  Actually in a program to track stock prices I saw a edit control that used fractions but it had two spincontrols one that controled the current value and another that controled the amount that would be added or subtracted for the value...so if you wanted to get 5/64 you would put in 1/16 and then 1/64
0
 

Author Comment

by:terryamy
ID: 1357781
Thank you  Greedy for your comments.

I agree that they would use decimals if they where Engineers, but I am dealing with Sales personnel!!!! and buyers.

They have stipulated that the Screen needs to be in Feet and Inches and also the drawings produced also in Feet and inches.

My main concern is to provide a clear picture of the data input screen.  I've thought of using four edit boxes arranged to show clearly the feet and inches and possibly create a calculator type form to select with radio buttons. Only ideas but it might work.

Thank you all again.
0
 
LVL 1

Expert Comment

by:Greedy
ID: 1357782
you could use this code to get the whole number and parts of the fraction.

I droped a edit box, 3 labels and a Button on a new form

procedure TForm1.Button1Click(Sender: TObject);
var
  MyTempInt: Integer;
begin
  try
    Label1.Caption := Copy( Trim(Edit1.Text), 0, (Pos(' ', Trim(Edit1.Text))-1));
    Label2.Caption := Copy( Trim(Edit1.Text), (Pos(' ', Trim(Edit1.Text))+1), (Pos('/', Trim(Edit1.Text)))-(Pos(' ', Trim(Edit1.Text))+1));
    Label3.Caption := Copy( Trim(Edit1.Text), (Pos('/', Trim(Edit1.Text))+1), (Length(Trim(Edit1.Text))-(Pos('/', Trim(Edit1.Text)))));
    MyTempInt := (StrToInt(Label1.Caption));
    MyTempInt := (StrToInt(Label2.Caption));
    MyTempInt := (StrToInt(Label3.Caption));
  except
    MessageDlg('Damn it, Fix that crap!', mtWarning, [mbOK], 0);
  end;
end;

I would probably use a mask and check to make sure that the edit box has a space and a / charicter in it.

0
 
LVL 1

Expert Comment

by:Greedy
ID: 1357783
You might need some code to ruduce the fractions...ie 2/4 = 1/2

0
 
LVL 1

Accepted Solution

by:
pjdb earned 50 total points
ID: 1357784
value is the value to transform (in exemple 2.5)
entier is the integer value (2)
numerateur is the numerator (1)
Denominateur is the denominator (2)
the result is the rest (0)

so the fraction is 2 + 1/2

to test if the value is a fraction, test if the rest is 0. If not, the return values is the nearest fraction (2.511 -> 2 + 93/182 + 1.1e-5)

Function Fraction(Value:double; Var Entier, Numerateur, Denominateur:LongInt):Double;
Const
      MaxFrac=256;            //max value of the denominator
      EqZero=1E-10;
Var
      Actuel:Double;
      i:Integer;
Begin
      entier:=Trunc(Value);
      Value:=Frac(Value);
      Result:=Value;
      For i:=2 To MaxFrac Do
      Begin
            Numerateur:=Trunc(Value * i + EqZero);
            Actuel:=Value - Numerateur / i;
            If Abs(Result)>Abs(Actuel) Then
            Begin
                  Denominateur:=i;
                  Result:=Actuel;
                  If Actuel<EqZero Then
                  Begin
                        Result:=0;
                        Break;
                  End;
            End;
      End;
      Numerateur:=Trunc(Value * Denominateur + EqZero);
End;      {Fraction}

0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now