Re: Best way to read/write Chinese (GBK/GB18030) files?
On Wednesday, 22 March 2023 at 15:23:42 UTC, Kagamin wrote: https://dlang.org/phobos/std_stdio.html#rawWrite It's really amazing, it succeeded. Thank you! ```cpp auto b="test.txt";//gbk void[]d=read(b); stdout.rawWrite(d); ```
Re: Watch me beat a dead horse. Super simple program...
On 23/03/2023 12:28 PM, WhatMeWorry wrote: Yes! Thank you very much. Downloaded the 2015 Microsoft Visual C++ Redistributables and it worked. You mentioning "dependencies" in an earlier post, but didn't know how to proceed. Would it be worth while to update the bindbc-FreeImage documentation or is this common knowledge? That would be the most likely solution to be do-able. But this really needs to be on FreeImage's site. It also appears the README in the distribution is out of date. Since its talking about Mingw for building. But Mingw supports MSVC for building and what version of MSVC installed matters.
Re: Watch me beat a dead horse. Super simple program...
On Wednesday, 22 March 2023 at 21:08:23 UTC, Richard (Rikki) Andrew Cattermole wrote: I finally went ahead and looked at the dependencies of FreeImage3180. Try installing: https://www.microsoft.com/en-ca/download/details.aspx?id=48145 It requires VCOMP140.dll which comes with the 2015 VC redistribution package. Found via: https://github.com/lucasg/Dependencies Yes! Thank you very much. Downloaded the 2015 Microsoft Visual C++ Redistributables and it worked. You mentioning "dependencies" in an earlier post, but didn't know how to proceed. Would it be worth while to update the bindbc-FreeImage documentation or is this common knowledge?
Re: Watch me beat a dead horse. Super simple program...
I finally went ahead and looked at the dependencies of FreeImage3180. Try installing: https://www.microsoft.com/en-ca/download/details.aspx?id=48145 It requires VCOMP140.dll which comes with the 2015 VC redistribution package. Found via: https://github.com/lucasg/Dependencies
Re: Watch me beat a dead horse. Super simple program...
On Wednesday, 22 March 2023 at 19:33:45 UTC, WhatMeWorry wrote: Ok, I've gotten rid of dub and dub packages code. Just LoadLibraryA. All eight dlls work except for FreeImage.dll. I've compiled with dmd and -m64 option and freshly download a x64 FreeImage. Any Window users out there that use LoadLibraryA or FreeImage.dll? ``` import std.stdio: writeln; import std.string: toStringz; import core.sys.windows.windows: LoadLibraryA; void main() { string[] DLLs = [ "assimp.dll", "fmod.dll", "freetype.dll", "glfw3.dll", "OpenAL32.dll", "SDL2.dll", "SDL2_mixer.dll", "FreeImage.dll" ]; foreach(dll; DLLs) { void *ptr = LoadLibraryA(toStringz(dll)); if (ptr) writeln("calling LoadLibraryA with ", dll, " ptr is set"); else writeln("calling LoadLibraryA with ", dll, " ptr is NULL"); } } ``` C:\Users\Admin\Documents\GitHub\Delivery\apps\00_03_freeimage_debug>app.exe calling LoadLibraryA with assimp.dll ptr is set calling LoadLibraryA with fmod.dll ptr is set calling LoadLibraryA with freetype.dll ptr is set calling LoadLibraryA with glfw3.dll ptr is set calling LoadLibraryA with OpenAL32.dll ptr is set calling LoadLibraryA with SDL2.dll ptr is set calling LoadLibraryA with SDL2_mixer.dll ptr is set calling LoadLibraryA with FreeImage.dll ptr is NULL C:\Users\Admin\Documents\GitHub\Delivery\apps\00_03_freeimage_debug>dir 03/22/2023 01:45 PM 3,116 app.d 03/22/2023 01:46 PM 681,984 app.exe 03/06/2023 04:25 PM 3,805,184 assimp.dll 03/06/2023 04:25 PM 1,721,344 fmod.dll 03/06/2023 04:25 PM 6,942,208 FreeImage.dll 03/06/2023 04:25 PM 832,512 freetype.dll 03/06/2023 04:25 PM 216,576 glfw3.dll 03/06/2023 04:25 PM 122,904 OpenAL32.dll 03/06/2023 04:25 PM 1,220,096 SDL2.dll 03/06/2023 04:25 PM 143,872 SDL2_mixer.dll Most likely a dependency that is missing? Can you zip your folder and upload it somewhere so i could try help you debug this issue?
Watch me beat a dead horse. Super simple program...
Ok, I've gotten rid of dub and dub packages code. Just LoadLibraryA. All eight dlls work except for FreeImage.dll. I've compiled with dmd and -m64 option and freshly download a x64 FreeImage. Any Window users out there that use LoadLibraryA or FreeImage.dll? ``` import std.stdio: writeln; import std.string: toStringz; import core.sys.windows.windows: LoadLibraryA; void main() { string[] DLLs = [ "assimp.dll", "fmod.dll", "freetype.dll", "glfw3.dll", "OpenAL32.dll", "SDL2.dll", "SDL2_mixer.dll", "FreeImage.dll" ]; foreach(dll; DLLs) { void *ptr = LoadLibraryA(toStringz(dll)); if (ptr) writeln("calling LoadLibraryA with ", dll, " ptr is set"); else writeln("calling LoadLibraryA with ", dll, " ptr is NULL"); } } ``` C:\Users\Admin\Documents\GitHub\Delivery\apps\00_03_freeimage_debug>app.exe calling LoadLibraryA with assimp.dll ptr is set calling LoadLibraryA with fmod.dll ptr is set calling LoadLibraryA with freetype.dll ptr is set calling LoadLibraryA with glfw3.dll ptr is set calling LoadLibraryA with OpenAL32.dll ptr is set calling LoadLibraryA with SDL2.dll ptr is set calling LoadLibraryA with SDL2_mixer.dll ptr is set calling LoadLibraryA with FreeImage.dll ptr is NULL C:\Users\Admin\Documents\GitHub\Delivery\apps\00_03_freeimage_debug>dir 03/22/2023 01:45 PM 3,116 app.d 03/22/2023 01:46 PM 681,984 app.exe 03/06/2023 04:25 PM 3,805,184 assimp.dll 03/06/2023 04:25 PM 1,721,344 fmod.dll 03/06/2023 04:25 PM 6,942,208 FreeImage.dll 03/06/2023 04:25 PM 832,512 freetype.dll 03/06/2023 04:25 PM 216,576 glfw3.dll 03/06/2023 04:25 PM 122,904 OpenAL32.dll 03/06/2023 04:25 PM 1,220,096 SDL2.dll 03/06/2023 04:25 PM 143,872 SDL2_mixer.dll
Re: Formatted date
On Wednesday, 22 March 2023 at 17:53:39 UTC, Steven Schveighoffer wrote: D's datetime intentionally does not tackle formatting -- it's a huge undertaking. There is an option on code.dlang.org: https://code.dlang.org/packages/datefmt -Steve I'll try it tomorrow, thanks!
Re: Threads
On 3/21/23 22:30, Tim wrote: > to make a simple multi-threading application. Unless there is a reason not to, I recommend std.concurrency and std.parallelism modules. They are different but much more simpler compared to the low-level core.thread. > args_copy = args; //Why program name is missing while copy arguments? That doesn't copy. Both args_copy and args will be references to the same elements. (They are both array slices.) The following may work to get a shared argument: immutable args_copy = args.idup; idup makes an immutable copy and immutable is implicitly shared. Even if that works, I still find std.concurrency much easier to deal with. :) Ali
Re: Formatted date
On 3/22/23 10:02 AM, Alexander Zhirov wrote: Tell me, how can I use such a date conversion mechanism? I didn't find [something](https://www.php.net/manual/en/datetime.format.php) similar on the forum. Convert date from received time ``` Clock.currTime().toSimpleString() ``` So that i can get a more readable look: `2023-Mar-22 16:53:42.2507395` => `2023.03.22 16:53:42` D's datetime intentionally does not tackle formatting -- it's a huge undertaking. There is an option on code.dlang.org: https://code.dlang.org/packages/datefmt -Steve
Re: Best way to read/write Chinese (GBK/GB18030) files?
https://dlang.org/phobos/std_stdio.html#rawWrite
Re: Formatted date
On Wednesday, 22 March 2023 at 14:02:53 UTC, Alexander Zhirov wrote: Convert date from received time ``` Clock.currTime().toSimpleString() ``` I missed the part about receiving the time, so ignore my previous post.
Re: Formatted date
On Wednesday, 22 March 2023 at 14:02:53 UTC, Alexander Zhirov wrote: So that i can get a more readable look: `2023-Mar-22 16:53:42.2507395` => `2023.03.22 16:53:42` Maybe there's a better way but I just do this. ``` import std; void main() { const now = Clock.currTime(); enum pattern = "%d.%02d.%02d %02d:%02d:%02d"; writefln(pattern, now.year, now.month, now.day, now.hour, now.minute, now.second); } ``` https://run.dlang.io/is/mhvzN2
Formatted date
Tell me, how can I use such a date conversion mechanism? I didn't find [something](https://www.php.net/manual/en/datetime.format.php) similar on the forum. Convert date from received time ``` Clock.currTime().toSimpleString() ``` So that i can get a more readable look: `2023-Mar-22 16:53:42.2507395` => `2023.03.22 16:53:42`
Re: Threads
On Wednesday, 22 March 2023 at 07:16:43 UTC, Kagamin wrote: static is thread local by default. ``` module main; import app; import core.thread; int main(string[] args) { static shared int result; static shared string[] args_copy; static void app_thread() { App app = new App(); result = app.run(args_copy); } args_copy = cast(shared)args; // Running app interface in a thread; Thread thread = new Thread(&app_thread).start(); thread.join(); return result; } ``` It seems work, but I have to change "int App.run(string[] args)" to "App.run(shared string[] args)" in app module and `std.getopt.getopt` throws me an error in the same module: Error: none of the overloads of template `std.getopt.getopt` are callable using argument types `!()(shared(string[]), string, string, string*)` /usr/include/dmd/phobos/std/getopt.d(420,14):Candidate is: `getopt(T...)(ref string[] args, T opts)`
Re: Threads
On Wednesday, 22 March 2023 at 07:16:43 UTC, Kagamin wrote: static is thread local by default. ``` module main; import app; import core.thread; int main(string[] args) { static shared int result; static shared string[] args_copy; static void app_thread() { App app = new App(); result = app.run(args_copy); // <-- Stucked here! } args_copy = cast(shared)args; // Running app interface in a thread; Thread thread = new Thread(&app_thread).start(); thread.join(); return result; } ``` I've changed "int App.run(string[] args)" to "int App.run(shared string[] args)" in app module. Now I've got an error in std.getopt.getopt in the same module. Error: none of the overloads of template `std.getopt.getopt` are callable using argument types `!()(shared(string[]), string, string, string*)` Am I doing something wrong?
Re: Threads
static is thread local by default. ``` module main; import app; import core.thread; int main(string[] args) { static shared int result; static shared string[] args_copy; static void app_thread() { App app = new App(); result = app.run(args_copy); } args_copy = cast(shared)args; // Running app interface in a thread; Thread thread = new Thread(&app_thread).start(); thread.join(); return result; } ```