المشاركات : 33
المواضيع 4
:
: 1
الإنتساب : Jan 2012
السلام عليكم
ما هى الطريقة البرمجيه لتنفيذ هذه العمليه .....
لدى ملف نصى txt يحتوى على مئات الاسطر
بهذا الشكل
00425997: mov edx, 0040D5F4h ; "2SC5406 1500 600 5 14 100 0.3 4 5 12 50 50 3 1.5 3 No TOP3E Horz Out Panasonic"
0042599C: add ecx, 00000244h
004259A2: call edi
004259A4: mov ecx, [esi+44h]
004259A7: mov edx, 0040D6F8h ; "2SC5406A 1500 600 5 14 100 0.3 4 5 12 1000 50 3 1.5 3 No TOP3E Horz Out Panasonic"
004259AC: add ecx, 00000248h
004259B2: call edi
004259B4: mov ecx, [esi+44h]
واريد حذف ما هو خارج علامتى التنصيص فما هى الطريقة البرمجيه لتنفيذ هذا الامر
وشكرا
المشاركات : 654
المواضيع 34
:
: 106
الإنتساب : Aug 2010
وعليكم السلام
هذا حل
PHP كود : function text_p(const text, stopdr: string): string; var I, P: Cardinal; SL: TStringList; begin Result := ''; SL := TStringList.Create; try SL.Text := text; for I := 0 to SL.Count - 1 do begin P := Pos(stopdr, SL[I]); if P > 0 then SL[I] := Copy(SL[I], 1, P-1); end; Result := SL.Text; finally SL.Free; end; end;
procedure TForm1.Button1Click(Sender: TObject); begin Memo2.Text := text_p(Memo1.Text, ';'); end;
سبحان الله وبحمده سبحان الله العظيم
المشاركات : 628
المواضيع 72
:
: 211
الإنتساب : Jun 2010
14-01-2016, 02:19 PM
(آخر تعديل لهذه المشاركة: 14-01-2016, 02:20 PM بواسطة لؤي.)
السلام عليكم
جرب هذه الوظيفة:
PHP كود : procedure RemoveLinesContaining(const fileName, searchText: string); var sl: TStringList; i: Integer; begin sl := TStringList.Create; try sl.LoadFromFile(fileName); for i := sl.Count-1 downto 0 do if Pos(searchText, sl[i])<>0 then sl.Delete(i); sl.SaveToFile(fileName); finally sl.Free; end; end; procedure TForm1.BitBtn1Click(Sender: TObject); begin RemoveLinesContaining('C:\My file.log','Try Me'); end;
أدبني الدهر فأراني نقص عقلي وإذا ما ازددت علما زادني علما بجهلي
المشاركات : 33
المواضيع 4
:
: 1
الإنتساب : Jan 2012
(14-01-2016, 02:15 PM)Agmcz كتب : وعليكم السلام
هذا حل
PHP كود : function text_p(const text, stopdr: string): string; var I, P: Cardinal; SL: TStringList; begin Result := ''; SL := TStringList.Create; try SL.Text := text; for I := 0 to SL.Count - 1 do begin P := Pos(stopdr, SL[I]); if P > 0 then SL[I] := Copy(SL[I], 1, P-1); end; Result := SL.Text; finally SL.Free; end; end;
procedure TForm1.Button1Click(Sender: TObject); begin Memo2.Text := text_p(Memo1.Text, '"'); end;
وعليكم السلام
جربت هذا الكود ولكنه نسخ النص قبل علامة التنصيص من أول كل سطر فقط الى Memo2
والمطلوب هو نسخ النص الموجود داخل علامة التنصيص (") فقط وتجاهل باقى النصوص
المشاركات : 654
المواضيع 34
:
: 106
الإنتساب : Aug 2010
هكذا
PHP كود : function Copy_Comment(const Text_File, Start, Stop: string): string; var I, P1, P2: Cardinal; SL, SL2: TStringList; begin Result := ''; if Text_File = '' then Exit; SL := TStringList.Create; SL2 := TStringList.Create; try if FileExists(Text_File) then SL.LoadFromFile(Text_File) else SL.Text := Text_File; for I := 0 to SL.Count - 1 do begin P1 := Pos(Start, SL[I]); P2 := Pos(Stop, Copy(SL[I], P1+1, Length(SL[I]))); if (P1 > 0) and (P2 > 0) then SL2.Add(Copy(SL[I], P1+1, P2-1)); end; Result := SL2.Text; finally SL.Free; SL2.Free; end; end;
procedure TForm1.Button1Click(Sender: TObject); begin //Memo2.Text := Copy_Des('C:\MyFile.txt', '"', '"'); load from file // or Memo2.Text := Copy_Des(Memo1.Text, '"', '"'); //load from string end;
سبحان الله وبحمده سبحان الله العظيم
المشاركات : 33
المواضيع 4
:
: 1
الإنتساب : Jan 2012
14-01-2016, 09:37 PM
(14-01-2016, 08:05 PM)Agmcz كتب : هكذا
PHP كود : function Copy_Comment(const Text_File, Start, Stop: string): string; var I, P1, P2: Cardinal; SL, SL2: TStringList; begin Result := ''; if Text_File = '' then Exit; SL := TStringList.Create; SL2 := TStringList.Create; try if FileExists(Text_File) then SL.LoadFromFile(Text_File) else SL.Text := Text_File; for I := 0 to SL.Count - 1 do begin P1 := Pos(Start, SL[I]); P2 := Pos(Stop, Copy(SL[I], P1+1, Length(SL[I]))); if (P1 > 0) and (P2 > 0) then SL2.Add(Copy(SL[I], P1+1, P2-1)); end; Result := SL2.Text; finally SL.Free; SL2.Free; end; end;
procedure TForm1.Button1Click(Sender: TObject); begin //Memo2.Text := Copy_Des('C:\MyFile.txt', '"', '"'); load from file // or Memo2.Text := Copy_Des(Memo1.Text, '"', '"'); //load from string end;
السلام عليكم
أصبت أخى .... جزاك الله خيرااا
هذا الكود ناجح 100% وتم اختزال كل ما هو بين علامتى التنصيص
جعله الله فى ميزان حسناتك
|