testapp

¿Has encontrado un error? ¿Tienes la solución? Deja tu correción ;-)

Antes de comentar: Gran parte de los ejercicios propuestos no tienen librerías debido a que Wordpress las eliminó al verlas como etiquetas HTML. Si sabes/tienes/conoces las librerías que hacen falta, déjalo en los comentarios. Y lo mas importante: Todos los ejemplos fueron realizados por estudiante con únicamente conocimiento básico del lenguaje, no de programación.

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
{$mode objfpc}
{$h+}
 
program testapp;
 uses custapp,classes;
 
Const
  ShortOpts = 'abc:d:012';
  Longopts : Array[1..6] of String = (    'add:','append','delete:','verbose','create:','file:');
 
Type
  TTestApp = Class(TCustomApplication)
    Procedure DoRun ; Override;  end;
 
Procedure TTestApp.DoRun;
 
Var  I : Integer;
  S : String;
  Opts,FN,Args : TStrings;
 
begin  Writeln('Exe name            : ',ExeName);
  Writeln('Help file           : ',HelpFile);
  Writeln('Terminated          : ',Terminated);
  Writeln('Title               : ',Title);
  Writeln('Console app         : ',ConsoleApplication);  Writeln('Location            : ',Location);
  Writeln('ParamCount          : ',ParamCount);
  For I:=0 to ParamCount do
    Writeln('Params [',I:3,']        : ',Params[i]);
  Writeln('Option char         : ',OptionChar);  Writeln('Case sensitive opts : ',CaseSensitiveOptions);
  Writeln('StopOnException     : ',StopOnException);
  Writeln('----------------------------------------');
  Writeln('Simple options check');
  S:=CheckOptions(ShortOpts,LongOpts);  If (S<>'') then
    Writeln(S);
  Writeln('Longer options check');
  Opts:=TstringList.Create;
  FN:=TStringList.Create;  Args:=TStringList.Create;
  Try
    For I:=1 to 6 do
      Opts.Add(LongOpts[i]);
    S:=CheckOptions(ShortOpts,Opts,Args,FN);    Writeln('Found ',Args.Count,' options and ',FN.Count,' non-options (filenames)');
    For I:=0 to Args.Count-1 do
      Writeln('Option ',I:2,': ',Args[i]);
    For I:=0 to FN.Count-1 do
      Writeln('Non-Option ',I:2,': ',FN[i]);    Writeln('Getting option value "add"');
    S:=GetOptionValue('add');
    Writeln('Value for "add": ',S);
    Writeln('Testing Hasoption "a"');
    Writeln('Option append found: ',HasOption('append'));    Writeln('Option a or append found: ',HasOption('a','append'));
    Writeln('-----------------------');
    GetEnvironmentList(Opts,True);
    Writeln('Found ',Opts.Count,' environment variables');
    For I:=0 to Opts.Count-1 do      Writeln(I:3,': ',Opts[i],' with value "',EnvironmentVariable[Opts[i]],'"');
  Finally
    Opts.Free;
    FN.Free;
    Args.Free;  end;
  Terminate;
  Writeln('-------------------------');
  Writeln('After terminate, "terminated" is ',Terminated);
end; 
Var
  App : TTestApp;
 
begin  App:=TTestApp.Create(Nil);
  App.Initialize;
  App.Title:='CustomApplication class test application.';
  App.Run;
  App.Free;end.

Punto importante: Si vas a sugerir un segmento de código en algún lenguaje debes hacerlo así:

  • Si es lenguaje C <code lang="c">Código en C</code>
  • Si es lenguaje Pascal <code lang="pascal">Aquí dentro el código de Pascal</code>.

De esta manera el código coloreas el código.

Deja un comentario

Suscribirse a los comentarios.