Bonjour,
Je voudrais passer une chaîne et retourner un nombre.
Je vous présente la procédure Make produisant un Attribut_Record ; Un article composé d'une chaîne de caractère en guise d'image, la valeur Value dont le type dépend de la chaîne, et le type Enum alias le type de donnée.
Code :
function Make (Names : in String; Value : in String) return Attribut_Record is Att : Attribut_Record; begin Att.Name := new String ' (Names); begin Att.boo := Boolean'Value(Value); Att.Enum := Boo; Att.Value := new String ' (Boolean'Image(Att.Boo)); exception when Constraint_Error => begin Att.Int := Integer'Value(Value); Att.Enum := Int; Att.Value := new String ' (Integer'Image(Att.Int)); exception when Constraint_Error => begin Att.Flt := float'Value(Value); Att.Enum := Flt; Att.Value := new String ' (Float'Image(Att.Flt)); exception when Constraint_Error => begin Att.date := Formatting.Value(Value); Att.Enum := Date; Att.Value := new String ' (Formatting.Image(Att.Date)); exception when Constraint_Error => begin Att.str := new String ' (Value); Att.Enum := Str; Att.Value := new String ' (Att.Str.all); end; end; end; end; end; return Att; end Make;
|
Je suis sur un os. J'entre "8.0 * 7.0" et je voudrais 56.0.
S'il vous plait, merci.
Message édité par lady ada le 11-10-2026 à 14:19:25
---------------
main is business suite for Ada projects. Web site : inconito.net