prueba cfg

pascal:
// $Id: cfgtest.pp,v 1.4 2005/02/14 17:13:18 peter Exp $

{$MODE objfpc}
{$H+}

program cfgtest;
uses xmlcfg;
var
  cfg: TXMLConfig;
  i: Integer;
  s: String;
  b: Boolean;
begin

  WriteLn('Writing a sample XML configuration to "testcfg.xml"...');

  cfg := TXMLConfig.Create('testcfg.xml');
  cfg.SetValue('cfgtest/MainWindow/Constraints/Width', 600);
  cfg.SetValue('cfgtest/MainWindow/Constraints/Height', 400);
  cfg.SetValue('cfgtest/MainWindow/Caption', 'TXMLConfig Test');
  cfg.SetValue('cfgtest/SomeForm/Presets/Preset1/Name', 'Example');
  cfg.SetValue('TipOfTheDay/Disabled', True);
  cfg.Free;

  WriteLn('Ok; now I''ll try to read back all values...');

  cfg := TXMLConfig.Create('testcfg.xml');

  i := cfg.GetValue('cfgtest/MainWindow/Constraints/Width', 0);
  if i <> 600 then
    WriteLn('Invalid value: cfgtest/MainWindow/Constraints/Width, got ', i);

  i := cfg.GetValue('cfgtest/MainWindow/Constraints/Height', 400);
  if i <> 400 then
    WriteLn('Invalid value: cfgtest/MainWindow/Constraints/Height, got ', i);

  s := cfg.GetValue('cfgtest/MainWindow/Caption', '');
  if s <> 'TXMLConfig Test' then
    WriteLn('Invalid value: cfgtest/MainWindow/Caption, got "', s, '"');

  s := cfg.GetValue('cfgtest/SomeForm/Presets/Preset1/Name', '');
  if s <> 'Example' then
    WriteLn('Invalid value: cfgtest/SomeForm/Presets/Preset1/Name, got "', s, '"');

  b := cfg.GetValue('TipOfTheDay/Disabled', False);
  if b <> True then
    WriteLn('Invalid value: TipOfTheDay/Disabled, got ', b);
  cfg.Free;

  WriteLn('Done!');
end.


{
  $Log: cfgtest.pp,v $
  Revision 1.4  2005/02/14 17:13:18  peter
    * truncate log

}

 
¿Ya le viste algún error? Dejanos tu correción ;-)

Antes de comentar: Gran parte de los ejercicios propuestos no tienen librerías debido a que Wordpress elimina los tags HTML. Si sabes/tienes/conoces las librerías que hacen falta, déjalo en los comentarios.

Otro punto antes de comentar, Si vas a sugerir un segmento de código en algún lenguaje debes hacerlo así:

De esta manera el código sale coloreado.

Otro punto importante para muchos que sienten que se les ignora: Todos los comentarios los reviso y en su debido momento los apruebo, pero ojo con el último párrafo.

Para poner los símbolos de las librerías sin que desaparezcan, debes escribir los símbolos de mayor > y menor qué < con su entidad HTML correspondiente, así como el símbolo de &

Mis Algoritmos se reserva el derecho de alterar, publicar o no los comentarios así como cambiar estas reglas de uso.

Si estas de acuerdo, adelante puedes comentar :)

P.D. No le hago tareas a nadie, mejor hagan la mía :P