IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Composants FMX Delphi Discussion :

[Tokyo 10.2.1] un autre bug dans l'interpréteur d'expressions (customformat)


Sujet :

Composants FMX Delphi

  1. #1
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 043
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 67
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 043
    Points : 40 957
    Points
    40 957
    Billets dans le blog
    62
    Par défaut [Tokyo 10.2.1] un autre bug dans l'interpréteur d'expressions (customformat)
    Bonjour,

    Avant de crier au loup sur le Quality Portal, je voudrai savoir si cela vient de moi ou ...

    j'avais rapporté sur la version 10.2.0 (RSP-18553) un bug a propos de format corrigé dans la version 10.2.1

    A la rédaction d'un nouveau tutoriel sur les Livebindings (LiveBindings + Base de données) il semble que je tombe sur un nouveau bug qui correspond peut être aux RSP-18988 et RSP-19411 du Quality Portal mais bon, je voudrai une certitude si quelques uns d'entre vous pouvaient faire le test.

    Contexte, je prend une table (ou une requête) qui contient un champ Float (non monétaire pour faire plus compliqué )
    je veux l'afficher justement sous forme monétaire (donc avec arrondi si besoin) mais avec 3 décimales je complique mais c'est voulu.

    mon expression CustomFormat devrait alors être Format('%%3.3m',%s) ou Format('%%3.3m',value) ou tout autre variante généralement acceptée pour appeler la valeur de la colonne. Rien n'y fait (quand l'interpréteur ne m'envoie pas aux pelotes en m'insultant )
    De rage, j'ai écrit Format('%%3.3m',123.456789) et là miracle j'obtiens 123.457 € donc mon format (la partie constante) est Ok
    pire, Format('%%3.3m',1*Value) fonctionne ! (je n'ai pas encore vérifier les autres variantes)


    La question est donc : est-ce chez moi ou, si vous pouvez faire le test, avez vous ce même comportement ?
    Je vais tenter de faire un petit source et tester les différentes variantes au cas où le sujet accrocherait !

    [Edit] un essai avec les version Berlin 10.1 ou Tokyo 10.2.0 ne montre aucun problème
    MVP Embarcadero
    Delphi installés : D3,D7,D2010,XE4,XE7,D10 (Rio, Sidney), D11 (Alexandria), D12 (Athènes)
    SGBD : Firebird 2.5, 3, SQLite
    générateurs États : FastReport, Rave, QuickReport
    OS : Window Vista, Windows 10, Windows 11, Ubuntu, Androïd

  2. #2
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 043
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 67
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 043
    Points : 40 957
    Points
    40 957
    Billets dans le blog
    62
    Par défaut
    Pour vous faire une idée
    ce code
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    unit Unit8;
     
    interface
     
    uses
      System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
      FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
      FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Error, FireDAC.UI.Intf,
      FireDAC.Phys.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Stan.Async,
      FireDAC.Phys, FireDAC.Phys.SQLite, FireDAC.Phys.SQLiteDef,
      FireDAC.Stan.ExprFuncs, FireDAC.FMXUI.Wait, FireDAC.Stan.Param, FireDAC.DatS,
      FireDAC.DApt.Intf, FireDAC.DApt, FMX.Controls.Presentation, FMX.StdCtrls,
      Data.DB, FireDAC.Comp.DataSet, FireDAC.Comp.Client, Data.Bind.EngExt,
      Fmx.Bind.DBEngExt, System.Rtti, System.Bindings.Outputs, Fmx.Bind.Editors,
      Data.Bind.Components, Data.Bind.DBScope;
     
    type
      TForm8 = class(TForm)
        FDConnection1: TFDConnection;
        FDQuery1: TFDQuery;
        PartName: TLabel;
        Label2: TLabel;
        Quantity: TLabel;
        Label4: TLabel;
        UnitPrice: TLabel;
        Label6: TLabel;
        Total: TLabel;
        Label8: TLabel;
        FDQuery1PART: TWideStringField;
        FDQuery1QTY: TFloatField;
        FDQuery1UNITPRICE: TFloatField;
        BindSourceDB1: TBindSourceDB;
        BindingsList1: TBindingsList;
        LinkPropertyToFieldText: TLinkPropertyToField;
        LinkPropertyToFieldText2: TLinkPropertyToField;
        LinkPropertyToFieldText3: TLinkPropertyToField;
        LinkPropertyToFieldText4: TLinkPropertyToField;
        Rounded: TLabel;
        LinkPropertyToFieldText5: TLinkPropertyToField;
      private
        { Déclarations privées }
      public
        { Déclarations publiques }
      end;
     
    var
      Form8: TForm8;
     
    implementation
     
    {$R *.fmx}
     
    end.
    avec ce dfm
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    object Form8: TForm8
      Left = 0
      Top = 0
      Caption = 'Form8'
      ClientHeight = 321
      ClientWidth = 339
      FormFactor.Width = 320
      FormFactor.Height = 480
      FormFactor.Devices = [Desktop]
      DesignerMasterStyle = 0
      object PartName: TLabel
        Position.X = 80.000000000000000000
        Position.Y = 56.000000000000000000
        Text = 'a part'
        object Label2: TLabel
          Position.X = -72.000000000000000000
          Size.Width = 57.000000000000000000
          Size.Height = 17.000000000000000000
          Size.PlatformDefault = False
          Text = 'Part Name'
        end
      end
      object Quantity: TLabel
        Position.X = 80.000000000000000000
        Position.Y = 88.000000000000000000
        Text = '1,25'
        object Label4: TLabel
          Position.X = -72.000000000000000000
          Size.Width = 57.000000000000000000
          Size.Height = 17.000000000000000000
          Size.PlatformDefault = False
          Text = 'Quantity'
        end
      end
      object UnitPrice: TLabel
        Position.X = 80.000000000000000000
        Position.Y = 120.000000000000000000
        Text = '0,235'
        object Label6: TLabel
          Position.X = -72.000000000000000000
          Size.Width = 57.000000000000000000
          Size.Height = 17.000000000000000000
          Size.PlatformDefault = False
          Text = 'Unit Price'
        end
      end
      object Total: TLabel
        Position.X = 80.000000000000000000
        Position.Y = 152.000000000000000000
        Text = '0,29 '#8364
        object Label8: TLabel
          Position.X = -72.000000000000000000
          Size.Width = 57.000000000000000000
          Size.Height = 17.000000000000000000
          Size.PlatformDefault = False
          Text = 'Total'
        end
      end
      object Rounded: TLabel
        Position.X = 152.000000000000000000
        Position.Y = 120.000000000000000000
        Text = '0,24'
      end
      object FDConnection1: TFDConnection
        Params.Strings = (
          'Database=F:\XE8\Test\CustomFormat\Win32\Debug\Test.db'
          'DriverID=SQLite')
        Connected = True
        LoginPrompt = False
        Left = 40
        Top = 232
      end
      object FDQuery1: TFDQuery
        Active = True
        Connection = FDConnection1
        SQL.Strings = (
          'SELECT '#39'a part'#39' PART,1.25 QTY,0.235 UNITPRICE'
          'union'
          'SELECT '#39'part 2'#39',4,1.2568')
        Left = 128
        Top = 232
        object FDQuery1PART: TWideStringField
          AutoGenerateValue = arDefault
          FieldName = 'PART'
          Origin = 'PART'
          ProviderFlags = []
          ReadOnly = True
          Size = 32767
        end
        object FDQuery1QTY: TFloatField
          AutoGenerateValue = arDefault
          FieldName = 'QTY'
          Origin = 'QTY'
          ProviderFlags = []
          ReadOnly = True
        end
        object FDQuery1UNITPRICE: TFloatField
          AutoGenerateValue = arDefault
          FieldName = 'UNITPRICE'
          Origin = 'UNITPRICE'
          ProviderFlags = []
          ReadOnly = True
        end
      end
      object BindSourceDB1: TBindSourceDB
        DataSet = FDQuery1
        ScopeMappings = <>
        Left = 232
        Top = 112
      end
      object BindingsList1: TBindingsList
        Methods = <>
        OutputConverters = <>
        Left = 220
        Top = 229
        object LinkPropertyToFieldText: TLinkPropertyToField
          Category = 'Liaisons rapides'
          DataSource = BindSourceDB1
          FieldName = 'PART'
          Component = PartName
          ComponentProperty = 'Text'
        end
        object LinkPropertyToFieldText2: TLinkPropertyToField
          Category = 'Liaisons rapides'
          DataSource = BindSourceDB1
          FieldName = 'QTY'
          Component = Quantity
          ComponentProperty = 'Text'
        end
        object LinkPropertyToFieldText3: TLinkPropertyToField
          Category = 'Liaisons rapides'
          DataSource = BindSourceDB1
          FieldName = 'UNITPRICE'
          Component = UnitPrice
          ComponentProperty = 'Text'
        end
        object LinkPropertyToFieldText4: TLinkPropertyToField
          Category = 'Liaisons rapides'
          DataSource = BindSourceDB1
          FieldName = 'UNITPRICE'
          Component = Total
          CustomFormat = 'Format('#39'%%3.2m'#39',DataSet.UnitPrice.value*DataSet.QTY.Value)'
          ComponentProperty = 'Text'
        end
        object LinkPropertyToFieldText5: TLinkPropertyToField
          Category = 'Liaisons rapides'
          DataSource = BindSourceDB1
          FieldName = 'UNITPRICE'
          Component = Rounded
          CustomFormat = 'Format('#39'%%3.2f'#39',Value)'
          ComponentProperty = 'Text'
        end
      end
    end
    Fonctionne parfaitement avec Berlin 10.1
    J'ai donc appuyé les deux rapport de bug cités en y ajoutant mon grain de sel

    [Edit] P.S. j'ai oublié d'indiquer qu'il fallait une base SQLite même vide pour pouvoir tester directement à partir de l'IDE
    MVP Embarcadero
    Delphi installés : D3,D7,D2010,XE4,XE7,D10 (Rio, Sidney), D11 (Alexandria), D12 (Athènes)
    SGBD : Firebird 2.5, 3, SQLite
    générateurs États : FastReport, Rave, QuickReport
    OS : Window Vista, Windows 10, Windows 11, Ubuntu, Androïd

Discussions similaires

  1. Réponses: 1
    Dernier message: 11/10/2008, 10h22
  2. Bug dans les expressions régulières ?
    Par SergioF dans le forum Linux
    Réponses: 8
    Dernier message: 12/05/2004, 15h14
  3. [PROPERTIES] Bug dans java.util.Properties ?
    Par mathieu dans le forum Collection et Stream
    Réponses: 6
    Dernier message: 28/04/2004, 15h11
  4. bug dans une base Access
    Par bizouard dans le forum Access
    Réponses: 5
    Dernier message: 29/12/2003, 12h41
  5. [Postgresql]Connecter à une autre base dans une fonction
    Par alex2205 dans le forum Requêtes
    Réponses: 2
    Dernier message: 05/05/2003, 11h30

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo