Jump to content

FranzB

Members
  • Content Count

    55
  • Joined

  • Last visited

Posts posted by FranzB


  1. I create a  working folder with  this  statement

    workingpath  : String; 
    myfolder : String;
    
    /// example 
    workingpath  :='\\myserver\username\options\process\'; 
    myfolder := 'Runme\results\txt\';
    
    ForceDirectories  ( workingpath  +  myfolder);

     

    after completing my work I want to  delete  everything  in myfolder , keep  workingpath  untouched

    Any good inverse  function ?


  2. can I start Jupyter Notebooks using P4D components ? 

    P4D is installed,  can this be done with Delphi code  or / and python code 

     

     

    what I need 

     

    a) check if notebook is available on  my computer   

     

    c) start a  new notebook 

     

     

     

    regarding a)

    pip install notebook
    

    regarding b)

    jupyter notebook

     

     


  3. would like to understand the difference  in the uses statement between uses System.Types;   vs. uses Types;

     

    After a long time I need to recompile an application which has already been successfully compiled for the LINUX OS.

    Today the compiler claims  I need to change  from Types only to system.Types  . This is basically not a  big deal but I want to understand why  this  happened.

     

    my unit scope names are definded as :  FMX;Winapi;System;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win   

     

     

     

     


  4. we use a JENKINS build server ,  JENKINS works with Delphi  via MSBuild option  (I guess .... ) . 

    As a software developer in my case , I must supply   path to  project ,   projectfile (*.dproj) and .optset file for generation of or executeables.

     

    My first  idea fails to  create two separate *.optset files for VCL and FMX framework as the supply  for the unit scope names via  different  *.optset files is not working 

     

    FXM : FMX;Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;System;Xml;Data;Datasnap;Web;Soap 

    VCL :  VCL;Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;System;Xml;Data;Datasnap;Web;Soap

     

        

    the source code  of my dll  is here mydllproject.dpr   ( as for all of us 🙂 ) . 

    I don't want to create 2 different source code versions  with the identical source code  , just to have different *.dpr *.dproj and  *.optset  files 


  5. I want to compile  one project with 2 totally different compiler  settings/options , one version goes to the VCL  - the other to the FMX framework etc...

    What is the  role of project file and optset file? 

    Unit scope names are only defined in the project file , but I need to  exchange it using the  optset file while  compiling for the  other framework.

     

     


  6. I want to compile this test code below  for regular expressions, but none uses option works for me ... 

     

    error 

     

    [dcc32 Fatal Error] ..... .pas(10): F2613 Unit 'System.Generics.Collections.TArray' not found.

     

     

    uses
      System.SysUtils, System.Types, System.UITypes, System.Classes,
      System.Variants,
      FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Memo.Types,
      FMX.StdCtrls, FMX.ScrollBox, FMX.Memo, FMX.Controls.Presentation, FMX.Edit,
     // System.Generics.Collections.TArray,
     // System.TArray,
      System.RegularExpressions;;
    
    
    
    
    
    .....
    
    procedure TForm2.Button_evalregexpressionsClick(Sender: TObject);
    var
      regex: string;
      analysistxt: string;
    
      list: TArray<string>;
      item: String;
    
    begin
      regex := Edit_regexp.Text;
      analysistxt := Edit_analysisText.Text;
    
      list := TRegEx.Split(analysistxt, regex);
      for item in list do
      begin
        ShowMessage(item);
      end;
    
    end;
    
    end.

     


  7. MyWord is the string i want to extract, in the brackets come a list of numbers  or strings 

    LongList ( 1,2,3,4,5)
    
    Towns ( Paris, London, NY,  Berlin)

     

     

    later I also need to extract the  text between the brackets  and need to port this code  to delphi 

     

    txt = "Town (my) simple test";
    reg = /((.*))/;
    Ausgabe = txt.match(reg);

     

     

     


  8. I use this  code  below to read an integer value  from an database

     

     

      aObject.IntValue := Fieldbyname('IntegerField').AsInteger;

     

     

    my code is functional, if there is an integer value stored.  

    Reading an  " "  empty field I get an exception failure. 

    What is the  best coding style to  avoid  this error  in an application ?  

     


  9. still no luck, compiling this code .... 

     

       TDialogService.MessageDialog('You want to  ........ ',
        TMsgDlgType.mtConfirmation, mbYesNo,  TMsgDlgBtn.mbNo,  nil,
        procedure(const aResult: TModalResult)
        begin
          if (aResult = mrYes) then
          begin
            // Write code here for pressing button OK
            // ......
            Label_Statusbar.Text := ' -> done ';
          end
          else
          begin
            // Write code here for pressing button NO
            // ......
            Label_Statusbar.Text := '  -> canceled ';
          end;
        end );


  10. Delphin 10.4  does not compile this code ,  but to my understanding this  is a correct set of parameters calling  MessageDialog  FMX version 

     

     

    TDialogService.MessageDialog('You want to  ........ ',
        TMsgDlgType.mtConfirmation, TMsgDlgBtn.mbYes,  TMsgDlgBtn.mbNo,  nil,
        procedure(const aResult: TModalResult)
        begin
          if (aResult = mrYes) then
          begin
            // Write code here for pressing button OK
            ......
            Label_Statusbar.Text := ' -> done ';
          end
          else
          begin
            // Write code here for pressing button NO

           ......
            Label_Statusbar.Text := '  -> canceled ';
          end;
        end );

    end;


  11. I found this  post  here 

     

    How popular is Pascal/Delphi in 2019

     

    and did not  know this :

     

    Quote

    Microsoft also planted Delphi-countermeasures in its operating system to detect and randomly crash Delphi applications

     

    with a  link .

     

    https://www.quora.com/How-popular-is-Pascal-Delphi-in-2019-and-how-big-are-its-capabilities-compared-to-other-languages 

     

     

    Is this still  true  in 2021  ?


  12. I'm using  delphi4python  components  with an app where I can define all config  parameters  by an ini  file  as given here   

     

     

     

    How to get  the config data  in windows is explained here : https://github.com/pyscripter/python4delphi/wiki/FindingPython  found this  on windows as show above 🙂 

     

     

    my  problem,  I found only  working  parameter set for RED HAT 7,  but can't find the settings  for ubuntu , any help - parameter set  possible  ? 


  13. good news  :   changed the code  according  your help  and  also created  new *.ini file -> text is written to output file  now 🙂

     

    bad news :  its difficult to find the correct parameter settings on a client computer system - there are  to many  options where python might be installed ......    https://github.com/pyscripter/python4delphi/wiki/FindingPython

     

     

    action : improve finding and setting of correct parameters ..... otherwise an app won't run on a different computer 

     

     

     

    procedure TPythonEngineConfig.SetPythonengineValues(PythonEngine
      : TPythonEngine);
    var
      FPyVersions: TPythonVersions;
    begin
      ///
      /// convert this  https://github.com/pyscripter/python4delphi/wiki/FindingPython
      /// into a small  automatic setting  of parameter
      ///
      PythonEngine.UseLastKnownVersion := Self.UseLastKnownVersion;
      if Self.UseLastKnownVersion then
      begin
    {$IFDEF  MSWINDOWS}
        FPyVersions := GetRegisteredPythonVersions;
        FPyVersions[0].AssignTo(PythonEngine);
    {$ENDIF}
    {$IFDEF  LINUX}
        /// see https://en.delphipraxis.net/topic/4700-getregisteredpythonversions-for-linux/
    {$ENDIF}
      end
      else
      begin
        PythonEngine.DllName := Self.DllName;
        PythonEngine.DllPath := Self.DllPath;
        PythonEngine.AutoFinalize := Self.AutoFinalize;
        PythonEngine.AutoLoad := Self.AutoLoad;
        PythonEngine.AutoUnload := Self.AutoUnload;
        PythonEngine.RedirectIO := Self.RedirectIO;
        PythonEngine.UseWindowsConsole := Self.UseWindowsConsole;
      end;
    end;

     

     

     

     

     

    demo project

     

    demopython34config.fmx

    demopython34config.pas

    P4Ddemo34Config.dpr

     

     

    screen dumps.

     

    fail.PNG

     

    pass.PNG


  14. yes,  tried debugging 

    function TForm_P4Deval.PythonInputOutputSendUniData(Sender: TObject);   is never called ,  even I assigned this function  during the create components function 

    for data output. 

    I'm using FMX framework and lastest Delphi 10.4.2  , full working code is attached  below 

     

        FPythonInOut.UnicodeIO := True;
        FPythonInOut.RawOutput := True;
        FPythonInOut.OnSendUniData := PythonInputOutputSendUniData;
    
    
    {$IFDEF  MSWINDOWS}
        FPyVersions := GetRegisteredPythonVersions;
        FPyVersions[0].AssignTo(FPythonEngine);
    {$ENDIF}
    
        FPythonEngineConfig.SetPythonengineValues(FPythonEngine);
    
        FPythonEngine.Loaddll;
        FPythonEngine.IO := FPythonInOut;

     

    Capture_start_demo.PNG

    Config_windows.ini

    demopython34config.fmx

    demopython34config.pas

    P4Ddemo34Config.dpr


  15. I still  need a helping hand  on one  failure  of the demo34Extend sample 

     

    Q :  why  is  python text output   not written to  the  output memo in Delphi app,  python engine  for sure is running, see  post above 

     

    Capture_windows_output.PNG

     

     

    procedure TForm_P4Deval.btn_CreatePythonEnviromentClick(Sender: TObject);
    
    begin
    
      //  run this function prior to execute python code
    
      FPythonEngine := TPythonEngine.Create(nil);
      FPythonInOut := TPythonInputOutput.Create(nil);
    
    
      try
    
        FPythonInOut.UnicodeIO := True;
        FPythonInOut.RawOutput := True;
        FPythonInOut.OnSendUniData := PythonInputOutputSendUniData;
    
    
    {$IFDEF  MSWINDOWS}
        FPyVersions := GetRegisteredPythonVersions;
        FPyVersions[0].AssignTo(FPythonEngine);
    {$ENDIF}
    
        FPythonEngineConfig.SetPythonengineValues(FPythonEngine);
    
        FPythonEngine.Loaddll;
        FPythonEngine.IO := FPythonInOut;
    
    
    
        { TPythonModule }
        FPythonModule1 := TPythonModule.Create(Self);
    
        FPythonModule1.Name := 'PythonModule1';
        FPythonModule1.Engine := FPythonEngine;
        FPythonModule1.ModuleName := 'spam';
        with FPythonModule1.Errors.Add do
        begin
          Name := 'PointError';
          ErrorType := etClass;
        end;
        with FPythonModule1.Errors.Add do
        begin
          Name := 'EBadPoint';
          ErrorType := etClass;
          ParentClass.Name := 'PointError';
        end;
    
      except
        on E: Exception do
          writeln(E.ClassName, ': ', E.Message);
    
      end;
    end;
    
    procedure TForm_P4Deval.btn_FreePythonEnviromentClick(Sender: TObject);
    begin
    
      FPythonEngine.Free;
      FPythonInOut.Free;
    
    end;

     

     

     

     

     

     

     

     

     

     

    Config_windows.ini

    demopython34config.fmx

    demopython34config.pas

    P4Ddemo34Config.dpr


  16. yes , here comes a  numpy short demo on windows ....  execution is perfect 

    I installed  numpy via  pip , did  not need  to set a  DLL path 

    see screen dump 

    (on LINUX i don't have admin rights to install software using pip, will report results  later - need other LINUX computer )

     

    #  demo script
    import matplotlib.pyplot as plt
    import numpy as np
    x = np.arange(0,8*np.pi,0.1)   # start,stop,step
    y = np.cos(x) *1/(1+x)
    plt.plot(x,y)
    plt.show()

     

    Capture_windows_numpy.PNG

×