Initial commit with my code directory
This commit is contained in:
		
							
								
								
									
										193
									
								
								code_JMW/UES.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										193
									
								
								code_JMW/UES.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,193 @@ | ||||
| unit UES; | ||||
|  | ||||
| interface | ||||
|  | ||||
| uses | ||||
|   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, | ||||
|   Dialogs, Menus, ExtCtrls,IniFiles, | ||||
|   UInit,UTest; | ||||
|  | ||||
| procedure Enregistrer; | ||||
| procedure Ouvrir; | ||||
|  | ||||
|  | ||||
| implementation | ||||
|  | ||||
| uses Unit1; | ||||
|  | ||||
|  | ||||
| procedure Enregistrer; | ||||
| var | ||||
|  F:TIniFile; | ||||
|  i:integer; | ||||
| begin | ||||
|   if Form1.SaveDialog.Execute then begin | ||||
|     F:=TIniFile.Create(Form1.SaveDialog.FileName); | ||||
|     F.WriteInteger('CP','R',Nb_Relais); | ||||
|     F.WriteInteger('CP','L',Nb_Lampe); | ||||
|     F.WriteInteger('CP','X',Nb_Connect); | ||||
|     F.WriteInteger('CP','C',Nb_Contact); | ||||
|     F.WriteInteger('CP','P',Nb_Compo); | ||||
|     F.WriteInteger('CP','S',Nb_Segment); | ||||
|     F.WriteInteger('CP','A',Nb_Alim); | ||||
|  | ||||
|     for i:=0 to Nb_Relais-1 do begin | ||||
|       F.WriteInteger('R'+IntToStr(i),'x',L_Relais[i].P.x); | ||||
|       F.WriteInteger('R'+IntToStr(i),'y',L_Relais[i].P.y); | ||||
|       F.WriteInteger('R'+IntToStr(i),'dx',L_Relais[i].Pd.X); | ||||
|       F.WriteInteger('R'+IntToStr(i),'dy',L_Relais[i].Pd.Y); | ||||
|       F.WriteInteger('R'+IntToStr(i),'t',L_Relais[i].tpr); | ||||
|       F.WriteString('R'+IntToStr(i),'m',L_Relais[i].modele); | ||||
|       F.WriteString('R'+IntToStr(i),'n',L_Relais[i].nom); | ||||
|       F.WriteBool('R'+IntToStr(i),'v',L_Relais[i].Visible); | ||||
|     end; | ||||
|  | ||||
|     for i:=0 to Nb_Lampe-1 do begin | ||||
|       F.WriteInteger('L'+IntToStr(i),'x',L_Lampe[i].P.x); | ||||
|       F.WriteInteger('L'+IntToStr(i),'y',L_Lampe[i].P.y); | ||||
|       F.WriteInteger('L'+IntToStr(i),'dx',L_Lampe[i].Pd.X); | ||||
|       F.WriteInteger('L'+IntToStr(i),'dy',L_Lampe[i].Pd.Y); | ||||
|       F.WriteInteger('L'+IntToStr(i),'C0',L_Lampe[i].Clr0); | ||||
|       F.WriteInteger('L'+IntToStr(i),'C1',L_Lampe[i].Clr1); | ||||
|       F.WriteString('L'+IntToStr(i),'m',L_Lampe[i].modele); | ||||
|       F.WriteString('L'+IntToStr(i),'n',L_Lampe[i].nom); | ||||
|       F.WriteBool('L'+IntToStr(i),'v',L_Lampe[i].Visible); | ||||
|     end; | ||||
|  | ||||
|  | ||||
|     for i:=0 to Nb_Connect-1 do begin | ||||
|       F.WriteInteger('X'+IntToStr(i),'x',L_Connect[i].P.X); | ||||
|       F.WriteInteger('X'+IntToStr(i),'y',L_Connect[i].P.Y); | ||||
|     end; | ||||
|  | ||||
|     for i:=0 to Nb_Contact-1 do begin | ||||
|       F.WriteInteger('C'+IntToStr(i),'x',L_Contact[i].P.x); | ||||
|       F.WriteInteger('C'+IntToStr(i),'y',L_Contact[i].P.y); | ||||
|       F.WriteString('C'+IntToStr(i),'m',L_Contact[i].modele); | ||||
|       F.WriteBool('C'+IntToStr(i),'i',L_Contact[i].EtatI); | ||||
|       F.WriteBool('C'+IntToStr(i),'j',L_Contact[i].Manuel); | ||||
|       F.WriteString('C'+IntToStr(i),'n',L_Contact[i].nom); | ||||
|       F.WriteBool('C'+IntToStr(i),'v',L_Contact[i].Visible); | ||||
|       F.WriteInteger('C'+IntToStr(i),'dx',L_Contact[i].Pd.X); | ||||
|       F.WriteInteger('C'+IntToStr(i),'dy',L_Contact[i].Pd.Y); | ||||
|     end; | ||||
|  | ||||
|     for i:=0 to Nb_Compo-1 do begin | ||||
|       F.WriteInteger('P'+IntToStr(i),'x',L_Compo[i].P.x); | ||||
|       F.WriteInteger('P'+IntToStr(i),'y',L_Compo[i].P.y); | ||||
|       F.WriteString('P'+IntToStr(i),'m',L_Compo[i].modele); | ||||
|     end; | ||||
|  | ||||
|     for i:=0 to Nb_Segment-1 do begin | ||||
|       F.WriteInteger('S'+IntToStr(i),'xa',L_Segment[i].P1.X); | ||||
|       F.WriteInteger('S'+IntToStr(i),'ya',L_Segment[i].P1.Y); | ||||
|       F.WriteInteger('S'+IntToStr(i),'xb',L_Segment[i].P2.X); | ||||
|       F.WriteInteger('S'+IntToStr(i),'yb',L_Segment[i].P2.Y); | ||||
|     end; | ||||
|  | ||||
|     for i:=0 to Nb_Alim-1 do begin | ||||
|       F.WriteInteger('A'+IntToStr(i),'x',L_Alim[i].P.x); | ||||
|       F.WriteInteger('A'+IntToStr(i),'y',L_Alim[i].P.y); | ||||
|       F.WriteString('A'+IntToStr(i),'m',L_Alim[i].modele); | ||||
|     end; | ||||
|  | ||||
|     F.Free; | ||||
|   end; | ||||
| end; | ||||
|  | ||||
|  | ||||
|  | ||||
| procedure Ouvrir; | ||||
| var | ||||
|  F:TIniFile; | ||||
|  i:integer; | ||||
| begin | ||||
|   if Form1.OpenDialog1.Execute then begin | ||||
|     Initialisation; | ||||
|     F:=TIniFile.Create(Form1.OpenDialog1.FileName); | ||||
|     Nb_Relais:=F.ReadInteger('CP','R',0); | ||||
|     Nb_Lampe:=F.ReadInteger('CP','L',0); | ||||
|     Nb_Connect:=F.ReadInteger('CP','X',0); | ||||
|     Nb_Contact:=F.ReadInteger('CP','C',0); | ||||
|     Nb_Compo:=F.ReadInteger('CP','P',0); | ||||
|     Nb_Segment:=F.ReadInteger('CP','S',0); | ||||
|     Nb_Alim:=F.ReadInteger('CP','A',0); | ||||
|  | ||||
|     SetLength(L_Relais,Nb_Relais); | ||||
|     for i:=0 to Nb_Relais-1 do begin | ||||
|       L_Relais[i].P.x:=F.ReadInteger('R'+IntToStr(i),'x',0); | ||||
|       L_Relais[i].P.y:=F.ReadInteger('R'+IntToStr(i),'y',0); | ||||
|       L_Relais[i].Pd.X:=F.ReadInteger('R'+IntToStr(i),'dx',0); | ||||
|       L_Relais[i].Pd.Y:=F.ReadInteger('R'+IntToStr(i),'dy',0); | ||||
|       L_Relais[i].tpr:=F.ReadInteger('R'+IntToStr(i),'t',0); | ||||
|       L_Relais[i].modele:=F.ReadString('R'+IntToStr(i),'m',''); | ||||
|       L_Relais[i].nom:=F.ReadString('R'+IntToStr(i),'n',''); | ||||
|       L_Relais[i].Visible:=F.ReadBool('R'+IntToStr(i),'v',false); | ||||
|     end; | ||||
|  | ||||
|     SetLength(L_Lampe,Nb_Lampe); | ||||
|     for i:=0 to Nb_Lampe-1 do begin | ||||
|       L_Lampe[i].P.x:=F.ReadInteger('L'+IntToStr(i),'x',0); | ||||
|       L_Lampe[i].P.y:=F.ReadInteger('L'+IntToStr(i),'y',0); | ||||
|       L_Lampe[i].Pd.X:=F.ReadInteger('L'+IntToStr(i),'dx',0); | ||||
|       L_Lampe[i].Pd.Y:=F.ReadInteger('L'+IntToStr(i),'dy',0); | ||||
|       L_Lampe[i].Clr0:=F.ReadInteger('L'+IntToStr(i),'C0',RGB(160,160,160)); | ||||
|       L_Lampe[i].Clr1:=F.ReadInteger('L'+IntToStr(i),'C1',RGB(255,0,0)); | ||||
|       L_Lampe[i].modele:=F.ReadString('L'+IntToStr(i),'m',''); | ||||
|       L_Lampe[i].nom:=F.ReadString('L'+IntToStr(i),'n',''); | ||||
|       L_Lampe[i].Visible:=F.ReadBool('L'+IntToStr(i),'v',false); | ||||
|     end; | ||||
|  | ||||
|  | ||||
|  | ||||
|     SetLength(L_Connect,Nb_Connect); | ||||
|     for i:=0 to Nb_Connect-1 do begin | ||||
|       L_Connect[i].P.X:=F.ReadInteger('X'+IntToStr(i),'x',0); | ||||
|       L_Connect[i].P.Y:=F.ReadInteger('X'+IntToStr(i),'y',0); | ||||
|     end; | ||||
|  | ||||
|     SetLength(L_Contact,Nb_Contact); | ||||
|     for i:=0 to Nb_Contact-1 do begin | ||||
|       L_Contact[i].P.x:=F.ReadInteger('C'+IntToStr(i),'x',0); | ||||
|       L_Contact[i].P.y:=F.ReadInteger('C'+IntToStr(i),'y',0); | ||||
|       L_Contact[i].modele:=F.ReadString('C'+IntToStr(i),'m',''); | ||||
|       L_Contact[i].EtatI:=F.ReadBool('C'+IntToStr(i),'i',false); | ||||
|       L_Contact[i].Manuel:=F.ReadBool('C'+IntToStr(i),'j',false); | ||||
|       L_Contact[i].nom:=F.ReadString('C'+IntToStr(i),'n',''); | ||||
|       L_Contact[i].Visible:=F.ReadBool('C'+IntToStr(i),'v',false); | ||||
|       L_Contact[i].Pd.X:=F.ReadInteger('C'+IntToStr(i),'dx',0); | ||||
|       L_Contact[i].Pd.Y:=F.ReadInteger('C'+IntToStr(i),'dy',0); | ||||
|       L_Contact[i].Select:=false; | ||||
|     end; | ||||
|  | ||||
|     SetLength(L_Compo,Nb_Compo); | ||||
|     for i:=0 to Nb_Compo-1 do begin | ||||
|       L_Compo[i].P.x:=F.ReadInteger('P'+IntToStr(i),'x',0); | ||||
|       L_Compo[i].P.y:=F.ReadInteger('P'+IntToStr(i),'y',0); | ||||
|       L_Compo[i].modele:=F.ReadString('P'+IntToStr(i),'m',''); | ||||
|     end; | ||||
|  | ||||
|  | ||||
|     SetLength(L_Segment,Nb_Segment); | ||||
|     for i:=0 to Nb_Segment-1 do begin | ||||
|       L_Segment[i].P1.X:=F.ReadInteger('S'+IntToStr(i),'xa',0); | ||||
|       L_Segment[i].P1.Y:=F.ReadInteger('S'+IntToStr(i),'ya',0); | ||||
|       L_Segment[i].P2.X:=F.ReadInteger('S'+IntToStr(i),'xb',0); | ||||
|       L_Segment[i].P2.Y:=F.ReadInteger('S'+IntToStr(i),'yb',0); | ||||
|     end; | ||||
|  | ||||
|     SetLength(L_Alim,Nb_Alim); | ||||
|     for i:=0 to Nb_Alim-1 do begin | ||||
|       L_Alim[i].P.x:=F.ReadInteger('A'+IntToStr(i),'x',0); | ||||
|       L_Alim[i].P.y:=F.ReadInteger('A'+IntToStr(i),'y',0); | ||||
|       L_Alim[i].modele:=F.ReadString('A'+IntToStr(i),'m',''); | ||||
|     end; | ||||
|  | ||||
|     F.Free; | ||||
|   end; | ||||
| end; | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| end. | ||||
		Reference in New Issue
	
	Block a user