{ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA } program Test; uses DOS, CRT, Defin, Config, Screen, Strings, Files; const AllDone: boolean = false; procedure DoRegisters(Cmd: string); var Rest: string; I, NrF: integer; begin if Cmd = '' then begin HelpP.FlashMessage(1, 'Comando incompleto.', 2000); exit; end; Rest := copy(Cmd, 2, length(Cmd)-1); NrF := NrFields(Cmd, ','); case upcase(Cmd[1]) of 'A': if NrF <> 2 then begin HelpP.FlashMessage(1, 'Esperaba 2 campos', 2000); exit; end else RegP.AddRegister(Field_Nr(Rest, ',', 1), Field_Nr(Rest, ',', 2)); 'D': if NrF = 1 then RegP.DelRegister(Field_Nr(Rest, ',', 1)); end; MainConfig.WriteInteger('Registros', 'Numero', RegP.NrReg); for I := 1 to RegP.NrReg do with RegP.Reg[I] do begin MainConfig.WriteString('Registros', 'Reg'+HexB(I), Ref + ',' + HexB(FNr)); end; end; procedure Command; var Cmd, Rest: string; begin Cmd := CommandP.GetCommand('Sim>'); if Cmd <> '' then begin Rest := copy(Cmd, 2, length(Cmd)-1); case upcase(Cmd[1]) of 'L': if SourceP.FileRead(Rest) then MainConfig.WriteString('Archivos', 'Fuente', Rest) else HelpP.FlashMessage(1, 'No encuentro: ' + Rest, 2000); 'F', 'R': DoRegisters(Rest); 'X': AllDone := true; else HelpP.FlashMessage(1, 'No conozco el comando: ' + Cmd, 2000); end; end; end; procedure Configuration; var NR, I: integer; S: string; begin S := MainConfig.ReadString('Archivos', 'Fuente', ''); if S <> '' then if not SourceP.FileRead(S) then HelpP.FlashMessage(1, 'Archivo '+S+' no existe', 2000); NR := MainConfig.ReadInteger('Registros', 'Numero', 0); for I := 1 to NR do begin S := MainConfig.ReadString('Registros', 'Reg'+HexB(I), ''); RegP.AddRegister(Field_Nr(S, ',', 1), Field_Nr(S, ',', 2)); end; end; begin MainConfig.Initialize('simpic.cfg'); InitInterface; Configuration; repeat Command; until AllDone; clrscr; end.