Arsip: [help] - Check Filename in String

 
user image
more 16 years ago

rydz™

Hello there.. Anyone can help me to copy some string data as example below : Var S:String; Begin S:= ' saya.jpg anda.png '; End; A question is, how to search in a S,string to get filename .jpg and .png ? and finally we display two result data? Result: saya.jpg anda.png
user image
more 16 years ago

n3o_cybertech

weleh pake B.inggris segala, gak pinter neh gue B.Inggris jadi neh deh tak coba jawab aja :

procedure FetchString(s: string ; sResult: TListBox);
var
    i: integer;
    slTemp: TStrings;
begin
slTemp := TstringList.Create;
try
//tangkap delimiter spasi sebagai kuncinya dengan metode perulangan terbalik (var n ke 1)
for i := Length(s) downto 1 do
  begin
    if s[i] = ' ' then
      begin
        slTemp.Add(Trim(Copy(s,i,Length(s))));
        s := Copy(s,1,i);
      end;
    if i = 1 then
      slTemp.Add(Copy(s,i,Length(s)));
  end;
//dibalik hasilnya biar urut sesuai yang diinputkan
for i:=slTemp.Count - 1 downto 0 do
  sResult.Items.Add(slTemp[i])
finally
slTemp.Free;
end;
end;
kode di atas gak hanya mecah menjadi 2 kalimat tetapi 100 kalimat pun bisa dengan syarat karakter spasi dianggap sebagai awal kalimat. semoga membantu...
user image
more 16 years ago

n3o_cybertech

Ooops...kelupaan, cara pakenya gini neh :

ListBox1.Items.Clear;
FetchString('saya.jpg anda.png mereka.gif semua.bmp kalian.tiff delphi.ico delphi-id.oke',ListBox1);
user image
more 16 years ago

rydz™

Thanks a lot to <n3o_cybertech>, i`m really apreciate it
user image
more 16 years ago

mas_kofa

kalo gini gmn???

for i := 1 to length(s) do
if s[i] = ' ' then s[i] :=#13;
lebih gampang khan???
user image
more 16 years ago

n3o_cybertech

@mas_kofa : xixixi...gak kepikiran ampe situ...
user image
more 16 years ago

ImanD

@mas_kofa: kalo gini gmn???

for i := 1 to length(s) do
if s[i] = ' ' then s[i] :=#13;
lebih gampang khan???
klo hasil S di tampilkan misal di TMemo jadinya saya.jpg dan anda.png masih 1result atw masih 1baris klo gini gmn??

uses 
  StrUtils;
begin
  S:=AnsiReplaceStr(S,' ',#13#10);
end;
peace !!
user image
more 16 years ago

mas_kofa

@Iman D
klo hasil S di tampilkan misal di TMemo jadinya saya.jpg dan anda.png masih 1result atw masih 1baris
ah masa.......????? [image]http://danahibah.net/images/ahmasa.jpg[/image]
user image
more 16 years ago

mas_kofa

pake memo.lines.text := s; bukan memo.text := s;
user image
more 16 years ago

ImanD

@mas_kofa dikau u/ nampilinnya kan pke misal Memo1.Lines.Text:=S; coba pke peintah ini Memo1.Text:=S; klo koding kan bebas mo berXpresi apapun terserah si tukang codingnya dia maunyo apo!
more ...
  • Pages:
  • 1
  • 2
Share to

AI Forward

🚀 We're thrilled to partner with Alibaba Cloud for "AI Forward - Alibaba Cloud Global Developer Summit 2025" in Jakarta! Join us and explore the future of AI. Register now: https://int.alibabacloud.com/m/1000400772/
#AlibabaCloud #DeveloperSummit #Jakarta #AIFORWARD

Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com