Einzelnen Beitrag anzeigen

Benutzerbild von Harry Stahl
Harry Stahl

Registriert seit: 2. Apr 2004
Ort: Bonn
2.479 Beiträge
 
Delphi 11 Alexandria
 
#1

Programme bzw. Funktionen von KI schreiben lassen (OpenAI)

  Alt 14. Dez 2022, 22:28
Wow, habt Ihr schon mal ChatGTP ausprobiert?
(Man muss da leider einen Account anlegen, um das ausprobieren zu können).

Auf meine Aufforderung

"Write a function in Delphi pascal that adds to a netto value a tax value"

Gibt er mir das zurück:
Delphi-Quellcode:
Function AddTax(Netto : Real; Tax : Real) : Real;
Begin
  Result := Netto + (Netto * Tax);
End;
Weitere Beispiele:

"Write a function in Delphi pascal, that loads a textfile into a TMemo"

This is an example of how to use the LoadFromFile procedure to load a text file into a TMemo.

Delphi-Quellcode:
procedure LoadTextFileToMemo(const FileName: string; Memo: TMemo);
begin
  Memo.Lines.LoadFromFile(FileName);
end;
"Write a function in Delphi pascal, that shows a messagedialog with "yes", "no" and "cancel" buttons"

The following code shows a message dialog with "Yes", "No" and "Cancel" buttons:
Delphi-Quellcode:
function ShowYesNoCancelDialog(const Msg: string): Integer;
begin
  Result := MessageDlg(Msg, mtConfirmation, [mbYes, mbNo, mbCancel], 0);
end;
Wohin das wohl führen mag...?

Ich bin über dieses Video darauf gestoßen, das zeigt, dass noch sehr viel mehr geht: https://youtu.be/HtuXjfqwGPE?t=164

Interessanterweise liefert die KI wohl oft unterschiedliche Ergebnisse, wenn man die Frage öfter stellt.

Bei der zweiten Abfrage hier hat die KI sogar eine Art Bereichsprüfung eingebaut (also count > 0 usw):

"Write a function in Delphi pascal with firemonkey that exchanges two items in a Tlistbox"

Delphi-Quellcode:
procedure ExchangeItems(listBox : TListBox; index1, index2 : Integer);
var
  temp : String;
begin
  if (index1 <> index2) and (index1 >= 0) and (index1 < listBox.Count)
     and (index2 >= 0) and (index2 < listBox.Count) then
  begin
    temp := listBox.Items[index1];
    listBox.Items[index1] := listBox.Items[index2];
    listBox.Items[index2] := temp;
  end;
end;

Geändert von Harry Stahl (14. Dez 2022 um 23:50 Uhr)
  Mit Zitat antworten Zitat