[Dgame] Is there Multiple Window support?

2015-12-12 Thread Jack via Digitalmars-d-learn
Hello, so I've been experimenting with the framework and I tried to implement a game that has more than two windows. The first window is the main game and the second window is a smaller one with the various commands you can select. So I tried to render sprites onto the first window and the

Re: How to check if result of request to DB is empty?

2015-12-12 Thread Suliman via Digitalmars-d-learn
it's seems that next block is execute even if is rs.next() is false: writeln("rs.next()-->", rs.next()); if(!rs.next()) //if user do not in DB { // is execute even if rs.next() is false writeln("Executed, but rs.nst was set to false"); } The output: rs.next()-->false Executed, but rs.nst was

Re: How to check if result of request to DB is empty?

2015-12-12 Thread Suliman via Digitalmars-d-learn
On Saturday, 12 December 2015 at 12:36:10 UTC, Suliman wrote: On Saturday, 12 December 2015 at 12:14:30 UTC, Vadim Lopatin wrote: On Saturday, 12 December 2015 at 12:06:21 UTC, Suliman wrote: On Saturday, 12 December 2015 at 11:53:51 UTC, Suliman wrote: On Saturday, 12 December 2015 at

alias butAtLeast = max; 5.butAtLeast(6);

2015-12-12 Thread SimonN via Digitalmars-d-learn
DMD v2.069.2-b1 on Linux. import std.algorithm; int a = max(5, 6);// works, a == 6 int b = max!(int, int)(5, 6); // works, manual instantiation int c = 5.max(6); // works, UFCS call I would like to use the last syntax, but with an alias. alias

Re: How to check if result of request to DB is empty?

2015-12-12 Thread Suliman via Digitalmars-d-learn
On Saturday, 12 December 2015 at 10:36:12 UTC, drug wrote: 12.12.2015 13:28, Suliman пишет: it's seems that next block is execute even if is rs.next() is false: writeln("rs.next()-->", rs.next()); if(!rs.next()) //if user do not in DB { // is execute even if rs.next() is false

Re: How to check if result of request to DB is empty?

2015-12-12 Thread Suliman via Digitalmars-d-learn
On Saturday, 12 December 2015 at 11:31:18 UTC, Suliman wrote: Oh sorry! I used wrong host! All ok! Yes, there was issue with host name, but it's do not solve problem. Second DB have same fields and I still getting false instead moving into while loop

Re: How to check if result of request to DB is empty?

2015-12-12 Thread Vadim Lopatin via Digitalmars-d-learn
On Saturday, 12 December 2015 at 12:06:21 UTC, Suliman wrote: On Saturday, 12 December 2015 at 11:53:51 UTC, Suliman wrote: On Saturday, 12 December 2015 at 11:31:18 UTC, Suliman wrote: Oh sorry! I used wrong host! All ok! Yes, there was issue with host name, but it's do not solve problem.

Re: How to check if result of request to DB is empty?

2015-12-12 Thread anonymous via Digitalmars-d-learn
On 12.12.2015 08:44, Suliman wrote: string query_string = (`SELECT user, password FROM otest.myusers where user LIKE ` ~ `'%` ~ request["username"].to!string ~ `%';`); Don't piece queries together without escaping the dynamic parts. Imagine what happens when the user enters an apostrophe in

Re: How to check if result of request to DB is empty?

2015-12-12 Thread Suliman via Digitalmars-d-learn
On Saturday, 12 December 2015 at 13:18:12 UTC, anonymous wrote: On 12.12.2015 08:44, Suliman wrote: string query_string = (`SELECT user, password FROM otest.myusers where user LIKE ` ~ `'%` ~ request["username"].to!string ~ `%';`); Don't piece queries together without escaping the dynamic

Re: How to check if result of request to DB is empty?

2015-12-12 Thread drug via Digitalmars-d-learn
12.12.2015 13:28, Suliman пишет: it's seems that next block is execute even if is rs.next() is false: writeln("rs.next()-->", rs.next()); if(!rs.next()) //if user do not in DB { // is execute even if rs.next() is false writeln("Executed, but rs.nst was set to false"); } The output:

Re: How to check if result of request to DB is empty?

2015-12-12 Thread Suliman via Digitalmars-d-learn
On Saturday, 12 December 2015 at 12:14:30 UTC, Vadim Lopatin wrote: On Saturday, 12 December 2015 at 12:06:21 UTC, Suliman wrote: On Saturday, 12 December 2015 at 11:53:51 UTC, Suliman wrote: On Saturday, 12 December 2015 at 11:31:18 UTC, Suliman wrote: Oh sorry! I used wrong host! All ok!

Re: How to check if result of request to DB is empty?

2015-12-12 Thread Suliman via Digitalmars-d-learn
On Saturday, 12 December 2015 at 12:43:36 UTC, Suliman wrote: On Saturday, 12 December 2015 at 12:36:10 UTC, Suliman wrote: On Saturday, 12 December 2015 at 12:14:30 UTC, Vadim Lopatin wrote: On Saturday, 12 December 2015 at 12:06:21 UTC, Suliman wrote: On Saturday, 12 December 2015 at

Re: alias butAtLeast = max; 5.butAtLeast(6);

2015-12-12 Thread ZombineDev via Digitalmars-d-learn
On Saturday, 12 December 2015 at 12:43:36 UTC, SimonN wrote: DMD v2.069.2-b1 on Linux. import std.algorithm; int a = max(5, 6);// works, a == 6 int b = max!(int, int)(5, 6); // works, manual instantiation int c = 5.max(6); // works, UFCS call I would

Re: alias butAtLeast = max; 5.butAtLeast(6);

2015-12-12 Thread JR via Digitalmars-d-learn
On Saturday, 12 December 2015 at 12:43:36 UTC, SimonN wrote: DMD v2.069.2-b1 on Linux. import std.algorithm; int a = max(5, 6);// works, a == 6 int b = max!(int, int)(5, 6); // works, manual instantiation int c = 5.max(6); // works, UFCS call I would

Re: How to check if result of request to DB is empty?

2015-12-12 Thread Suliman via Digitalmars-d-learn
Oh sorry! I used wrong host! All ok!

Re: How to check if result of request to DB is empty?

2015-12-12 Thread Suliman via Digitalmars-d-learn
On Saturday, 12 December 2015 at 11:53:51 UTC, Suliman wrote: On Saturday, 12 December 2015 at 11:31:18 UTC, Suliman wrote: Oh sorry! I used wrong host! All ok! Yes, there was issue with host name, but it's do not solve problem. Second DB have same fields and I still getting false instead

Re: How to check if result of request to DB is empty?

2015-12-12 Thread Chris Wright via Digitalmars-d-learn
On Sat, 12 Dec 2015 07:44:40 +, Suliman wrote: >>> string query_string = (`SELECT user, password FROM otest.myusers where >>> user LIKE ` ~ `'%` ~ request["username"].to!string ~ `%';`); >> >> Don't piece queries together without escaping the dynamic parts. >> Imagine what happens when the

AliasSeq can contain template identifier too?

2015-12-12 Thread Shriramana Sharma via Digitalmars-d-learn
https://github.com/D-Programming-Language/phobos/blob/master/std/meta.d#L790 Looks like an AliasSeq can contain a template identifier too. So should I understand that AliasSeq in general can refer to any identifier and any value? Hitherto I thought it was any *type* and any value... --

isTemplate and isValue?

2015-12-12 Thread Shriramana Sharma via Digitalmars-d-learn
Hello. Re my posting just now re AliasSeq being able to contain a template identifier too, I wonder whether it is possible to have a std.traits template to identify whether something is a template or not? In connection with this, while is() is there to determine whether something is a type or

Re: alias butAtLeast = max; 5.butAtLeast(6);

2015-12-12 Thread SimonN via Digitalmars-d-learn
By putting it in the top level. I believe this is intentional but I don't remember the reasoning. On Saturday, 12 December 2015 at 13:34:09 UTC, ZombineDev wrote: This is due to limitation of function-local aliases. If you put the alias outside it will work:

Re: isTemplate and isValue?

2015-12-12 Thread Basile B. via Digitalmars-d-learn
On Saturday, 12 December 2015 at 14:17:52 UTC, Shriramana Sharma wrote: Hello. Re my posting just now re AliasSeq being able to contain a template identifier too, I wonder whether it is possible to have a std.traits template to identify whether something is a template or not? In connection

Re: AliasSeq can contain template identifier too?

2015-12-12 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 12 December 2015 at 14:15:37 UTC, Shriramana Sharma wrote: https://github.com/D-Programming-Language/phobos/blob/master/std/meta.d#L790 Looks like an AliasSeq can contain a template identifier too. So should I understand that AliasSeq in general can refer to any identifier and

Re: functional way doing array stuff/ lambda functions

2015-12-12 Thread Namal via Digitalmars-d-learn
On Saturday, 12 December 2015 at 23:50:55 UTC, Xinok wrote: On Saturday, 12 December 2015 at 23:36:43 UTC, cym13 wrote: ... So, in your example: int product(const ref int[] arr) { import std.array: array; import std.algorithm: reduce; arr = arr.reduce!((p, i) => p*i).array; }

Re: AliasSeq can contain template identifier too?

2015-12-12 Thread Ali Çehreli via Digitalmars-d-learn
On 12/12/2015 06:15 AM, Shriramana Sharma wrote: > https://github.com/D-Programming-Language/phobos/blob/master/std/meta.d#L790 > > Looks like an AliasSeq can contain a template identifier too. So should I > understand that AliasSeq in general can refer to any identifier and any > value?

Re: functional way doing array stuff/ lambda functions

2015-12-12 Thread Namal via Digitalmars-d-learn
On Sunday, 13 December 2015 at 00:02:11 UTC, cym13 wrote: Now that I think about it, it's true that it would make no sense whatsoever to return a range as reduce is typically used to return a single value... At least it makes perfect sense. Thanks alot, this helped alot. But I have another

Re: functional way doing array stuff/ lambda functions

2015-12-12 Thread cym13 via Digitalmars-d-learn
On Sunday, 13 December 2015 at 00:36:29 UTC, Namal wrote: On Sunday, 13 December 2015 at 00:02:11 UTC, cym13 wrote: Now that I think about it, it's true that it would make no sense whatsoever to return a range as reduce is typically used to return a single value... At least it makes perfect

functional way doing array stuff/ lambda functions

2015-12-12 Thread Namal via Digitalmars-d-learn
Hello guys, I am still uncertain how to do it right when it comes to lambda functions. For instance: how do I multiply all the elements in an array ? int product(const ref int[] arr){ int p = 1; foreach(i;arr) p*=i; return p; }

Re: functional way doing array stuff/ lambda functions

2015-12-12 Thread cym13 via Digitalmars-d-learn
On Saturday, 12 December 2015 at 23:10:21 UTC, Namal wrote: Hello guys, I am still uncertain how to do it right when it comes to lambda functions. If you are looking for the functionnal way I'd advise that you start by looking up three functions in a language-agnostic way: filter, map and

Re: functional way doing array stuff/ lambda functions

2015-12-12 Thread Xinok via Digitalmars-d-learn
On Saturday, 12 December 2015 at 23:36:43 UTC, cym13 wrote: ... So, in your example: int product(const ref int[] arr) { import std.array: array; import std.algorithm: reduce; arr = arr.reduce!((p, i) => p*i).array; } A good post overall but you got reduce wrong. In D, reduce

Re: functional way doing array stuff/ lambda functions

2015-12-12 Thread cym13 via Digitalmars-d-learn
On Saturday, 12 December 2015 at 23:50:55 UTC, Xinok wrote: On Saturday, 12 December 2015 at 23:36:43 UTC, cym13 wrote: ... So, in your example: int product(const ref int[] arr) { import std.array: array; import std.algorithm: reduce; arr = arr.reduce!((p, i) => p*i).array; }

Re: functional way doing array stuff/ lambda functions

2015-12-12 Thread cym13 via Digitalmars-d-learn
On Saturday, 12 December 2015 at 23:59:01 UTC, cym13 wrote: On Saturday, 12 December 2015 at 23:50:55 UTC, Xinok wrote: On Saturday, 12 December 2015 at 23:36:43 UTC, cym13 wrote: ... So, in your example: int product(const ref int[] arr) { import std.array: array; import