Machsupport Forum

Mach Discussion => Mach Screens => Flash Screens => Topic started by: azambuja on September 08, 2008, 01:44:07 PM

Title: How to round numbers
Post by: azambuja on September 08, 2008, 01:44:07 PM
Hello friends,

How can I make this transformation:

1.3333 to 1.33 ???

I tried to use this code:

X=Round(GetDRO(0),2)
AB=Round(X*100)/100
Call SetOEMDRO(800,AB)

but the number I got  was 1.3300.
All that I wanted was 1.33.

Thanks for any support.
Title: Re: How to round numbers
Post by: Chaoticone on September 08, 2008, 01:57:16 PM
Can you format your dro/s to only display two decimal places and then when it pulls the value from that DRO will it only use what is seen?

Just thinking out loud.
Brett
Title: Re: How to round numbers
Post by: azambuja on September 08, 2008, 02:01:29 PM
How can I format my DRO's?
I do not know how to do it.
If you know how, hepl me.

thanks
Title: Re: How to round numbers
Post by: Chaoticone on September 08, 2008, 02:03:26 PM
If this is a flash screen your dealing with, I can't help you.

Brett
Title: Re: How to round numbers
Post by: azambuja on September 08, 2008, 02:05:08 PM
Yes, it is a flash screen.

And thanks again.
Title: Re: How to round numbers
Post by: zealous on September 08, 2008, 02:54:02 PM
Hi,
To format a DRO use:

Example will format DRO 104

Code: [Select]
fscommand( "DROFmt104", "%.0f")
To format to time based:

Example will format DRO 815 and 814

Code: [Select]
fscommand( "DROFmt815", "%D:%H:%M:%S")
fscommand( "DROFmt814", "%D:%H:%M:%S")

Thanks,
Jason Blake
Title: Re: How to round numbers
Post by: zealous on September 08, 2008, 03:01:07 PM
These are the formating parameters:

Days:Hours:Minutes:Seconds

Code: [Select]
"%D:%H:%M:%S"
(f)loating point number, (4) decimal points, (+) or -

Code: [Select]
"+%.4f"
integer, no decimals

Code: [Select]
"%i"
hex number

Code: [Select]
"%x"
Format to send the above:

fscommand( TYPE fmt DRO Number , ABOVE FORMAT )

Example:
fscommand ("DROFmt800" , "format" )
Title: Re: How to round numbers
Post by: azambuja on September 08, 2008, 03:28:03 PM
This was really helpfull.
Thanks a lot.

azambuja
Title: Re: How to round numbers
Post by: zealous on September 11, 2008, 07:12:16 PM
Great  ;D
Title: Re: How to round numbers
Post by: Chaoticone on September 11, 2008, 07:13:35 PM
Thanks for helping Jason.  :)

Brett