Re: cast a C char array - offset ?

2015-02-04 Thread ketmar via Digitalmars-d-learn
On Wed, 04 Feb 2015 16:09:24 +, irtcupc wrote: Thx again for your help Ketmar and FG, Thx again for the help in the other Q too (the one about snn imports), I share the binding, it's nothing at all but was a fun to do on a off-day... https://github.com/BBasile/dbeaengine you may want

Re: cast a C char array - offset ?

2015-02-04 Thread irtcupc via Digitalmars-d-learn
On Monday, 2 February 2015 at 13:40:30 UTC, irtcupc wrote: On Monday, 2 February 2015 at 13:34:28 UTC, ketmar wrote: On Mon, 02 Feb 2015 13:32:57 +, ketmar wrote: On Mon, 02 Feb 2015 13:23:23 +, irtcupc wrote: my current understanding is that: - C: char

Re: Record separator is being lost after string cast

2015-02-04 Thread Kagamin via Digitalmars-d-learn
Looks like RS is an unprintable character, that's why you don't see it in console.

Record separator is being lost after string cast

2015-02-04 Thread Kadir Erdem Demir via Digitalmars-d-learn
I am opening a .gz file and reading it chunk by chunk for uncompressing it. The data in the uncompressed file is like : aRSbRScRSd, There are record separators(ASCII code 30) between each record(records in my dummy example a,b,c). File file = File(mylog.gz, r); auto uc = new

Re: Record separator is being lost after string cast

2015-02-04 Thread Kadir Erdem Demir via Digitalmars-d-learn
don't beleive what you see! ;-) I am sorry make a busy community more busy with false alarms. When I write to file I saw Record Separator really exists. I hope my second question is a valid one. How can I write the code below better? How can I reduce the number of foreach? statements.

Re: Record separator is being lost after string cast

2015-02-04 Thread Kagamin via Digitalmars-d-learn
You can use C functions in D too: import core.stdc.stdio; ubyte[] temp = [ 65, 30, 66, 30, 67, 0]; puts(cast(char*)temp.ptr);

Re: Record separator is being lost after string cast

2015-02-04 Thread ketmar via Digitalmars-d-learn
On Wed, 04 Feb 2015 08:13:28 +, Kadir Erdem Demir wrote: A more general and understandable code for first question : ubyte[] temp = [ 65, 30, 66, 30, 67]; writeln(temp); string tempStr = cast(string) temp; writeln (tempStr); Result is : ABC which is not desired.

Re: Concurrent Thread Safe List?

2015-02-04 Thread Ali Çehreli via Digitalmars-d-learn
On 02/04/2015 12:10 PM, Gan wrote: I'm looking for a non-blocking way of a thread pushing objects into a list and another thread able to pull objects from the same list. Thread 1 pushes objects onto the list, Thread 2 pulls the oldest objects off the list. Does D language have something like

Re: Problem with creating a new account on wiki.dlang.org

2015-02-04 Thread Piotrek via Digitalmars-d-learn
On Wednesday, 4 February 2015 at 07:02:01 UTC, Zach the Mystic wrote: Vladimir fixed it. Yay! That was quick action. Thank you both Zach and Vladimir. Piotrek

Concurrent Thread Safe List?

2015-02-04 Thread Gan via Digitalmars-d-learn
I'm looking for a non-blocking way of a thread pushing objects into a list and another thread able to pull objects from the same list. Thread 1 pushes objects onto the list, Thread 2 pulls the oldest objects off the list. Does D language have something like that?

Re: What am I doing Wrong (OpenGL SDL)

2015-02-04 Thread Entity325 via Digitalmars-d-learn
I will see how much I can strip away and still reproduce the problem. If I find the cause before then, I'll be sure to report back here.

Re: What am I doing Wrong (OpenGL SDL)

2015-02-04 Thread Entity325 via Digitalmars-d-learn
I am having a problem which is similar in appearance to the OP's, but it does not seem to be similar in function. When I try to execute any of the Gl functions in the (protected) DerelictGL3.gl.loadSymbols function, I get an access violation. Checking for null reveals that the functions are

Re: Concurrent Thread Safe List?

2015-02-04 Thread Gan via Digitalmars-d-learn
On Wednesday, 4 February 2015 at 22:14:31 UTC, Ali Çehreli wrote: On 02/04/2015 12:10 PM, Gan wrote: I'm looking for a non-blocking way of a thread pushing objects into a list and another thread able to pull objects from the same list. Thread 1 pushes objects onto the list, Thread 2 pulls the

Re: Concurrent Thread Safe List?

2015-02-04 Thread Gan via Digitalmars-d-learn
On Thursday, 5 February 2015 at 02:13:23 UTC, Gan wrote: On Wednesday, 4 February 2015 at 22:14:31 UTC, Ali Çehreli wrote: On 02/04/2015 12:10 PM, Gan wrote: I'm looking for a non-blocking way of a thread pushing objects into a list and another thread able to pull objects from the same list.

Re: how can I get a reference of array?

2015-02-04 Thread Ali Çehreli via Digitalmars-d-learn
On 02/04/2015 10:42 PM, zhmt wrote: Here is a simple code snippet: class A { public int[] arr; } class B { public int[] arr; } void main() { int[] arr; A a = new A; B b = new B; a.arr = arr; b.arr = arr; arr ~= 1; arr ~= -2; foreach(data;

Re: What am I doing Wrong (OpenGL SDL)

2015-02-04 Thread Entity325 via Digitalmars-d-learn
On Thursday, 5 February 2015 at 06:07:34 UTC, Entity325 wrote: I will see how much I can strip away and still reproduce the problem. If I find the cause before then, I'll be sure to report back here. I don't know if this is relevant, but while stripping down my code, I discovered that

Re: What am I doing Wrong (OpenGL SDL)

2015-02-04 Thread drug via Digitalmars-d-learn
On 05.02.2015 09:57, Entity325 wrote: On Thursday, 5 February 2015 at 06:07:34 UTC, Entity325 wrote: I will see how much I can strip away and still reproduce the problem. If I find the cause before then, I'll be sure to report back here. I don't know if this is relevant, but while stripping

Re: What am I doing Wrong (OpenGL SDL)

2015-02-04 Thread Entity325 via Digitalmars-d-learn
On Thursday, 5 February 2015 at 07:23:15 UTC, drug wrote: Look at this https://github.com/drug007/geoviewer/blob/master/src/sdlapp.d I used here SDL and OpenGL and it worked. Ctor of SDLApp creates SDL window with OpenGL context, may be it helps. Tested your code. Symbols still not being

Re: how can I get a reference of array?

2015-02-04 Thread zhmt via Digitalmars-d-learn
void test(ref int[] arr) { arr ~= 4; } It is something like ref variables. But ref just be used in function declaration.

Re: how can I get a reference of array?

2015-02-04 Thread zhmt via Digitalmars-d-learn
@Ali I know the direction now, I should learn more about the pointers. Thx very much.

how can I get a reference of array?

2015-02-04 Thread zhmt via Digitalmars-d-learn
Here is a simple code snippet: class A { public int[] arr; } class B { public int[] arr; } void main() { int[] arr; A a = new A; B b = new B; a.arr = arr; b.arr = arr; arr ~= 1; arr ~= -2; foreach(data; a.arr)

Re: Record separator is being lost after string cast

2015-02-04 Thread Kadir Erdem Demir via Digitalmars-d-learn
Thanks a lot, I will follow your advise and implement this part same as your example. Regards Kadir Erdem

Re: Want to read a whole file as utf-8

2015-02-04 Thread Foo via Digitalmars-d-learn
Since I'm now almost finished, I'm glad to show you my work: https://github.com/Dgame/m3 You're free to use it or to contribute to it.

Re: Record separator is being lost after string cast

2015-02-04 Thread ketmar via Digitalmars-d-learn
On Wed, 04 Feb 2015 09:28:27 +, Kadir Erdem Demir wrote: I am sorry make a busy community more busy with false alarms. don't mind it. ;-) D.learn is for *any* questions about language, no matter how strange they may seem. How can I write the code below better? How can I reduce the number

Re: What am I doing Wrong (OpenGL SDL)

2015-02-04 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 5 February 2015 at 01:51:05 UTC, Entity325 wrote: I am having a problem which is similar in appearance to the OP's, but it does not seem to be similar in function. When I try to execute any of the Gl functions in the (protected) DerelictGL3.gl.loadSymbols function, I get an access

Re: Concurrent Thread Safe List?

2015-02-04 Thread Ali Çehreli via Digitalmars-d-learn
On 02/04/2015 06:33 PM, Gan wrote: If I want a non blocking receive call, would I do bool receiveTimeout(T...)(Duration duration, T ops); with a duration of 0? Yes but I am not sure whether the thread simply checks whether there is a message or also sleeps for 0 msecs. Ali