Typhoon relational database lazarus / 63-Database ---------------------------------------------------------------------- funlw65 · 2022-01-22 13:55 Update: Now ty.pas got it's own repository at gitlab. https://gitlab.com/funlw65/typhoon-pas The following changes were made: - ty.pas unit got reworked to accept static or dynamic/shared libraries. By default, it will include the static library - you have to define TYPHOON_STATIC before including ty unit in your main program; - the graphical application and the raylib units were removed; - the tytest.pas console app got reworked to be a little more useful; - the README.md file is now, hopefully, more comprehensive. Original Post: This is a little precious database engine (you will agree with me if you read de docs) written in C language. I used it many years ago in a project, then forgot about it. Nowadays I'm glad to find out that it still compiles ok in a Linux environment (Debian 10 and derivatives and gcc 8.3.0) So I wrote a quick database application to test it and to familiarize myself also with raylib/raygui graphical libraries. A small pigeon breeds database, which can be downloaded and tested from here: https://gitlab.com/funlw65/squabdb-c The README.md contains a screenshot of the main form of the application and links to the C libraries used. So, I started converting the app in FreePascal language, and it seems that the typhoon database can be easily converted/interfaced for Pascal using h2pas utility. Well, I'm not expert on this matter and there still are two functions that I was not able to translate them, but it will not affect the project. ---------------------------------------------------------------------- Zvoni · 2022-01-24 08:25 For completeness sake (untested!) Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Type  TProcKeyBuild:Procedure (_para1:Pchar; _para2:longword; _para3:longword);  TProcSetErr  :Procedure (_para1:longint; _para2:longint); //Function d_keybuild(_para1:Procedure (_para1:Pchar; _para2:longword; _para3:longword)): integer;cdecl;external cDllName;Function d_keybuild(_para1:TProcKeyBuild): integer;cdecl;external cDllName; //Function d_seterrfn(_para1:Procedure (_para1:longint; _para2:longint)): integer;cdecl;external cDllName;Function d_seterrfn(_para1:TProcSetErr): integer;cdecl;external cDllName; But i'm weary of this conversion in general. Use ctypes for conversions ---------------------------------------------------------------------- funlw65 · 2022-01-26 19:10 Thank you Zvoni, I appreciate! I had some things to do, but done now and I will start in translating the app to pascal. Actually, most of it is done, as I wrote it for the qdbm database first, hit some walls then translated the pascal app in C, then in the end changed the database engine to typhoon and now back to pascal ---------------------------------------------------------------------- funlw65 · 2022-02-03 05:04 Done! Not fully tested, but I think is ok. https://gitlab.com/funlw65/squabdb-pas Inside the code is a little useful "gadget", deactivated as a comment The app comes with two themes, dark and light. ---------------------------------------------------------------------- Roland57 · 2022-02-03 07:33 Very interesting.  I could compile and run successfully the C demo (with the static lib, on Linux Mageia). Very nice! (By the way, it was very easy to install raylib.) For the Pascal demo, I have to find how to build libtyphoon.so. Could you share the binary, or explain how you built it? ---------------------------------------------------------------------- Zvoni · 2022-02-03 07:45 Again reminding the OP: Use Ctypes for the bindings! You might get lucky that the native Pascal-Types are correct for your intended Target, another User trying to use it for a different target might start a nuclear rocket in North Korea ---------------------------------------------------------------------- funlw65 · 2022-02-03 15:04 Quote from: Zvoni on February 03, 2022, 08:45:51 amAgain reminding the OP: Use Ctypes for the bindings! You might get lucky that the native Pascal-Types are correct for your intended Target, another User trying to use it for a different target might start a nuclear rocket in North Korea Hi Zvoni, I have yet to learn what and how to do that ... I said I am not skilled in this. If I awakened some interest in typhoon database, then than would be an accomplished goal... ---------------------------------------------------------------------- Zvoni · 2022-02-03 15:06 https://wiki.freepascal.org/Creating_bindings_for_C_libraries#Manual_c onversion_of_C_headers_to_Pascal QuoteNote that one should use the ctypes unit together with the types that it declares to convert C headers instead of trying to use the basic Pascal types directly. This ensures that the bindings are correct in all platforms, as the C types might have different sizes on different architectures and operating systems. ---------------------------------------------------------------------- funlw65 · 2022-02-03 15:21 Quote from: Roland57 on February 03, 2022, 08:33:38 amVery interesting.  I could compile and run successfully the C demo (with the static lib, on Linux Mageia). Very nice! (By the way, it was very easy to install raylib.) For the Pascal demo, I have to find how to build libtyphoon.so. Could you share the binary, or explain how you built it? Hi Roland57, For the dynamic raylib, this one must include inside also raygui... You have to clone the GLFW project from github and compile and install it as a shared library - it gives you a link to their home page for the compiling instructions. Follow them. After that, get the raylib 4 release, unzip it and go to the src subfolder and edit the Makefile. There, you have to activate using the external GLFW, activate the shared compilation and the inclusion of the raygui... can't remember now if there are more, but all you need is there in the Makefile. I think this is also something that Gunko must resolve/explain for use of its distro of Ray4Laz... For the dynamic typhoon. Just execute configure to obtain the Makefile file and edit it to include the -fPIC option in CFLAGS vatiable (I included it after -shared option which must be included as well) . Then, after compilation, execute the following command: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i gcc -shared -o libtyphoon.so ansi.o bt_del.o bt_funcs.o bt_io.o bt_open.o cmpfuncs.o os.o readdbd.o record.o sequence.o ty_auxfn.o ty_find.o ty_ins.o ty_io.o ty_log.o ty_open.o ty_refin.o ty_repl.o ty_util.o unix.o vlr.o How looks CFLAGS in my Makefile: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i CFLAGS        = -g -Wall -shared -fPIC -Wstrict-prototypes -Wmissing-prototypes -D_POSIX_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE $(DEFINES) ---------------------------------------------------------------------- funlw65 · 2022-02-03 15:27 Quote from: Zvoni on February 03, 2022, 04:06:46 pmhttps://wiki.freepa scal.org/Creating_bindings_for_C_libraries#Manual_conversion_of_C_head ers_to_Pascal QuoteNote that one should use the ctypes unit together with the types that it declares to convert C headers instead of trying to use the basic Pascal types directly. This ensures that the bindings are correct in all platforms, as the C types might have different sizes on different architectures and operating systems. Thank you Zvoni, I will look into it and redo the header... ---------------------------------------------------------------------- Roland57 · 2022-02-03 17:44 @funlw65 Thanks. I will try to do that. ---------------------------------------------------------------------- funlw65 · 2022-02-03 18:47 Quote from: Roland57 on February 03, 2022, 06:44:40 pm@funlw65 Thanks. I will try to do that. I realized that you need detailed instructions to make that raylib library that can work also with Ray4Laz that Gunko has it in the works (the one that includes raygui as well). So let me try to write the required steps: So, apart of compiling GLFW 3.4 (from the repo and, if you have a previous version installed in your system, uninstall it) as dynamic lib, you have to do the following: 1. Get the 4.0 distro of raylib and unzip it in your home folder; 2. Inside the main folder of the raylib, go to src/extras subfolder as we need to prepare raygui.h and physac.h headers. 3. Copy them into .c sources:   cp raygui.h raygui.c   cp physac.h physac.c 4. Copy the resulted .c files into the src subfolder (up one level in the tree structure of the folders).  so you are here now: $HOME/raylib_main_folder/src 5. Now we have to introduce one line of code to the raygui.c. Open it in an editor, and below  #define RAYGUI_VERSION  "3.0" line, insert the following line:  #define RAYGUI_IMPLEMENTATION 6. Save the modification. 7. Now we need to prepare the Makefile as below (I will include part of my Makefile for clarity): Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i # Library type used for raylib: STATIC (.a) or SHARED (.so/.dll)RAYLIB_LIBTYPE     ?= SHARED # Build mode for library: DEBUG or RELEASERAYLIB_BUILD_MODE    ?= RELEASE # Build output name for the libraryRAYLIB_LIB_NAME      ?= raylib # Define resource file for DLL propertiesRAYLIB_RES_FILE      ?= ./raylib.dll.rc.data # Define raylib platform# Options:  PLATFORM_DESKTOP, PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEBPLATFORM             ?= PLATFORM_DESKTOP # Include raylib modules on compilation# NOTE: Some programs like tools could not require those modulesRAYLIB_MODULE_AUDIO  ?= TRUERAYLIB_MODULE_MODELS ?= TRUERAYLIB_MODULE_RAYGUI ?= TRUERAYLIB_MODULE_PHYSAC ?= TRUE RAYLIB_MODULE_RAYGUI_PATH ?= $(RAYLIB_SRC_PATH)/extrasRAYLIB_MODULE_PHYSAC_PATH ?= $(RAYLIB_SRC_PATH)/extras # Use external GLFW library instead of rglfw moduleUSE_EXTERNAL_GLFW    ?= TRUE  7.a On short, RAYLIB_LIBTYPE should be SHARED, RAYLIB_MODULE_RAYGUI should be TRUE, RAYLIB_MODULE_PHYSAC should be TRUE and USE_EXTERNAL_GLFW should be TRUE. 8. Save the modifications in the Makefile and compile from here (execute make command). You should get the required .so library, that contains both raygui and physac headers, required also for the upcoming new version and examples of Ray4Laz package... 9. Execute  sudo make install and you are good to go. ---------------------------------------------------------------------- funlw65 · 2022-02-03 22:52 Updated ty.pas in the first post with ctypes... hopefully, is right? The demo compiles nicely and runs well (tested navigating between keys, searching key, modifying record). ty.pas is also in the demo's repo... if you get the repo, you have it. ---------------------------------------------------------------------- Roland57 · 2022-02-04 02:24 @funlw65 Thank you very much for all these informations. I will try all that ASAP. If you have time and desire, it could be a good idea to make a simple demo (not using raylib), so that we can test easily the Typhoon bindings. Regards. Roland ---------------------------------------------------------------------- funlw65 · 2022-02-04 02:51 There is tytest.pas in the repository, but only for a few functions and I thought I would make something similar to MushRoomsDatabase by Jurassic Pork, but for fpc only, using raylib/raygui as an alternative to the classic GUI interfaces. Anyway, one needs to read the documentation that typhoon comes with, how to define the structure of a database using the provided language (DDL), then how to use the specific tools to create the database and the .h header with the record definitions that must be translated with h2pas, etc. Is a quite capable classic database, similar to .DBF but a little complex at the beginning (but only regarding database definitions, because the functions are quite straight forward), and probably not too beginner friendly, so I had to dress her in an attractive GUI interface. It helps much if playing with the C example that comes with typhoon... ---------------------------------------------------------------------- Roland57 · 2022-02-04 06:39 Quote from: funlw65 on February 04, 2022, 03:51:26 amThere is tytest.pas in the repository, but only for a few functions and I thought I would make something similar to MushRoomsDatabase by Jurassic Pork, but for fpc only, using raylib/raygui as an alternative to the classic GUI interfaces. Following your instructions I could compile libtyphoon.so and tytest.pas. The program works well here. Thanks for the manual. ---------------------------------------------------------------------- funlw65 · 2022-02-04 07:29 Quote from: Roland57 on February 04, 2022, 07:39:05 amQuote from: funlw65 on February 04, 2022, 03:51:26 amThere is tytest.pas in the repository, but only for a few functions and I thought I would make something similar to MushRoomsDatabase by Jurassic Pork, but for fpc only, using raylib/raygui as an alternative to the classic GUI interfaces. Following your instructions I could compile libtyphoon.so and tytest.pas. The program works well here. Thanks for the manual. I'm glad it works for you. ---------------------------------------------------------------------- funlw65 · 2022-08-23 01:49 Original post updated.