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 / learning VS question and GDK?

Author
Message
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 7th Mar 2009 10:27
Hi All

I am converting my weather station project that I made in DarkBasic, however this is a big pices of code and in DBPro I have the file as small file that where joined together when complied.

thew question is how do I do the same in VS.

I can get my code to load in pictures and display them ok if its all in one, however that going to make main very big.

I made a another file and called loadpictures and put #include "loadpictures.ccp" in to main but it fails.

or how do I make it a function call if its called that.

so how do I do this, a key word so that the help files can help or just a bit of guidance.

if helps to see the code say so and I post it.

TIA.

Dark Physics makes any hot drink go cold.
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 7th Mar 2009 12:44
now this runs ok, what I would like to find out is how to have it so that the int are in one file the loadpictures in another and main calling all these bit.




Dark Physics makes any hot drink go cold.
Dar13
16
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 7th Mar 2009 18:26
making header file containing the vars and functions and then including it should let you call them from a separate .cpp different.

...
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 7th Mar 2009 18:48
been trying that all I get then is errors, something about

this is what I have put inthe header



and this is whats in the loadpictures



and this what I have in main



so where have I gone wrong?

Dark Physics makes any hot drink go cold.
Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 7th Mar 2009 18:55
So the header file is "stationfunc.h"?
And the .cpp file is "stationfunc.cpp", right?

Do you have #include "stationfunc.h" at the top of "stationfunc.cpp"?

#ifdef _DEBUG
FixBugs(All);
#endif
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 7th Mar 2009 18:56 Edited at: 7th Mar 2009 19:01
This example code should explain everything you need to know; attached are the project files:

FullInclude.h


Functions.h


Vars.h


Functions.cpp


Main.cpp


Vars.cpp


[edit]
Your code doesn't work because you need to use extern with your variables in the header file and store them in a cpp file. Or you can use #define in the header file if they are constant.

Attachments

Login to view attachments
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 7th Mar 2009 20:42
@Michael P
thanks that helping, not got it working, but then I am trying to
swim before I can float.

@anyone

Its getting there, what do the color line down the side mean I have some green and yellow ones.

plus my for next loop is giving me this error

error C2143: syntax error : missing ';' before '='

see above for how I have put the for next loop in, I get a green line down the side of it.

plus on the
dbLoadImage ( "media\\WeatherStationBanner.bmp" , Weatherbanner );

is giving the error
error C2059: syntax error : ')'

cheers for any help given.

Dark Physics makes any hot drink go cold.
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 7th Mar 2009 22:07
The moonpic for next loop needs to be within the DarkGDK function, and for(moonpic = 0; should be changed to for(int moonpic = 0.

C++ is case sensitive so Weatherbanner needs to be WeatherBanner.


You should have a look at a C++ tutorial e.g. http://www.cplusplus.com/doc/tutorial/
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 8th Mar 2009 00:02
Taken it back to just tring to load one picture using a header, vars and function files, however once again it does not like the identifer.

error C2065: 'WeatherBanner' : undeclared identifier

using const int WeatherBanner ; in h file
and
const int WeatherBanner = 1; in cpp file

So if anyone willing could they show in a project file how to do this, I think its just getting the varable to be seen in all parts.

@Michael P
Cheers good web link, know one that deals with lots of little bit joined together.

Dark Physics makes any hot drink go cold.
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 8th Mar 2009 16:26
movede on a bit, can get the varables setup in a h file, however when I make a function file in h and cpp it then goes wrong.

the code works ok in the main.cpp but when I move into loadpictures cpp it does not work.

I have this in functions.h

and this in loadpictures.cpp


and this line in main.cpp



error is 'dbLoadImage': identifier not found.

so what else do I need to add.

Dark Physics makes any hot drink go cold.
Dar13
16
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 8th Mar 2009 19:25
you have to include DarkGDK.h as well as vars.h in loadpictures.cpp.

...
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 8th Mar 2009 20:24
cheers Dar13, thats move it on, can now see all the pictures up to when I start looking at the moon pictures, the dim moon[] does not see the values stored, even move for loop into loadpictures but still no show.

so how might I get dim bit to work.

TIA.

Dark Physics makes any hot drink go cold.

Login to post a reply

Server time is: 2024-09-30 19:23:45
Your offset time is: 2024-09-30 19:23:45