Merhaba;
Bu kod bloğunda RestRequest.Execute edildikten sonra eğer ulaşılmak istenen dosya belirtilen yolda yok ise kodu nasıl durdurup;
json := RESTResponse1.JSONText;
Bu satıra devam etmemesini sağlayabilirim.
Teşekkürler
Dosya olmadığı için execute bölümünde hata veriyor try-except-end bloğuna alsam bile yine hata mesajı çıkıyor ve satıra normal işleyişiyle devam ediyor.
procedure TForm1.Button4Click(Sender: TObject);
var
Hatirla,SL_SonucIOS,json: string;
i,sayi : integer;
obj : TJSONObject;
data,detail : TJSONValue;
toplam,dettoplam : TJSONArray;
begin
RESTClient1.BaseURL := 'http://cihankoca.com.tr/hatirla';
RESTRequest1.Resource := 'Hatirla.json';
RESTRequest1.Execute;
json := RESTResponse1.JSONText;
obj := TJSONObject.ParseJSONValue(json) as TJSONObject;
try
data := obj.ParseJSONValue(json);
data := (data as TJSONObject).Get('data').JSONValue;
toplam := obj.GetValue('data') as TJSONArray;
if toplam.Count >= 1 then
begin
for I := 0 to toplam.Count-1 do
begin
if ((data as TJSONArray).Items[i] as TJSonObject).Get('Form').JSONValue.Value = 'AnaMenu' then
begin
if ((data as TJSONArray).Items[i] as TJSonObject).Get('Baslik').JSONValue.Value = 'Beni Hatirla' then
begin
Hatirla := ((data as TJSONArray).Items[i] as TJSonObject).Get('Deger').JSONValue.Value;
end;
end;
end;
if Hatirla = '1' then
begin
CheckBox1.IsChecked := True;
for I := 0 to toplam.Count-1 do
begin
if ((data as TJSONArray).Items[i] as TJSonObject).Get('Form').JSONValue.Value = 'AnaMenu' then
begin
if ((data as TJSONArray).Items[i] as TJSonObject).Get('Baslik').JSONValue.Value = 'Sunucu' then
begin
Edit1.Text := ((data as TJSONArray).Items[i] as TJSonObject).Get('Deger').JSONValue.Value;
end;
if ((data as TJSONArray).Items[i] as TJSonObject).Get('Baslik').JSONValue.Value = 'Kullanici' then
begin
Edit2.Text := ((data as TJSONArray).Items[i] as TJSonObject).Get('Deger').JSONValue.Value;
end;
end;
end;
end
else CheckBox1.IsChecked := False;
end;
finally
obj.Free;
end;
end;
Bu kod bloğunda RestRequest.Execute edildikten sonra eğer ulaşılmak istenen dosya belirtilen yolda yok ise kodu nasıl durdurup;
json := RESTResponse1.JSONText;
Bu satıra devam etmemesini sağlayabilirim.
Teşekkürler
(27-11-2020, Saat: 16:48)cihankoca Adlı Kullanıcıdan Alıntı: Merhaba;
procedure TForm1.Button4Click(Sender: TObject); var Hatirla,SL_SonucIOS,json: string; i,sayi : integer; obj : TJSONObject; data,detail : TJSONValue; toplam,dettoplam : TJSONArray; begin RESTClient1.BaseURL := 'http://cihankoca.com.tr/hatirla'; RESTRequest1.Resource := 'Hatirla.json'; RESTRequest1.Execute; json := RESTResponse1.JSONText; obj := TJSONObject.ParseJSONValue(json) as TJSONObject; try data := obj.ParseJSONValue(json); data := (data as TJSONObject).Get('data').JSONValue; toplam := obj.GetValue('data') as TJSONArray; if toplam.Count >= 1 then begin for I := 0 to toplam.Count-1 do begin if ((data as TJSONArray).Items[i] as TJSonObject).Get('Form').JSONValue.Value = 'AnaMenu' then begin if ((data as TJSONArray).Items[i] as TJSonObject).Get('Baslik').JSONValue.Value = 'Beni Hatirla' then begin Hatirla := ((data as TJSONArray).Items[i] as TJSonObject).Get('Deger').JSONValue.Value; end; end; end; if Hatirla = '1' then begin CheckBox1.IsChecked := True; for I := 0 to toplam.Count-1 do begin if ((data as TJSONArray).Items[i] as TJSonObject).Get('Form').JSONValue.Value = 'AnaMenu' then begin if ((data as TJSONArray).Items[i] as TJSonObject).Get('Baslik').JSONValue.Value = 'Sunucu' then begin Edit1.Text := ((data as TJSONArray).Items[i] as TJSonObject).Get('Deger').JSONValue.Value; end; if ((data as TJSONArray).Items[i] as TJSonObject).Get('Baslik').JSONValue.Value = 'Kullanici' then begin Edit2.Text := ((data as TJSONArray).Items[i] as TJSonObject).Get('Deger').JSONValue.Value; end; end; end; end else CheckBox1.IsChecked := False; end; finally obj.Free; end; end;
Bu kod bloğunda RestRequest.Execute edildikten sonra eğer ulaşılmak istenen dosya belirtilen yolda yok ise kodu nasıl durdurup;
json := RESTResponse1.JSONText;
Bu satıra devam etmemesini sağlayabilirim.
Teşekkürler
Dosya olmadığı için execute bölümünde hata veriyor try-except-end bloğuna alsam bile yine hata mesajı çıkıyor ve satıra normal işleyişiyle devam ediyor.

