case of with string
#1
السلام عليكم ورحمة الله
في Lazarus fpc 2.6.0
كود :
procedure TForm1.Button1Click(Sender: TObject); begin case edit1.Text of 'one': caption := 'one'; '111': caption := '1'; end; end;
في دلفي
كود :
function CaseOfString(s: string; a: array of string): Integer; begin  Result := 0;  while (Result < Length(a)) and (a[Result] <> s) do    Inc(Result);  if a[Result] <> s then    Result := -1; end; procedure TForm1.Button1Click(Sender: TObject); begin  case CaseOfString(Edit1.Text, ['42', '23', 'nerd alert', 'hello world']) of    0: Label1.Caption := 'What is ?';    1: Label1.Caption := 'Tow';    2: Label1.Caption := 'yes';    3: Label1.Caption := 'Hello';    else      Label1.Caption := '?';  end; end;
لأستهلنّ الصعب أو أدرك المنى    فما انقادت الآمال إلاّ لصابر
[-] كل من 5 users say قال شكرا ل mobile على المشاركة المفيدة
  • محمد عبد العزيز, nadire1946, S.FATEH, h-farid, Delphi4Us
الرد


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم