wuwuxin
Members-
Content Count
79 -
Joined
-
Last visited
-
Days Won
3
Everything posted by wuwuxin
-
Thanks again. I am novice to HTML/CSS - to help me jump start, do you think you can provide a little more details for ITEM 2/3, possibly with illustrative html/css sample?
-
If so, can I hide it?
-
@Alexander Sviridenkov Some further questions (sorry I am an HTML novice) -
-
I am sold. Now I am looking at how to order this component.
-
@Alexander Sviridenkov Wow! That is exactly I am looking for. This is HTML Component? Fantastic. After resizing, is it possible to get the size of each sub "cell"?
-
Thank you @Kas Ob. and @Pat Foley Actually I am trying to have the following result: The cells are "jagged", with the freedom to INDEPENDENTLY resize cell 1/2, cell 3/4, cell 5/6, and cell 7/8 Is this possible with TDrawGrid?
-
procedure TForm1.PythonEngine1SysPathInit(Sender: TObject; PathList: PPyObject); begin var v := PythonEngine1.PyObjectAsVariant(PathList); // Then what to do????? end; What is the correct way to add to SysPath?
-
To be exact, Py_Begin_Allow_Threads should be called inside PythonEngine.OnAfterInit event, NOT OnAfterLoad event as advised by @pyscripter. Otherwise, error will be thrown, because the gPythonEngine at this point is still nil. Py_End_Allow_Threads should NOT be called inside OnBeforeUnload event. If put inside OnBeforeUnload event, an access violation error will be thrown - because Py_Finialize will be called BEFORE OnBeforeUnload, thus would trigger an access violation error at the point where Py_Finalize is called, which is before firing OnBeforeUnload event. I think a new event OnBeforeFinalize should be added, to address this problem. @pyscripter What am I missing here?
-
OK. I found that in order to use Python4Delphi effectively, some knowledge of Python C API is needed, or at least you need to know where to look for answers. I didn't find useful information from this Forum but I googled and googled here is what I found out, in order to add a new entry to SysPath: procedure TForm1.PythonEngine1SysPathInit(Sender: TObject; PathList: PPyObject); begin var _folder: AnsiString := ExtractFilePath(Application.ExeName) + 'scripts'; var v := PythonEngine1.PyList_Append(PathList, PythonEngine1.Py_BuildValue('s', PAnsiChar(_folder))); end;
-
OK. After studying Python documentation https://docs.python.org/3/c-api/init.html I think I found the answer. Python internally has a thread-switching mechanism, controlled by sys.setswitchinterval. PyGILState_Ensure tries to get the GIL lock - which is blocking. It seems when the thread context is switched to the current thread, GIL lock held by a previously running thread will have already been (automatically) released, and the current running thread can get the GIL lock. So in that sense, PyGILState_Ensure is not blocking at all (i.e., with an actively running thread, it won't "block" since it can always get the GIL lock) - is my understanding correct?
-
I am still somewhat confused - if I call PyGILState_Ensure in one thread, will that block other threads calling PyGILState_Ensure? If I use your utility function IPyEngineAndGIL, do I still need to call TPythonThread.Py_Begin_Allow_Threads (calls PyEval_SaveThread) in the main thread, after loading the Python DLL? Thank you.
-
I am still somewhat confused - if I call PyGILState_Ensure in one thread, will that block other thread calling PyGILState_Ensure? If I use your utility function IPyEngineAndGIL, do I still need to call TPythonThread.Py_Begin_Allow_Threads (calls PyEval_SaveThread) in the main thread, after loading the Python DLL? Thank you.
-
C++ Builder bcc32c (Clang 32bit) cannot find symbol for inline function in DEBUG build
wuwuxin posted a topic in General Help
I have an inline function defined in a C file, lp_pricePSE.c INLINE MYBOOL applyPricer(lprec *lp) { int rule = get_piv_rule(lp); return( (MYBOOL) ((rule == PRICER_DEVEX) || (rule == PRICER_STEEPESTEDGE)) ); } C++ Builder bcc32c (Clang 32bit compiler), DEBUG build would give me the following error: [ilink32 Error] Error: Unresolved external '_applyPricer' referenced from C:\OBJ\WIN32\DEBUG\LP_PRICEPSE.OBJ However, if I use classic Borland Compiler bcc32, OR use bcc32c (i.e, the Clang 32 compiler) do RELEASE build, then the above problem won't happen. Is this a known issue, or there is something with bcc32ci (the Clang 32 bit compiler) that I set up wrong? @Remy Lebeau -
MMX would wrap code line (that exceeds the set max columns), but sometimes the wrapping is not very optimal, for example, function MyFooFooFunction(const AParam1: string; const AParam2: TObject; const AParam3: IInterface): TObject would be wrapped up as function MyFooFooFunction(const AParam1: string; const AParam2: TObject; const AParam3: IInterface): TObject or wrapped up as function MyFooFooFunction(const AParam1: string; const AParam2 : TObject; const AParam3: IInterface): TObject Ideally, I want to keep the parameter declaration intact, i.e., const AParam3: IInterface doesn't get "cut off" at const, or at ":". How can I do that?
-
1. The implementation of the function is wrapped wrongly: class function TMormotOrmFactory.CreateMormotOrm(const AParams: TMormotOrmParams; const ATables: TArray< TSQLRecordClass>; const ASchema: String; const AObsoleteSchemas: TArray<String>; const ACreateIndexProc: TMormotCreateIndexProc; const AStartupScript: String = ''): IMormotOrmFramework; 2. Not sure what it means. 3. Wrap margin is 118 4. Indent = 2
-
It seems the latest MMX improves the wrapping algorithm. But still it doesn't seem to be able to wrap generic param correctly: for example: ATables: TArray<TSQLRecordClass> can be wrapped as at the left bracket: ATables: TArray< TSQLRecordClass>
-
I am using Delphi 10.4.2, with latest patches, on Windows Server 2019. 32bit application, running in desktop mode. I am having strange access violation. It seems FastMM5 (with full debug mode) can not capture it. MadExcept can not capture it either. By "can not capture" - I meant - nothing is logged though the logs are enabled. The application is a multi-threaded application, and the access violation seems to happen randomly (i.e., I don't know when exactly it will happen, but usually the access violation takes a couple of hours to show up after the application is started, so I cannot really running the debugger and sit there for a couple of hours).... When the access violation happens, it disappeared from the desktop, but the access violation is logged by the Windows Event Viewer: Exception code: 0xc0000005 Fault offset: 0x0003d421 "Fault offset: 0x0003d421" seems to be the address somewhere inside the function System.SysUtils.CreateInOutError , as shown in the Figure below. Any advice or suggestions? @David Heffernan
-
Thank you very much. The application is running with admin account... But why it is an access violation? function CreateInOutError: EInOutError; type TErrorRec = record Code: Integer; Ident: string; end; const ErrorMap: array[0..6] of TErrorRec = ( (Code: 2; Ident: System.SysConst.SFileNotFound), (Code: 3; Ident: System.SysConst.SInvalidUnknownFilename), (Code: 4; Ident: System.SysConst.STooManyOpenFiles), (Code: 5; Ident: System.SysConst.SAccessDenied), (Code: 100; Ident: System.SysConst.SEndOfFile), (Code: 101; Ident: System.SysConst.SDiskFull), (Code: 106; Ident: System.SysConst.SInvalidInput)); var I: Integer; InOutRes: Integer; begin I := Low(ErrorMap); InOutRes := IOResult; // resets IOResult to zero while (I <= High(ErrorMap)) and (ErrorMap[I].Code <> InOutRes) do Inc(I); if I <= High(ErrorMap) then Result := EInOutError.Create(ErrorMap[I].Ident) else Result := EInOutError.CreateResFmt(@SInOutError, [InOutRes]); Result.ErrorCode := InOutRes; end;
-
Is it possible to work with PostgreSQL /PostGIS spatial database with Delphi? Any advice?
-
I used to use MySQL Enterprise (yes, I paid $5000/year, mainly for its ThreadPool plugin which is not available in community edition!). Then I switched to PostgreSQL in 2020. I never regret. My postgresql database has daily increment of 8 million records.
-
Is it possible to dynamically generate an editor GUI based on a data type class?
wuwuxin posted a topic in VCL
Is there any existing library or framework that can automatically (dynamically) generate an editor user interface for a user defined class? For example, TSex = (Male, Female); TMyFunkyDataType = class Name: String; // --- this will generate a text editor Sex: TSex; // --- this will generate a drop down box end; -
I rate myself as an "intermediate-level" Delphi programmer (as compared to the experts I found in this forum; I also use C/C++, .NET/C#/F#, FORTRAN). The following is the list of Dephi books that I've collected over the years. These are all great books by great writers - I'd like to thank them all for their books accompanying my Delphi journey over the years. For Learners: Inside Delphi 2006 (Ivan Hlandi) - the first Delphi book I read, by which I learned Delphi. I found this book very good for picking up Delphi. It covers not only Delphi but C++ Builder (for cross referencing Delphi features). Object Pascal Handbook (Marco Cantu, 2021) - classic, and continuously updated, with the latest one being for Sydney 10.4.2. Delphi XE2 Foundations (Chris Rolliston, 2012) - a well written book covering the Delphi language and other aspects. Comprehensive: Mastering Delphi 7 (Marco Cantu, 1996) - classic of the classics. Old but still relevant. Of all of Marco's books, I think his "Master Delphi XXX" series are really well written, impeccable text-book style. Expert Delphi (Pawel Glowacki, 2017) - another good Delphi book. Delphi Cookbook (Daniele Teti, 2018) - cookbook style, and good as a desktop reference to check out the tips occasionally. Delphi GUI Programming with FireMoney (Andrea Magni, 2021) - on the GUI programming using FMX, haven't finish reading it. Seems a comprehensive one. Delphi in a Nutshell (Ray Lischner, 2000) - my favorite book. Very well written, concise, and no non-sense. I like the "nutshell" style. I really hope Oreilly could update this book to the recent Delphi editions. For COM/ActiveX developing in Delphi: Delphi COM Programming (Eric Harmon, 2000) - the classic for Delphi COM programming. Oldie but goodie. A must-have if you are still doing COM programming. For Delphi Component Development: Delphi Component Design (Danny Thorpe, 1996) - the classic for component developers. Oldie but goodie. The author is Danny Thorpe after all. Even if you don't read it, you can save the book for the old times' sake. A nostalgic item to keep. Developing Custom Delphi 3 Components (Ray Konopka, 1997). Old, but still relevant. Well-written. For Database: Delphi in Depth - Client Dataset (Cary Jensen, 2014) - Not sure ClientDataSet is still a good option nowadays. But the book provides comprehensive coverage on ClientDataSet and its under-the-hood. Delphi in Depth - FireDAC (Cary Jensen, 2015) - a must-have if you want to learn FireDAC systematically. Introducing Delphi ORM (John Kouraklis, 2019) - An interesting little book about ORM, with a focus on TMS Aurelius. Enterprise Delphi Database with mORMot (Erick Engelke, 2016) - the only book on mORMot (except mORMot's own manual). Neither well-written, nor carefully proofread. It can be useful before driving you lunatic with the various typos, typesetting errors, or out-of-no-where examples. Still appreciate the book for being the only mORMot book, though. Multi-threading/Parallel Programming Parallel Programming with OmniTheadLibrary (Primoz Gabrijelcic, 2019) - A systematic book on the wonderful OmniThreadLibrary. Delphi Event-based and Asynchronously Programming (Dalija Prasnikar, 2020) - a very well written book on the subject. Design Patterns Hands on Design Patterns with Delphi (Primoz Gabrijelcic, 2019) - A very nice book of implementing various design patterns in Delphi. Coding in Delphi, More Coding in Delphi, Dependency Injection in Delphi (Nick Hodges, 2015) - the three books by Nick Hodges on implementing design patterns in Delphi. Primarily about the Spring4D. The books have a very enthusiastic writing style, together with a lot of filler jokes (not my style but I can appreciate Nick's enthusiasm trying to make things lighter and fun). MVVM in Delphi (John Kouralkis, 2016) - a book on implementing MVVM in Delphi. The first couple of chapters are quite academic but interesting. Delphi Performance/Memory Management/Algorithms Delphi High Performance (Primoz Gabrijelcic, 2018) - a fairly unique book on writing performant Delphi code. Delphi Memory Management (Dalija Prasnikar, 2018) - a very interesting book, well written too. Delphi Algorithms and Data Structures (Julian Bucknall, 2001) - A unique book on algorithms and data structures in Delphi language.
-
How to "correctly" pass an array to a C function
wuwuxin posted a topic in RTL and Delphi Object Pascal
I have a C DLL function, void FillArray(int* data, int num_element); from Delphi side, is the following caller code correct? var data: TArray<Integer>; SetLength(data, 100); FillArray(data, 100); Also, what would be the correct Delphi translation of the C function? Is the following correct? Should I use "const" or not? procedure FillArray(const data: TArray<Integer>; num_element: Integer); -
By the way -I bought your new book, and found it very well written. The writing style is probably the best (or one of the best) of all the Delphi technical writers whose book I've read. Last time I found such a good technical writer was Delphi in a Nutshell by Ray Lischner . I look forward to more of your books - or maybe you might want to update the Memory Management book considering now Delphi has a uniform memory manager?
-
How to "correctly" pass an array to a C function
wuwuxin replied to wuwuxin's topic in RTL and Delphi Object Pascal
Thank you very much for the advice.