Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / How do you declare Variables, Strings, and Arrays?

Author
Message
James McGlocken
16
Years of Service
User Offline
Joined: 29th Jan 2008
Location: In The Beautiful Mountains of Vermont
Posted: 8th Feb 2008 04:37
I've used DarkBasic Classic for a while now, so I'm not used to moving to the Visual C++ 2008 envirnment. I know how to declare Variables, Strings, and Arrays in C++, although when I take the code from C++ tutorials on various sites and try to compile it within Visual Studio 2008 it dosn't work.

After clicking New > Project Wizards > Game I have the whole set up in front of me. So now my first test with DarkGDK would be to go into main.cpp and declare some variables, strings, and arrays before moving on.

Ok, so to declare a variable I do:

int Hello=1;
dbMakeObjectSphere ( Hello,100 );

Alright, so that code works perfectly. Now to try a string:

string Hello="hello there";
dbPrint (Hello)

This code will not work. Darned. I'll try a Char statement instead.

char Hello="hello there";
dbPrint (Hello);

Alright I'm lost. I just can't figure out how to properly declare Variables and Strings here.

PHP Programming, Music Composition
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 8th Feb 2008 12:09
You have to use a char pointer, like this: char* hello = "hello there";

A pointer just points to a memory location, and you can use them like arrays.

Of course, you could do this:

char[10] = "hello there";

Your signature has been erased by a mod
James McGlocken
16
Years of Service
User Offline
Joined: 29th Jan 2008
Location: In The Beautiful Mountains of Vermont
Posted: 8th Feb 2008 19:07


Thanks Zotoaster, it works perfectly! Now I think I understand for next loops and if then statements in C++, though I'm still not familiar with arrays and boolean values (I mean I'm not familiar with how the heck to use them in commands like dbText etc...)

How can I create an array like in Darkbasic and then output it in a string like this?

DIM Array[5,5];
Array[3,4]=15;
dbText (0,0,Array[3,4]);

PHP Programming, Music Composition
CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 5th May 2008 21:19
That was a good question!

The answer is:

jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 5th May 2008 21:29
Lots of free to rip and whatever here: http://code.google.com/p/darkgdkoop/ and P.S. Welcome to the DarkSide!

Login to post a reply

Server time is: 2024-11-20 09:36:01
Your offset time is: 2024-11-20 09:36:01