JGMS 2 Posted 11 hours ago I studied Demo 17 to use it in my application. The following routine is what I made from it: Function TPyForm.VertaalMetPython(Var Arr : Variant; TaalCode : String; TaalNr : integer) : Boolean; VAR Mem : TStringList; begin Result := False; // Arr is created upfront with: Arr := VarArrayCreate([0, FDQ_comps.RecordCount-1, 0, 5], VarVariant), // and populated with variant data in a for loop: ... VarArrayPut(Arr, FDQ_comps.Fieldbyname('nederlands').AsVariant, [I, 0]) ...; // PythonModule1.Engine := PythonEngine1; // PythonModule1.ModuleName := 'Vertaal'; PythonModule1.SetVarFromVariant( 'PArr', Arr ); TRY Mem := TStringList.Create; With Mem DO begin Add('from deep_translator import GoogleTranslator'); Add('taalcode = "' + taalcode +'"'); Add('taalnr = ' + TaalNr.toString ); Add('for j in range(len(Vertaal.PArr)):'); Add(' translated = GoogleTranslator(source="nl", target=taalcode).translate(text= Vertaal.PArr[j, 0])' ); Add(' Vertaal.PArr[j, taalnr] = translated'); end; TRY PythonEngine1.ExecString( ansiString( Mem.text ) ); Arr := PythonModule1.GetVarAsVariant( 'PArr' ); Result := True; Except Result := False; END; FINALLY Mem.Free; END; end; The input array for Python is populated correctly with data, but Python doesn't give any sign of action. The array is returned empty and the Result value is set to True. What do I wrong? Please help. Share this post Link to post