[Samples] Sexagesimal Expression s Evaluator

This topic is 4412 days old. Please don't post here. Open a new topic instead.

Recommended Posts

File Name: Sexagesimal Expression s Evaluator

File Submitter: raybaudi

File Submitted: 07 Jan 2011

File Category: Samples

FM Version: 9

A simple sexagesimal expression's evaluator.

Share on other sites

Nice. Two suggestions:

`rest = Mod ( adj ; 3600 ) ;`
```

Result =

```
`Time ( degrees ; minutes ; seconds )`

Share on other sites

Thank you.

I could take your first suggestion, but why the second ?

0° will be 0:00:00 ( or am I blind ? )

Share on other sites

Because it is an accepted format to express a sexagesimal value - and also because the result remains usable for further calculations.

And - I forgot to mention - you could let the Time function do all the work, i.e.

`Time ( 0 ; 0 ; adj )`
```

BTW, you can do this even with your text result, e.g.

```
`Hour ( adj ) & "°" & ... `

Share on other sites

This is a nice suggestion !

So I end up with:

Let([

adj = "(" & Substitute ( TrimAll ( input ; 1 ; 3 ) ; [ ¶ ; "" ] ; [ "-" ; ")-("] ; [ "+" ; ")+("] ; [ "*" ; ")*(" ] ; [ "/" ; ")/("] ; [ "x" ; ")*(" ] ; [ ":" ; ")/("]) & ")" ;

adj = Mod ( Evaluate ( Substitute ( adj ; [ "()" ; ""] ; [ "°" ; "*3600 "] ; [ "'" ; "*60 "] ; [ "\"" ; " "] ;[ " " ; "+"] ; [ "+)" ; ")" ] ) ) ; 360*3600 )

];

Hour ( adj ) & "°" & If ( Minute ( adj ) ; Minute ( adj ) & "'" ) & If ( Seconds ( adj ) ; Seconds ( adj ) & "\"" )

)

BTW: I wished to use the List ( ) function in the result ( to get only not empty values ), but could not find a way.