Re: Reading an environment variable value

2023-06-29 Thread Josh Holtrop via Digitalmars-d-learn
On Thursday, 29 June 2023 at 19:19:21 UTC, Adam D Ruppe wrote: On Thursday, 29 June 2023 at 18:47:48 UTC, Josh Holtrop wrote: $ ldc2 -of environment environment.d Since you named the file `environment.d` and didn't use an explicit `module name.thing;` declaration, the compiler assumes

Reading an environment variable value

2023-06-29 Thread Josh Holtrop via Digitalmars-d-learn
I am trying to use `std.process.environment.get()` as described here: https://dlang.org/library/std/process/environment.get.html I wrote this program to test it: ```d import std.stdio; import std.process; int main(string[] args) { string home = environment.get("HOME"); writeln("home

Cannot convert expression of a SubType's sub type to the parent SubType on return

2023-06-06 Thread Josh Holtrop via Digitalmars-d-learn
I am trying to use std.sumtype which seems to be just what I need for some functions that can return various types of errors with parameters or a success value with different parameters. In this test I get a compilation error with ldc2: ```d import std.stdio; import std.sumtype; struct Error

Re: constant pointer failing to compile

2023-04-06 Thread Josh Holtrop via Digitalmars-d-learn
On Thursday, 6 April 2023 at 00:59:12 UTC, Mathias LANG wrote: immutable ubyte[4] data = [1, 2, 3, 4]; Using a static array instead of a slice will do the trick. You can leave the `__gshared` if you want, but it is redundant on a global, initialized `immutable` variable. Yes, thank you,

constant pointer failing to compile

2023-04-05 Thread Josh Holtrop via Digitalmars-d-learn
I am trying to port a small C project to D and am getting a compilation error I don't understand. I've simplified the situation down to the example here. This C version compiles fine: ```c #include static const unsigned char data[] = {1, 2, 3, 4}; static const unsigned char * p = [0]; int

Trying to reduce memory usage

2021-02-11 Thread Josh via Digitalmars-d-learn
I'm trying to read in a text file that has many duplicated lines and output a file with all the duplicates removed. By the end of this code snippet, the memory usage is ~5x the size of the infile (which can be multiple GB each), and when this is in a loop the memory usage becomes unmanageable

Re: Getting Qte5 to work

2020-10-28 Thread Josh Dredge via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 07:56:35 UTC, Mike Parker wrote: On Wednesday, 28 October 2020 at 07:50:27 UTC, Josh Dredge wrote: developers would love to be working with! I will give Gtk a go too - I've never programmed with it, but I used Ubuntu alot back in the day and never really

Re: Getting Qte5 to work

2020-10-28 Thread Josh Dredge via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 06:52:35 UTC, evilrat wrote: On Tuesday, 27 October 2020 at 11:46:02 UTC, Josh Dredge wrote: [...] Welcome! If by web development you also have back-end programming then you should be like 50% know how desktop programming works. [...] Fantastic, thank

Getting Qte5 to work

2020-10-27 Thread Josh Dredge via Digitalmars-d-learn
Hi all, I'm completely new to D and while I'm not new to programming in general, I mostly do web development, and what desktop development I've done has all been with easy drag-and-drop GUI builders - so Visual Basic, C# and J# (if that doesn't date me). I'm trying to experiment in new

Re: Is using floating point type for money/currency a good idea?

2019-05-20 Thread Josh via Digitalmars-d-learn
On Monday, 20 May 2019 at 11:10:32 UTC, Boqsc wrote: https://dlang.org/spec/float.html I'm frozen in learning basics of D lang since I want to create a simple game and I really would like a clean and simple code, however to me floating points are magic. https://wiki.dlang.org/Review_Queue

Re: Linked List iterating over and inserting an element around (before/after) the current position.

2019-05-19 Thread Josh via Digitalmars-d-learn
Thank you, that helps big time. This is just more curiosity, but do you happen to know why I have to use DList.linearRemove() instead of DList.remove()? import std.stdio; import std.container.dlist; import std.algorithm; import std.range; void main() { auto list = make!DList("the",

Linked List iterating over and inserting an element around (before/after) the current position.

2019-05-19 Thread Josh via Digitalmars-d-learn
Just started looking at D this weekend, coming from a C++/Java/Go/Rust background and it's really not going well. Trying to write something to play with the language and need a linked list, looking in std.container you have a single or doubly linked list...great. Now how to I iterate over

Trying to extract string from curl redirected URL

2019-02-10 Thread Josh via Digitalmars-d-learn
I have a website (say https://website.com) that I need to log in to, it will do a few 302 redirects and then I will end up with a unique session ID in the URL (such as https://website.com/welcome.html?s=636853677441448706). Is there some way of extracting this ID (I'll need it later for other

Re: libcurl acting differently to curl.exe

2017-12-10 Thread Josh via Digitalmars-d-learn
ass=submit"); curl_easy_setopt(hnd, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)52); curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/7.57.0"); curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); curl_easy_setopt(hnd, CURLOPT_HTTP_VERSION, (long)CURL_HTTP_VERSION_2TLS); curl_easy_setopt(hnd, CURLOPT_

libcurl acting differently to curl.exe

2017-12-10 Thread Josh via Digitalmars-d-learn
handle.set(CurlOption.useragent, "curl/7.57.0"); http.handle.set(CurlOption.maxredirs, 50); //http.handle.set(CurlOption.cainfo, "C:\\Users\\Josh\\Downloads\\curl-7.57.0-win64-mingw\\bin\\curl-ca-bundle.crt"); http.handle.set(CurlOption.cookiejar, "co

Re: Problems with function as parameter

2017-09-21 Thread Josh via Digitalmars-d-learn
On Friday, 22 September 2017 at 03:26:36 UTC, Mike Parker wrote: On Friday, 22 September 2017 at 02:22:46 UTC, Josh wrote: src\mixer.d(80,22): Error: function pointer Mix_ChannelFinished (extern (C) void function(int channel)) is not callable using argument types (extern (C) void delegate

Re: Problems with function as parameter

2017-09-21 Thread Josh via Digitalmars-d-learn
On Friday, 22 September 2017 at 02:18:34 UTC, Mike Parker wrote: On Thursday, 21 September 2017 at 22:05:22 UTC, Matt Jones wrote: On Thursday, 21 September 2017 at 20:21:58 UTC, Josh wrote: I'm trying to write a callback function for SDL_mixer through Derelict, but this is the first time I've

Re: Problems with function as parameter

2017-09-21 Thread Josh via Digitalmars-d-learn
On Thursday, 21 September 2017 at 22:05:22 UTC, Matt Jones wrote: On Thursday, 21 September 2017 at 20:21:58 UTC, Josh wrote: I'm trying to write a callback function for SDL_mixer through Derelict, but this is the first time I've tried to use a function as a parameter, and so I think I'm just

Problems with function as parameter

2017-09-21 Thread Josh via Digitalmars-d-learn
I'm trying to write a callback function for SDL_mixer through Derelict, but this is the first time I've tried to use a function as a parameter, and so I think I'm just making a minor mistake somewhere. The C SDL docs say: // make a

Starting threads inside class

2016-02-23 Thread Josh via Digitalmars-d-learn
My goal with the code below is to eventually have my main communicate with Foo and Bar classes listening for packets on a different address/port, each in a separate thread. They would then communicate with Foobaz and Barbaz threads respectively to do other work. In trying to get just Foo

Re: Possible to get Class of Interface at runtime

2016-01-24 Thread Josh Phillips via Digitalmars-d-learn
On Saturday, 23 January 2016 at 21:06:32 UTC, Adam D. Ruppe wrote: Are you sure you correctly casted first? Nope sorry. Thanks for the help!!

Re: Possible to get Class of Interface at runtime

2016-01-23 Thread Josh Phillips via Digitalmars-d-learn
On Friday, 22 January 2016 at 23:44:34 UTC, Adam D. Ruppe wrote: There's a .classinfo property that works on Objects. If you have an interface, cast to Object first, and check for null, then get .classinfo off that. I tried this but it will return A not B

Possible to get Class of Interface at runtime

2016-01-22 Thread Josh Phillips via Digitalmars-d-learn
If I have: interface A {} class B : A {} void printClass(A obj){ // Code here } Is there any way that I can find out what class obj is inside of printClass? I know I can cast and check if(cast(B)obj) but I want to just be able to do something along the lines of obj.class. I can think of

Re: DUB & Win-10 SDK / link lib not found

2016-01-15 Thread Josh Phillips via Digitalmars-d-learn
I also ran into this issue because I upgraded VS and removed the old version. A quick re-install with the dmd .exe fixed it.

Re: Glad and WGL

2016-01-15 Thread Josh Phillips via Digitalmars-d-learn
On Friday, 15 January 2016 at 07:37:27 UTC, Josh Phillips wrote: However I (of course) ran into new errors. Gl functions like glGetString and glGetIntegerv cause the program to crash. It appears that an opengl context is being created so I'm not sure whats causing the problem For anyone else

Re: Glad and WGL

2016-01-14 Thread Josh Phillips via Digitalmars-d-learn
On Thursday, 14 January 2016 at 09:42:50 UTC, Dav1d wrote: On Thursday, 14 January 2016 at 09:25:50 UTC, Dav1d wrote: On Thursday, 14 January 2016 at 02:35:28 UTC, Josh Phillips wrote: Welcome to D and Windows. You can use GDC or LDC or try http://wiki.dlang.org/Installing_DMD_on_64

Glad and WGL

2016-01-13 Thread Josh Phillips via Digitalmars-d-learn
So I started using Glad but I can't get WGL to work with it, though I think this is more of a Win32 issue than WGL. wndclass.lpfnWndProc = Gives me an error no matter what: Error: cannot implicitly convert expression (& WndProc) of type int function(void* hWnd, uint message, uint wParam,

Re: Glad and WGL

2016-01-13 Thread Josh Phillips via Digitalmars-d-learn
On Wednesday, 13 January 2016 at 18:37:09 UTC, Adam D. Ruppe wrote: You just need to explicitly mark it nothrow in the signature. Add `nothrow` to the end of the param list: extern(Windows) LRESULT WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) nothrow and then you'll be

Re: Glad and WGL

2016-01-13 Thread Josh Phillips via Digitalmars-d-learn
On Thursday, 14 January 2016 at 02:16:40 UTC, userABCabc123 wrote: On Wednesday, 13 January 2016 at 19:05:30 UTC, Josh Phillips wrote: Oh wow that's easy. They should really make that more clear in the dlang reference. They way it sounds there made me think that if a function doesn't throw any

Re: Glad and WGL

2016-01-13 Thread Josh Phillips via Digitalmars-d-learn
On Wednesday, 13 January 2016 at 20:08:55 UTC, Dav1d wrote: Link with opengl32.lib How? Everywhere I looked it says this cannot be done due to conflicting formats between the dmd compiler and the windows one.

USB Controller

2015-04-02 Thread Josh Phillips via Digitalmars-d-learn
? Thanks Josh

Set differences

2014-04-05 Thread Josh
, sequence!(n * a[0])(2)); trimmed = setDifference(trimmed, sequence!(n * a[0])(3)); Thanks, Josh

Re: DGUI

2014-02-15 Thread Josh Phillips
On Friday, 14 February 2014 at 20:36:42 UTC, Jeremy DeHaan wrote: Unless I am mistaken, it looks like the last time it was updated was in 2011. You'd probably have to update a bunch of stuff in the sources in order to get it to work properly. I would recommend gtkD as a gui library. I think

DGUI

2014-02-14 Thread Josh Phillips
I recently downloaded and tried to use DGUI but I can't get it to work. Is there any tutorials on how to build an use it? Or can anyone help me and tel me a way on how I can get it to work?

Which Libraries?

2013-12-26 Thread Josh Phillips
I was wondering if people could suggest which libraries may be best to use for building an application which would be a type of text editor with multiple documents and branches. I need something whereby I can create simple, custom windows and do simple text editing, but then i need it to also

Re: Files not found issues

2013-09-09 Thread Josh
On Thursday, 22 August 2013 at 04:18:34 UTC, Josh wrote: Windows 7, DMD 2.062 I was trying to use std.file.copy, and I kept getting a FileException because it couldn't find the file, even though I triple checked the name and that it existed in Explorer. So I did a little test to illustrate

Files not found issues

2013-08-21 Thread Josh
.dll I created by copying msvcrt.dll. I also can't find msvcrt20/40.dll inside Explorer. Is there any reason why these don't show the same results? Thanks, Josh

Weird error occurance

2013-08-07 Thread Josh
{ d = dirEntry(n); if (d.isDir !canFind(d.name, Windows) !canFind(d.name, Program Files) !canFind(d.name, ProgramData) !canFind(d.name, Josh)) entries.put(scanDrive(n, saving).data

Re: Stop to! rounding?

2013-07-03 Thread Josh
On Wednesday, 3 July 2013 at 04:51:06 UTC, Jonathan M Davis wrote: On Wednesday, July 03, 2013 06:44:33 Josh wrote: On Wednesday, 3 July 2013 at 04:32:15 UTC, Jonathan M Davis wrote: On Wednesday, July 03, 2013 06:23:12 Josh wrote: writeln(to!double(151.42499));//prints 151.425

Stop to! rounding?

2013-07-02 Thread Josh
writeln(to!double(151.42499));//prints 151.425 Is there any way to stop this rounding? Thanks, Josh

Re: Stop to! rounding?

2013-07-02 Thread Josh
On Wednesday, 3 July 2013 at 04:32:15 UTC, Jonathan M Davis wrote: On Wednesday, July 03, 2013 06:23:12 Josh wrote: writeln(to!double(151.42499));//prints 151.425 Is there any way to stop this rounding? No. double can't hold the value 151.42499. There are _tons_ of values that it can't

Linker issue?

2013-06-17 Thread Josh
, as I can compile other programs that just use Phobos. I'm sure it's something really obvious that I can't see, but I haven't had much luck with external libs. The same sort of thing happened when I used GtkD... Any help is welcomed. Thanks, Josh

Re: Find variable at run time

2013-05-18 Thread Josh
On Saturday, 18 May 2013 at 08:26:09 UTC, Dicebot wrote: On Saturday, 18 May 2013 at 02:09:49 UTC, Josh wrote: Bearophile, is your findVar an AA? It looks like it is, I just didn't think you could put refs in an AA. Thanks Josh It is AA and it stores pointers, not references. P.S

Re: Find variable at run time

2013-05-17 Thread Josh
On Friday, 17 May 2013 at 22:15:09 UTC, bearophile wrote: Josh: Is something like this possible in D? void main() { int x, y, z; write(Increment which variable: ); string input = readln()[0..$ - 1]; findVar(input)++; writeln(x, y, z); } The Go language and its standard

Input timeout

2013-05-13 Thread Josh
Is there a way in D to only accept input for a certain time, instead of std.stdio.readln's behaviour? Something like Press a key in 3 seconds to abort. Thanks Josh

Re: Input timeout

2013-05-13 Thread Josh
On Tuesday, 14 May 2013 at 04:14:27 UTC, Ali Çehreli wrote: On 05/13/2013 08:50 PM, Josh wrote: Is there a way in D to only accept input for a certain time, instead of std.stdio.readln's behaviour? Something like Press a key in 3 seconds to abort. Thanks Josh An unlikely solution

Re: GtkD No GSettings schemas installed

2013-04-15 Thread Josh
On Sunday, 14 April 2013 at 13:34:07 UTC, Mike Wey wrote: On 04/13/2013 07:00 AM, Josh wrote: On Wednesday, 10 April 2013 at 20:17:36 UTC, Mike Wey wrote: On 04/10/2013 03:20 PM, Josh wrote: After trying to compile in 64 bit and failing, I've given up and just used 32 bit. So now I have GTK

Re: GtkD No GSettings schemas installed

2013-04-12 Thread Josh
On Wednesday, 10 April 2013 at 20:17:36 UTC, Mike Wey wrote: On 04/10/2013 03:20 PM, Josh wrote: After trying to compile in 64 bit and failing, I've given up and just used 32 bit. So now I have GTK-Runtime 3.6.1 32 bit, GtkD 2.1.1 and DMD 2.062. My program is still giving the no schemas

Re: GtkD No GSettings schemas installed

2013-04-10 Thread Josh
On Wednesday, 3 April 2013 at 20:41:47 UTC, Mike Wey wrote: On 04/03/2013 05:38 AM, Josh wrote: On Tuesday, 2 April 2013 at 20:50:16 UTC, Mike Wey wrote: On 04/02/2013 02:38 PM, Josh wrote: On Sunday, 31 March 2013 at 14:21:50 UTC, Mike Wey wrote: On 03/30/2013 05:42 PM, Josh wrote

LinkTerminated origin

2013-04-03 Thread Josh
How can I find out which line of code is causing a thread to throw a LinkTerminated? Every time I catch one, it always says std\concurrency.d(262), which is just the LinkTerminated constructor. Thanks, Josh

Re: GtkD No GSettings schemas installed

2013-04-02 Thread Josh
On Sunday, 31 March 2013 at 14:21:50 UTC, Mike Wey wrote: On 03/30/2013 05:42 PM, Josh wrote: On Saturday, 30 March 2013 at 16:17:22 UTC, Mike Wey wrote: On 03/30/2013 03:49 PM, Josh wrote: Sorry, I misread, I thought the xml files were the compiled bits. When I ran glib-compile-schemas.exe

Re: GtkD No GSettings schemas installed

2013-04-02 Thread Josh
On Tuesday, 2 April 2013 at 20:50:16 UTC, Mike Wey wrote: On 04/02/2013 02:38 PM, Josh wrote: On Sunday, 31 March 2013 at 14:21:50 UTC, Mike Wey wrote: On 03/30/2013 05:42 PM, Josh wrote: On Saturday, 30 March 2013 at 16:17:22 UTC, Mike Wey wrote: On 03/30/2013 03:49 PM, Josh wrote: Sorry, I

Re: GtkD No GSettings schemas installed

2013-03-30 Thread Josh
On Saturday, 30 March 2013 at 13:19:03 UTC, Mike Wey wrote: On 03/30/2013 05:25 AM, Josh wrote: This is the code causing the problem: class myInputDialog : Dialog ... this() { super(Please enter file location..., this, GtkDialogFlags.MODAL | GtkDialogFlags.DESTROY_WITH_PARENT, [StockID.OK

Re: GtkD No GSettings schemas installed

2013-03-30 Thread Josh
On Saturday, 30 March 2013 at 14:45:07 UTC, Josh wrote: On Saturday, 30 March 2013 at 13:19:03 UTC, Mike Wey wrote: On 03/30/2013 05:25 AM, Josh wrote: This is the code causing the problem: class myInputDialog : Dialog ... this() { super(Please enter file location

Re: GtkD No GSettings schemas installed

2013-03-30 Thread Josh
On Saturday, 30 March 2013 at 16:17:22 UTC, Mike Wey wrote: On 03/30/2013 03:49 PM, Josh wrote: Sorry, I misread, I thought the xml files were the compiled bits. When I ran glib-compile-schemas.exe, I get the following: warning: Schema 'org.gnome.system.proxy' has path '/system/proxy

GtkD No GSettings schemas installed

2013-03-29 Thread Josh
, findFile never runs and the problem doesn't happen, except I can't browse for files. Thanks, Josh

DirEntry isDir not working?

2013-02-25 Thread Josh
false false true true true true F:\folder true F:\folder true Is anybody able to explain why a DirEntry can't seem to detect whether a directory is in fact a directory, whereas plain isDir and even a DirEntry inside dirEntries can? Thanks, Josh

Re: Why are commands executing out of order?

2013-02-02 Thread Josh
On Saturday, 2 February 2013 at 11:16:50 UTC, FG wrote: On 2013-02-02 07:49, Josh wrote: But main's first writeln actually outputs after f.close(). Maybe because of output buffering and you need to add flush? How do I do that? I've never heard of flush before. The program uses ~1GB of RAM

Continue iteration after exception

2013-01-23 Thread Josh
to C:\Documents and Settings. On Windows 7 that doesn't actually exist, which is fine. What I'd like it to do is tell me that it doesn't exist, but continue iterating anyway. I've tried try-catch, but that just stops the iteration. Any help is appreciated. Thanks :) Josh

Re: Continue iteration after exception

2013-01-23 Thread Josh
On Wednesday, 23 January 2013 at 15:00:16 UTC, bearophile wrote: A possible solution: desugar the foreach range iteration protocol of dirEntries and wrap the relevant method with a try-catch. Sorry, could you explain that a little? I'm not sure what desugar means :/

Detect if running 32 bit program on 64 bit Windows OS

2012-10-09 Thread Josh
Is there a way to do that? I've tried getenv(PROCESSOR_ARCHITECTURE) and shell(echo %PROCESSOR_ARCHITECTURE%), and both of them return x86 instead of AMD64 like cmd. I want to use this to run a 64 bit version of an external program if the OS is 64 bit, and the 32 bit version if not.

importing executables

2012-09-26 Thread Josh
I'm trying to make an installer application in D. I've checked with various hashes and the file it's outputting is different to the original, and therefore Windows is saying it's not a valid Win32 application. I'm sure it's me doing something wrong and not DMD's fault. Any help is appreciated.

Module Symbol Undefined Problem

2009-08-29 Thread Josh
Hi, I wanted to give D a try today and port one of my applications to it. I am currently stuck on this problem: I have the following 3 files: maindialog.d - contains the main() function form creation(using dfl and Entice Designer) private { import dfl.all; import common.Globals; }