Ga naar inhoud
  • 0

Getallen kleuren in functie van


Dirty May

Vraag

Filemaker voorziet om tekst een kleur te geven in functie van deze of gene voorwaarde.

Helaas is dat niet van toepassing voor getallen. Niet zo begrijpelijk waarom niet.

Maar goed, dan maar zelf iets in eengeknutseld.

 

Wel er bij zeggen dat standaard de (Europese) interpunctie toegepast wordt.

 

De gebruikte Functieparameters zijn Getal en Aantal decimalen.

 

Wie van oordeel is dat dit beter kan, of korter, mag zich gerust laten horen.

Altijd blij wat bij te leren.

 

 

[ Erratum : wie voor 02-04-2008 18:51 dit heeft gekopieerd, heeft een foute versie bij negatieve getallen. Mijn excuses hiervoor. ]

 

 

If ( Left ( Getal ; 1 ) = "-" ; "-" ; "" ) &

 

Case (

 

Length ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ) > 15 ;

Middle ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ; 1 ; Length ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ) - 15 ) & "." &

Middle ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ; Length ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ) - 14 ; 3 ) & "." &

Middle ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ; Length ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ) - 11 ; 3 ) & "." &

Middle ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ; Length ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ) - 8 ; 3 ) & "." &

Middle ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ; Length ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ) - 5 ; 3 ) & "." &

Middle ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ; Length ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ) - 2 ; 3 ) ;

 

Length ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ) > 12 ;

Middle ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ; 1 ; Length ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ) - 12 ) & "." &

Middle ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ; Length ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ) - 11 ; 3 ) & "." &

Middle ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ; Length ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ) - 8 ; 3 ) & "." &

Middle ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ; Length ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ) - 5 ; 3 ) & "." &

Middle ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ; Length ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ) - 2 ; 3 ) ;

 

Length ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ) > 9 ;

Middle ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ; 1 ; Length ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ) - 9 ) & "." &

Middle ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ; Length ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ) - 8 ; 3 ) & "." &

Middle ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ; Length ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ) - 5 ; 3 ) & "." &

Middle ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ; Length ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ) - 2 ; 3 ) ;

 

Length ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ) > 6 ;

Middle ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ; 1 ; Length ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ) - 6 ) & "." &

Middle ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ; Length ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ) - 5 ; 3 ) & "." &

Middle ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ; Length ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ) - 2 ; 3 ) ;

 

 

Length ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ) > 3 ;

Middle ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ; 1 ; Length ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ) - 3 ) & "." &

Middle ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ; Length ( Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) ) - 2 ; 3 ) ;

 

Truncate ( Round ( Filter ( Getal; "0123456789," ) ; Aantal decimalen ) ; 0 ) )

 

& If ( Aantal decimalen ≠ 0 ; "," ; "" )

 

& Right ( Truncate ( Round ( Getal ; Aantal decimalen ) ; Aantal decimalen ) ;

 

Length ( Truncate ( Round ( Getal ; Aantal decimalen ) ; Aantal decimalen ) ) -

 

If ( Position ( Truncate ( Round ( Getal ; Aantal decimalen ) ; Aantal decimalen ) ; "," ; 1 ; 1 ) = 0 ;

 

Length ( Truncate ( Round ( Getal ; Aantal decimalen ) ; Aantal decimalen ) ) ; Position ( Truncate ( Round ( Getal ; Aantal decimalen ) ; Aantal decimalen ) ; "," ; 1 ; 1 ) ) )

 

& Right ( 10 ^ Aantal decimalen ;

 

Aantal decimalen -

 

( Length ( Truncate ( Round ( Getal ; Aantal decimalen ) ; Aantal decimalen ) ) -

 

If ( Position ( Truncate ( Round ( Getal ; Aantal decimalen ) ; Aantal decimalen ) ; "," ; 1 ; 1 ) = 0 ;

 

Length ( Truncate ( Round ( Getal ; Aantal decimalen ) ; Aantal decimalen ) ) ; Position ( Truncate ( Round ( Getal ; Aantal decimalen ) ; Aantal decimalen ) ; "," ; 1 ; 1 ) ) ) )

aangepast door Gast
Link naar reactie

8 antwoorden op deze vraag

Aanbevolen berichten

  • 0

Bij het verder testen van deze functie stoot ik echter op een moeilijk oplosbaar probleem.

 

Wanneer er een reeks van 9 aaneengesloten nullen net voor

de komma komen te staan, dan krijg ik, let echter wel, in de getekste versie,

een rare notatie tegen, waarschijnlijk wordt ergens diep in de coding

met wetenschappelijke notaties gewerkt.

Vandaar waarschijnlijk dit uitzicht.

 

70.000.000.000,006 wordt : 7.,0e.+10,0e+10

 

Als ik evenwel tussen al die nullen 1 niet-nul zet, dan wordt het :

 

700.000.000.001,006 wordt : 700.000.000.001,006

 

Onthoudt hierbij : links is het oorspronkelijke getal, rechts is tekst !

 

Een ander voorbeeld, zonder cijfers na de komma :

 

1.230.000.000.000 wordt : 1,.23e.+1223e+12

 

Maar zet ik een niet-nul, net voor de komma bijvoorbeeld, dan doe ik wat ik wil :

 

12.300.000.000.000.001 wordt netjes 12.300.000.000.000.001

 

Iemand enig idee hoe dat kan voorkomen worden ?

 

Ik heb ondertussen gepoogd om elke Functieparameter Getal te vervangen

door GetAsText ( Getal ). Dit helpt in ieder geval niet.

Link naar reactie

Doe mee aan dit gesprek

Je kunt dit nu plaatsen en later registreren. Indien je reeds een account hebt, log dan nu in om het bericht te plaatsen met je account.

Gast
Beantwoord deze vraag...

×   Geplakt als verrijkte tekst.   Plak in plaats daarvan als platte tekst

  Er zijn maximaal 75 emoji toegestaan.

×   Je link werd automatisch ingevoegd.   Tonen als normale link

×   Je vorige inhoud werd hersteld.   Leeg de tekstverwerker

×   Je kunt afbeeldingen niet direct plakken. Upload of voeg afbeeldingen vanaf een URL in

×
×
  • Nieuwe aanmaken...