stringl

¿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
87
88
program teststrings;
 
Uses classes,sysutils;
 
Procedure DoRef (P : Pointer); 
Type PLongint = ^Longint;
 
begin
  If P=Nil then    Writeln ('(Ref : Empty string)')
  else
{$ifdef fpc}
    Writeln (' (Ref: ',Plongint(Longint(P)-4)^,',Len: ',PLongint(Longint(P)-8)^,')');
{$else}    Writeln (' (Ref: ',Plongint(Longint(P)-8)^,',Len: ',PLongint(Longint(P)-4)^,')');
{$endif}
end;
 
Procedure test; 
var S,TS : ANsiSTring;
    T : TStringList;
    I,J : Longint;
    A : String[255]; 
begin
  S:='An Ansi string ';
  T:=TStringList.create;
  Writeln ('Count : ',T.Count,' Capacity : ',T.Capacity);  For I:=1 to 10 do
    begin
    str (I,TS);
    T.Add(S+TS);
    end;  Writeln ('Count : ',T.Count,' Capacity : ',T.Capacity);
  J:=T.Count-1;
  Writeln ('J : ',J);
  For I:=0 to J do
    Writeln(I,'/',J,' : ',T.Strings[I]);  T.SaveToFile ('strings.dat');
  T.Clear;
  T.LoadFromFile('strings.dat');
  J:=T.Count-1;
  Writeln ('Count = ',J);  For I:=0 to J do
    Writeln(I,'/',J,' : ',T.Strings[I]);
  Writeln ('IndexOf(''An Ansi string 6'') = ',T.IndexOf('An Ansi string 6'));
  Writeln ('IndexOf(''An Ansi string 11'') = ',T.IndexOf('An Ansi string 11'));
  T.Clear;  For I:=1 to 10 do
    T.Values['Var'+IntToStr(I)]:='Val'+IntToSTr(I);
  J:=T.Count-1;
  Writeln ('J = ',J);
  For I:=0 to J do    Writeln(I,'/',J,' : ',T.Strings[I]);
  Writeln ('Indexof(''Var6'') = ',T.IndexOfName('Var6'));
  Writeln ('Indexof(''Var13'') = ',T.IndexOfName('Var13'));
  Writeln ('Value[''Var6'']  = ',T.Values['Var6']);
  Writeln ('Value[''Var13'']  = ',T.Values['Var13']);  Try
    Writeln ('String 100 = ');
    S:=T.Strings[100];
  except
    On e: exception do Writeln ('Caught exception : ',e.message);  end;
  T.Free;
end;
 
Var Data : longint;    t    : THeapStatus;
begin
  Data:=getfpcheapstatus.currheapused;
  test;
  Writeln ('Lost ',getfpcheapstatus.currheapused-data);end.
 
{
  $Log: stringl.pp,v $
  Revision 1.6  2005/03/20 12:46:55  marco   * sb removed legacymem. Fixed with getfpcheapstatus. Now 1.9.9 only
 
  Revision 1.5  2005/03/16 13:30:17  marco
   * fixed with legacymem (I hope)
   Revision 1.4  2005/02/14 17:13:18  peter
    * truncate log
}

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.