Re: Programming on OSX

2012-01-01 Thread Joel Christensen
On 01-Jan-12 3:27 AM, Jacob Carlborg wrote: On 2011-12-31 00:50, Joel Christensen wrote: I've got an Mac with OSX. But I have a few problems with using it with D. 1. I haven't got any media programming going. Could you please elaborate. Derelict is a library that contains bindings for OpenGL

Programming on OSX

2011-12-30 Thread Joel Christensen
I've got an Mac with OSX. But I have a few problems with using it with D. 1. I haven't got any media programming going. 2. The readln (etc) isn't much good, same problem as Linux. It can only add characters and remove characters from the end.

Re: xml Bible for conversion for D

2011-10-19 Thread Joel Christensen
I don't care to learn xml at this stage. I just want to use it on that Bible file. On 19-Oct-11 8:03 PM, Bernard Helyer wrote: I think I want to stick with the current std xml library for now.

Re: xml Bible for conversion for D

2011-10-19 Thread Joel Christensen
Thanks Adam. :-) It seems to be working now, with the stuff you gave me. I was thinking of making a text file from it that my programs can load from. avoiding the xml file, so they load faster. But I think I'll have my program(s) use the xml file each time they're run, in the mean time.

xml Bible for conversion for D

2011-10-18 Thread Joel Christensen
I've got xml text of a Bible version. I want to get the text in the following format: class Bible { Book[] bs; } class Book { Chapter[] cs; } class Chapter { Verse[] vs; } class Verse { string v; } Here's a part of the xml file: ?xml version=1.0 encoding=ISO-8859-1? bible b

Re: xml Bible for conversion for D

2011-10-18 Thread Joel Christensen
I think I want to stick with the current std xml library for now. I think the books example is too different for me to work for what I want.

Get current date and time with std.datetime

2011-10-07 Thread Joel Christensen
Hi, I have a program that uses the old time stuff before the module std.datetime. I have a DateTime object, but I can't seem to set its properties to the current time. Some thing like: DateTime dateTime; dateTime = getCurrentDateTime(); -JoelCNZ

Re: Get current date and time with std.datetime

2011-10-07 Thread Joel Christensen
http://d-programming-language.org/intro-to-datetime.html Thanks Jonathan, that helped I think, (haven't read it all, though). But I've got errors with some of the date times not being able to change them with int's values. task.d(44): Error: function std.datetime.DateTime.month () const is

Re: copy and paste in program

2011-09-12 Thread Joel Christensen
I mean, I can't copy text from my program to the clipboard. - Joelcnz On 12-Sep-11 3:50 PM, Joel Christensen wrote: Thanks Jimmy. Your example worked. Or though I haven't managed to get the other way to work. [code] import std.stdio; //import core.stdc.string; import std.c.string; import

Re: copy and paste in program

2011-09-12 Thread Joel Christensen
Thanks so much Jimmy. You put in a bit of effort. :-) I just added this code to my general library: extern(Windows) { bool OpenClipboard(void*); void* GetClipboardData(uint); void* SetClipboardData(uint, void*); bool EmptyClipboard(); bool CloseClipboard(); void*

copy and paste in program

2011-09-11 Thread Joel Christensen
Hi, I've got a text program I'm working on. It has game like print. But I want to be able to copy to the clip board and paste from it in my program etc. I'm using Windows 7. I have used a bit of Ubuntu in the past. - Joelcnz

Re: copy and paste in program

2011-09-11 Thread Joel Christensen
: Well, it doesn't matter what you've used in the past :-) Take a look: http://msdn.microsoft.com/en-us/library/ms907128.aspx On Sun, Sep 11, 2011 at 5:29 PM, Joel Christensen joel...@gmail.com mailto:joel...@gmail.com wrote: Hi, I've got a text program I'm working on. It has game like print

Re: copy and paste in program

2011-09-11 Thread Joel Christensen
So how would I got about doing it in D? On 12-Sep-11 1:52 PM, Vladimir Panteleev wrote: On Mon, 12 Sep 2011 04:39:52 +0300, Joel Christensen joel...@gmail.com wrote: I'm not sure I would be able to get Windows CE Clipboard stuff working for me. Search engines often return Windows CE results

Re: copy and paste in program

2011-09-11 Thread Joel Christensen
Thanks Jimmy. Your example worked. Or though I haven't managed to get the other way to work. [code] import std.stdio; //import core.stdc.string; import std.c.string; import std.string; import std.conv; extern(Windows) { bool OpenClipboard(void*); void* GetClipboardData(uint); void*

toStringz, and memory management, also fromStringz

2011-09-09 Thread Joel Christensen
Hi, In the std.string document at toStringz it has this note: Important Note: When passing a char* to a C function, and the C function keeps it around for any reason, make sure that you keep a reference to it in your D code. Otherwise, it may go away during a garbage collection cycle and

Re: toStringz, and memory management, also fromStringz

2011-09-09 Thread Joel Christensen
On 10-Sep-11 3:09 PM, Jonathan M Davis wrote: Jonathan M Davis Ok, now I have a better idea with char pointers. And the std.conv.to worked too. Thanks. - Joelcnz

Re: DMD 2.055

2011-09-08 Thread Joel Christensen
Also I can't compile programs like this any more: \D\dmd2\windows\bin\dmd file1 file2 etc. I've been using Geany (a light IDE), now I have to use the terminal to compile my programs (also clicking on a batch file), before I could compile with the hit of a key. Actually I fix my problem in my

Re: DMD 2.055

2011-09-08 Thread Joel Christensen
On 08-Sep-11 9:05 PM, Johannes Pfau wrote: cast(string delegate(string)) Thanks Johannes, that's better than my way. :-) - Joelcnz

Multiple subtyping

2011-08-25 Thread Joel Christensen
Hi, Has anyone had much experience with multiple subtyping. //Org: based on page 232 (6.13.1) in The D Programming Language book //#save(); without storeShape does not work import std.stdio; class Shape { void shape() { writeln( Shape ); } } class DataBase {

Re: Reading by character and by line from stdin

2011-08-25 Thread Joel Christensen
On 26-Aug-11 10:20 AM, Timon Gehr wrote: On 08/26/2011 12:19 AM, Timon Gehr wrote: On 08/25/2011 11:34 PM, bellinom wrote: whoops, this is better: auto arr=to!(int[])(split(strip!(readln(; Or, auto arr2=to!(int[])( readln.strip.split ); Got rid of the second ! too (does not work with

Re: delegate object instead of a literal

2011-08-15 Thread Joel Christensen
On 15-Aug-11 5:21 PM, Joel Christensen wrote: On 15-Aug-11 2:55 PM, Jonathan M Davis wrote: On Sunday, August 14, 2011 20:50:03 Joel Christensen wrote: Hi, This program loops through a string until it finds a number and gives the position of it. The first assert works, but not the second one

Re: delegate object instead of a literal

2011-08-15 Thread Joel Christensen
Ok, this is a good one I think. import std.string, std.algorithm, std.functional; bool isANum( dchar chr ) { return inPattern( chr, digits ~ `+-.` ); } void main() { auto input = `abc123`; auto indexEnd = -1; indexEnd = count!( not!isANum )( input ); assert( indexEnd

Re: delegate object instead of a literal

2011-08-15 Thread Joel Christensen
On 16-Aug-11 10:22 AM, Jonathan M Davis wrote: On Monday, August 15, 2011 14:28 Jonathan M Davis wrote: On Monday, August 15, 2011 02:25 Joel Christensen wrote: Ok, this is a good one I think. import std.string, std.algorithm, std.functional; bool isANum( dchar chr ) { return inPattern( chr

delegate object instead of a literal

2011-08-14 Thread Joel Christensen
Hi, This program loops through a string until it finds a number and gives the position of it. The first assert works, but not the second one. import std.algorithm; void main() { static bool isNumber( char input, char dummy ) { if ( ( input = '0' input = '9' ) ||

Re: delegate object instead of a literal

2011-08-14 Thread Joel Christensen
On 14-Aug-11 10:44 PM, Jonathan M Davis wrote: On Sunday, August 14, 2011 03:23:39 Jonathan M Davis wrote: On Sunday, August 14, 2011 20:50:03 Joel Christensen wrote: Hi, This program loops through a string until it finds a number and gives the position of it. The first assert works

Re: delegate object instead of a literal

2011-08-14 Thread Joel Christensen
On 15-Aug-11 2:55 PM, Jonathan M Davis wrote: On Sunday, August 14, 2011 20:50:03 Joel Christensen wrote: Hi, This program loops through a string until it finds a number and gives the position of it. The first assert works, but not the second one. import std.algorithm; void main

Re: ref int value() { return m_value; } - uses?

2011-07-31 Thread Joel Christensen
value it being set to at the method definition (could with 'ref auto xpos( int value ) { ... return m_xpos; }' :-/). And having two methods, one for getter and one for setter, you can't do stuff like 'xpos++;' - Joel Christensen

ref int value() { return m_value; } - uses?

2011-07-29 Thread Joel Christensen
What use is the property thing? class Test { private int m_value; @property ref int value() { return m_value; } } void main() { auto test = new Test; test.value += 1; } Or this: import std.stdio: writeln; import std.conv: to; class Test { private string

Re: r/w binary

2011-07-01 Thread Joel Christensen
Ok, I get you. A whole int*, not one byte of the int* data. - Joel On 01-Jul-11 6:07 AM, Ali Çehreli wrote: On Fri, 01 Jul 2011 05:28:56 +1200, Joel Christensen wrote: Shouldn't file.rawWrite((i)[0..1]); have [0..4]? Or am I missing some thing? [0..1] follows the regular slicing syntax

Re: r/w binary

2011-06-30 Thread Joel Christensen
Yes, portability, I hadn't thought of that. Shouldn't file.rawWrite((i)[0..1]); have [0..4]? Or am I missing some thing? - Joel On 30-Jun-11 7:53 PM, Ali Çehreli wrote: On Thu, 30 Jun 2011 15:52:59 +1200, Joel Christensen wrote: I'm thinking more about handling binary files. With the C

Re: r/w binary

2011-06-29 Thread Joel Christensen
, Joel Christensen wrote: I want to save and load levels for my game. The std.stream module doesn't have much examples. Here is my code: void saveLevel( string fileName ) { auto bfile = new std.stream.File; int ver = 1; string verStr = version:; with( bfile

Re: r/w binary

2011-06-29 Thread Joel Christensen
With the char[], I can't use spaces in it the way I've got it here, (like if I tried using a phrase): void saveLevel( string fileName ) { int ver = 1; auto house = two.dup; double rnum = 3.0; { auto fout = File( fileName, wb); // open for

Re: r/w binary

2011-06-29 Thread Joel Christensen
file and it's a text file. So in that case I would use read line to have spaces in strings, though what if I wanted to have new line character(s) in the one string. I still want to work with binary files. On 30-Jun-11 2:23 AM, Ali Çehreli wrote: On Wed, 29 Jun 2011 19:55:38 +1200, Joel

r/w binary

2011-06-28 Thread Joel Christensen
I want to save and load levels for my game. The std.stream module doesn't have much examples. Here is my code: void saveLevel( string fileName ) { auto bfile = new std.stream.File; int ver = 1; string verStr = version:; with( bfile ) { scope(

Re: sort!(a b)( arr ); - opCmp

2011-06-17 Thread Joel Christensen
Yeah, it works now. Thanks David :-) I have actually used type o = cast(type)variable; But had forgotten about it. Though the super part of what you said is more subtle.

Physics engine, eg Blaze

2011-06-15 Thread Joel Christensen
I've got a GUI (GtkD) and a game library (DAllegro5) going. But I'm thinking a physics library would be wanted. I had a go at making Blaze work with D2.0. I got it to compile and had things fall down the screen with it, but the original it hasn't been updated for 2 years, I think. Blaze is

Re: Next Release

2011-04-23 Thread Joel Christensen
Ok, I was just making sure. I guess you would surely know about that. I actually made a program that used date and time before your library. Not nice. I guess I should go and revisit it. I use the program of mine too, it boots with Windows.

Re: Next Release

2011-04-22 Thread Joel Christensen
Well, then I'd better make sure that I get my most recent updates to std.datetime in soon. - Jonathan M Davis Does your library take into account that there's no year 0?

Re: I seem to be able to crash writefln

2011-03-15 Thread Joel Christensen
On 15/03/2011 1:57 a.m., Steven Schveighoffer wrote: On Fri, 11 Mar 2011 18:57:32 -0500, Spacen Jasset spacenjas...@yahoo.co.uk wrote: On 10/03/2011 12:18, Steven Schveighoffer wrote: On Wed, 09 Mar 2011 18:19:55 -0500, Joel Christensen joel...@gmail.com wrote: This is on Windows 7. Using

I seem to be able to crash writefln

2011-03-09 Thread Joel Christensen
This is on Windows 7. Using a def file to stop the terminal window coming up. win.def EXETYPE NT SUBSYSTEM WINDOWS bug.d import std.stdio; import std.string; void main() { auto f = File( z.txt, w ); scope( exit ) f.close; string foo = bar;

Re: I seem to be able to crash writefln

2011-03-09 Thread Joel Christensen
On 10-Mar-11 1:04 PM, spir wrote: On 03/10/2011 12:19 AM, Joel Christensen wrote: This is on Windows 7. Using a def file to stop the terminal window coming up. win.def EXETYPE NT SUBSYSTEM WINDOWS bug.d import std.stdio; import std.string; void main() { auto f = File( z.txt, w ); scope( exit

Re: Icons

2011-02-27 Thread Joel Christensen
Thanks, Chapman :-), I followed your instructions and they worked.

Re: Icons

2011-02-27 Thread Joel Christensen
I got it working with the DAllegro (Allegro 4.2) game library as well!

Icons

2011-02-26 Thread Joel Christensen
I noticed in windows with D you can use .res (eg. dmd main.d smile.res) files for icons any way. but how do you make icon .res files?

Re: Icons

2011-02-26 Thread Joel Christensen
On 27-Feb-11 12:56 AM, J Chapman wrote: == Quote from Joel Christensen (joel...@gmail.com)'s article I noticed in windows with D you can use .res (eg. dmd main.d smile.res) files for icons any way. but how do you make icon .res files? With a resource compiler. Digital Mars supplies one

Re: Icons

2011-02-26 Thread Joel Christensen
On 27-Feb-11 11:24 AM, Joel Christensen wrote: On 27-Feb-11 12:56 AM, J Chapman wrote: == Quote from Joel Christensen (joel...@gmail.com)'s article I noticed in windows with D you can use .res (eg. dmd main.d smile.res) files for icons any way. but how do you make icon .res files

Re: Error when exiting program

2011-02-20 Thread Joel Christensen
On 19-Feb-11 6:53 PM, Jesse Phillips wrote: Joel Christensen Wrote: I'm using some one else's bindings to a C library. The problem seems to be limited to D2 programs. Error as follows: An exception was thrown while finalizing an instance of class jec2.bmp.Bmp I also get other errors

Error when exiting program

2011-02-18 Thread Joel Christensen
I'm using some one else's bindings to a C library. The problem seems to be limited to D2 programs. Error as follows: An exception was thrown while finalizing an instance of class jec2.bmp.Bmp I also get other errors at program exit. Thanks for any help. :-)

Exiting program problems, DAllegro

2011-02-17 Thread Joel Christensen
I'm using a wrapper (or what ever it's called ) that I made on top of DAllegro binding of the C library Allegro). But I get this error when exiting a DAllegro program with my JEC2 library. It's a long standing problem I've had. I think it's my JEC2 library that makes it fail. An exception

Re: ASM access to array

2011-02-02 Thread Joel Christensen
What about my edited version: import std.stdio; uint rotl_d(uint value,ubyte rotation){ return (valuerotation) | (value(value.sizeof*8 - rotation)); } uint rotl_asm(uint value,ubyte rotation){ asm{ mov EAX, value; // get first argument mov CL , rotation; // how many

Re: [D1] assert failure expression.c

2010-10-10 Thread Joel Christensen
Looks like there's no problem to me, except with the code. char[] foo() { char[2] res = 1 ; res[1] = ;; // should be res[1] = ';'; return res; } I don't think you can have an incomplete mixin.

Re: linked list

2010-09-27 Thread Joel Christensen
Thanks for the long winded reply Jonathan. I don't know how to avoid using my own linked list, I have next/prev in each class (Ball, Lazer and Mine ) in the list. Thanks bearophile, I had a bit of a look at that site. My game is simple so just maybe the easiest way is the way to go, though

Re: intrusive linked list

2010-09-27 Thread Joel Christensen
That's called intrusive linked list, and I find using it quite viable: zero-allocation O(1) add/removal is a very strong characteristics. They are very useful especially for lock-free algorithms. That's for the info Denis. I got the idea from a friend who is interested in how to make games.

Re: std.c.stdio, std.stream std.c.file, ranges

2010-09-26 Thread Joel Christensen
Thanks for your reply Jonathan. Yes, I heard about stream being replaced, but since my code with binary files isn't very much, I can just redo it if I have to. I think I'll continue using std.c.file for the time being. I should learn about ranges. I tried std.stdio already. It's been been

Re: linked list, ranges

2010-09-26 Thread Joel Christensen
Thanks again for the reply Jonathan. I'm using doublely linked list I made for a game where ships and there lazer bolts are in the same list. Without linked list I couldn't do things like create a lazer bolt or remove one while trans-versing the linked list. I had to use my own linked list,

Re: linked list

2010-09-26 Thread Joel Christensen
I am looking for use cases of singly|doubly linked lists, I (nearly) never need them in my code. Few questions: 1) What's a typical (or average) length of your list? Thanks for your interest bearophile. I haven't used linked list much more than just trying them out. And my game is at its

Re: linked list

2010-09-26 Thread Joel Christensen
I normally use D's built in dynamic arrays. but it doesn't work with adding and removing with the foreach loop (like removing an object from the list while still going through the list).

date and time

2010-09-25 Thread Joel Christensen
I'm using D2.049. I have a program in which I want to be able to get the current time as one number, also be able to change the hour and stuff then convert it back to one number. I'm saving just the one number to file. Thanks in advance. :-)

Re: date and time

2010-09-25 Thread Joel Christensen
I've tried that module. I was putting: long dt = UTCtoLocalTime(getUTCtime - (msPerDay / 2)); Then when daylight savings came it was wrong, (computer was right mind). long datetime = UTCtoLocalTime(getUTCtime); It is 1 hour and half a day out. It was the right hour till daylight savings. I

Re: date and time, core access

2010-09-25 Thread Joel Christensen
Thanks for the replies Jonathan M Davis and Yao G. :-) Good to hear it's being worked on. I've other programs that are done with D1.0 that are all right. I'm using Windows, would like it to work on Linux too though. I think I'll use year month etc. separately instead of just having a big

Re: date and time, std.c.stdio

2010-09-25 Thread Joel Christensen
Thanks Jonathan. My plan is to use the C version, and not use the big time_t number. I'm actually using std.c.stdio module too, for binary files, I probably should use std.stream or some thing.

Re: Dynamic method example in TDPL

2010-08-31 Thread Joel Christensen
Thanks for the fix up Philippe. Just a little note. Where it says 'DynMethod m', you can put 'auto m', but I'm wondering is it some times clearer to have the class name even though 'auto' works.

Reading stdin in Windows 7

2010-08-31 Thread Joel Christensen
, or Windows's piping? -- Aug 17 Jesse Phillips jessekphillips+D gmail.com In my experience Windows hasn't gotten piping right. And it has been known to have bugs, this might be related: http://stackoverflow.com/questions/466801/python-piping-on-windows-why-does-this-not-work Aug 18 Joel Christensen

Dynamic method example in TDPL

2010-08-20 Thread Joel Christensen
I've typed this example program in, but it doesn't compile. I looked up the The D programming language errata but it wasn't listed. I'm using DMD v2.048. /** Date: Aug 20, 2010 This was copied from TDPL book pages 386 - 387 */ module dynamicmethods; import std.stdio; import

Programming test - using strings

2009-12-16 Thread Joel Christensen
Any one interested in doing D versions of this program? http://www.rubyquiz.com/quiz14.html

Re: Explicit ordering with std.format

2009-12-05 Thread Joel Christensen
Tomek Sowiński wrote: An extract from java.util.Formatter docs: // Explicit argument indices may be used to re-order output. formatter.format(%4$2s %3$2s %2$2s %1$2s, a, b, c, d) // - d c b a How do I achieve this with std.format? The ddocs only say that variadic arguments are consumed in

Re: anonymous function/deleget usage

2009-11-12 Thread Joel Christensen
Sam Hu wrote: How can I reach something like below code: int a=1; int b=2; int c=(int a,int b){ return a+b;} writefln(Result:%d,c); Thanks in advance. int a=1; int b=2; int add(int a,int b) { return a+b; } int c=add(a,b); writefln(Result:%d,c); Nested functions are cool. :-)

Re: FMOD working with Windows

2009-11-09 Thread Joel Christensen
Now I get the error using coffimplib.exe 'Error: missing archive signature'.

Re: FMOD working with Windows

2009-11-09 Thread Joel Christensen
grauzone wrote: Joel Christensen wrote: FMOD sound (record and play) is off D Programming web site. http://wiki.dprogramming.com/FMod/HomePage I followed instructions from the web site. But one instruction said to use 'coffimplib.exe' but I couldn't see where it is to download it, and one

Re: Descent eclipse plugin - auto code completion

2009-11-05 Thread Joel Christensen
Do you have something in the Error Log (Window - Show View - Error Log)? How is your project configured? Do you have phobos or Tango in the include path? My Eclipse doesn't have a thing called Error Log. I can't see more than 'D Build Path' to configure. I've been testing with Tangos

Re: cast(int) getting an unexpected number

2009-11-04 Thread Joel Christensen
To be safe, whenever converting to int, always add a small epsilon. I think you can use float.epsilon, but I don't have any experience with whether that is always reasonable. -Steve Thanks every one for the replies. I still have problems. How do I use epsilon? 'real' helps in my example

Re: FMOD working with Windows

2009-10-28 Thread Joel Christensen
Moritz Warning wrote: On Wed, 28 Oct 2009 14:37:22 +1300, Joel Christensen wrote: FMOD sound (record and play) is off D Programming web site. http://wiki.dprogramming.com/FMod/HomePage I followed instructions from the web site. But one instruction said to use 'coffimplib.exe' but I couldn't

FMOD working with Windows

2009-10-27 Thread Joel Christensen
FMOD sound (record and play) is off D Programming web site. http://wiki.dprogramming.com/FMod/HomePage I followed instructions from the web site. But one instruction said to use 'coffimplib.exe' but I couldn't see where it is to download it, and one link wasn't found (Dr.Dobb).

Re: Trying to get DMD bundled with libs

2009-09-08 Thread Joel Christensen
Jarrett Billingsley wrote: On Mon, Sep 7, 2009 at 6:44 AM, Joel Christensenjoel...@gmail.com wrote: div0 wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Joel Christensen wrote: I noticed you can get DMD bundled with various libraries. I found you had to login to another web site

Trying to get DMD bundled with libs

2009-09-05 Thread Joel Christensen
I noticed you can get DMD bundled with various libraries. I found you had to login to another web site, but the registery page has 3 must fill in textbox's that are crazy.

Re: Should be easy

2009-06-12 Thread Joel Christensen
For 2 dim array I like auto a=new char[][](40,25); so that a[39][24]='B'; 'B' is at the bottom right of the 2D array.

Errors since dmd 1.045

2009-06-10 Thread Joel Christensen
Joel Christensen wrote: See previous post.

Error 1: Previous Definition Different, Error 42: Symbol Undefined

2009-06-09 Thread Joel Christensen
I get this error with dmd 1.045. The _errno seems to be with the DAllegro (http://www.dsource.org/projects/dallegro) library. And the 42 one to do with some thing of mine. OPTLINK (R) for Win32 Release 8.00.1 Copyright (C) Digital Mars 1989-2004 All rights reserved.