testds
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 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | { $Id: testds.pp,v 1.3 2005/02/14 17:13:12 peter Exp $ This file is part of the Free Pascal run time library. Copyright (c) 1999-2000 by Michael Van Canneyt, member of the Free Pascal development team Tests the TDDGDataset component. See the file COPYING.FPC, included in this distribution, for details about the copyright. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. **********************************************************************} program testds; uses db,ddg_ds,sysutils; Procedure Log(Const Msg : String); begin Writeln(Msg); end; Procedure DumpFieldDef(F : TfieldDef); begin With F do begin Writeln ('Name : ',Name); Writeln ('FieldNo : ',FieldNo); Writeln ('Size : ',Size); Writeln ('FieldClass : ',FieldClass.ClassName); Writeln ('Required : ',required); Writeln ('Precision : ',Precision); Writeln ('DataType : ',FieldTypeNames[DataType]); Writeln ('InternalCalcField : ',Internalcalcfield); end; end; Procedure DumpField(F : Tfield); begin With F do begin writeln ('-------------------------------------'); Writeln ('FieldName : ',FieldName); Writeln ('FieldNo : ',FieldNo); Writeln ('Index : ',Index); Writeln ('DataSize : ',DataSize); Writeln ('Size : ',Size); Writeln ('DataType : ',FieldTypeNames[DataType]); Writeln ('Class : ',ClassName); Writeln ('Required : ',required); Writeln ('ReadOnly : ',ReadOnly); Writeln ('Visible : ',Visible); end; end; Procedure DumpFieldData (F : TField); begin With F Do begin Writeln ('Field : ',FieldName); Writeln ('Data type : ',FieldTypeNames[DataType]); Writeln ('As String : ',Asstring); Case Datatype of ftSmallint, ftInteger, ftWord : Writeln ('As longint : ',AsLongint); ftBoolean : Writeln ('As Boolean : ',AsBoolean); ftFloat : Writeln ('As Float : ',AsFloat); ftDate, ftTime, ftDateTime : Writeln ('As DateTime : ',DateTimeToStr(AsDateTime)); end; end;end; Var Data : TDDGdataset; I,Count : longint; Bookie : TBookMarkStr; Procedure ScrollForward; begin Writeln ('Browsing Forward:'); Writeln ('------------------'); With Data do While NOT EOF do begin Writeln ('================================================'); For I:=0 to FieldCount-1 do DumpFieldData(Fields[I]); Next; end;end; Procedure ScrollBackWard; begin Writeln ('Browsing Backward:'); Writeln ('-------------------'); With Data do While NOT BOF do begin For I:=0 to FieldCount-1 do DumpFieldData(Fields[I]); Prior; end; end; begin if paramcount<>1 then begin Writeln ('Usage : testds tablename'); Halt(1); end; Log ('Creating Dataset'); Data:=TDDGDataset.Create(Nil); With Data do begin Log('Setting Tablename'); TableName:=Paramstr(1); Log('Opening Dataset'); Open; Log('Dumping fielddefs : '); Writeln ('Fielddefs count : ',FieldDefs.Count); For I:=0 to FieldDefs.Count-1 do DumpFieldDef(FieldDefs.Items[i]); Writeln ('Fields count : ',FieldCount); For I:=0 to FieldCount-1 do DumpField(Fields[i]); ScrollForward; ScrollBackWard; Writeln ('Going to last :'); writeln ('---------------'); Last; ScrollBackWard; ScrollForward; Writeln ('Going to first:'); First; Count:=0; Writeln ('Browsing Forward:'); Writeln ('------------------'); With Data do While NOT EOF do begin Inc(Count); If Count=50 then begin Writeln ('Setting bookmark on record'); Bookie:=Bookmark; Writeln ('Got data : "',Bookie,'"'); end; For I:=0 to FieldCount-1 do DumpFieldData(Fields[I]); Next; end; Writeln ('Jumping to bookmark',Bookie); BookMark:=Bookie; Writeln ('Dumping Record : '); For I:=0 to FieldCount-1 do DumpFieldData(Fields[I]); Next; Writeln ('Dumping Next Record : '); For I:=0 to FieldCount-1 do DumpFieldData(Fields[I]); Prior; Prior; Writeln ('Dumping Previous Record : '); For I:=0 to FieldCount-1 do DumpFieldData(Fields[I]); Log('Closing Dataset'); Close; Log('End.'); Free; end; end. { $Log: testds.pp,v $ Revision 1.3 2005/02/14 17:13:12 peter * truncate log } |
¿Has encontrado algún error? ¿Tienes la solución? Dejame 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 personas con únicamente conocimiento básico del lenguaje, no de programación.
Otro 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.
Otro punto importante para muchos que crees que te he ignorado: Todos los comentarios los reviso y en su debido momento los apruebo, pero ojo con el con lo siguiente:Me reservo el derecho de alterar, publicar o no los comentarios así como también cambiar mis condiciones en el momento que yo lo requiera.
¿Si estas de acuerdo? Adelante! que ya te he quitado bastante tiempo leyendo esta basura :)