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 / input problems

Author
Message
sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 17th Dec 2007 21:07
what does this error want me to do?
('dbinput' : undeclared identifier)
here is the input code:


why do I have this error??

( : error C2144: syntax error : 'char' should be preceded by ')'
I have a ')' there. I tryed a nother one and it did not work.

Now there is this 'dbLoadObject' : no overloaded function takes 0 arguments)
What should I do with this????? What is a overloaded function????
I know this is a lot. but one more thing.
I been reading about char, now when I declare a char arrays for the
model should do it like this
char model
or like this
char buffer[100]
Noe this is alot, let try one think at a time, lets start with the input.

dbinput " model name ( must be an .X or DBO like man.x or man.dbo): ",model;

Why won't this compile?

Thank You
renny

PS ther is one more error:
error C2181: illegal else without matching if

I have a if statement, do I need a nother one?
sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 17th Dec 2007 21:55
OH no, I can't think that I would do somtthing like that.
ok I will go to the other computer and try that out. Dumb dumb
Sorry for that.
But I been lookind at the if and else statement at http://www.cplusplus.com/doc/tutorial/

here is a if else statement

For example:




Now this is just like my if else statement, but I get errors on mine.
aersixb9
16
Years of Service
User Offline
Joined: 29th Nov 2007
Location:
Posted: 17th Dec 2007 22:16 Edited at: 17th Dec 2007 22:26
I think you're missing a '{' somewhere in there...or you have an extra one, or something like that.

The rule is that if statements need a { and a } if there's more than one statement following the if. Also don't use extra { and }'s, it looks like you have extra {}'s.

Please indent your code properly. If you're inside a {, put an extra tab in there. It makes your code easier to read, and will also point out any mismatched {}'s.

Also, on reading it further, your code is downright wacky. You're not doing input right. I don't actually know how to do input in DarkGDK...so someone else might nicely post a little dbInput tutorial. I'll read it too. Maybe a good explanation of variables also?

Like when you input, you have to store it in a variable. A variable is something that holds data, like numbers, integers, or characters. A "char" is a type of variable, not a variable. That is to say, to "declare" a variable. (this is different from basic, where you do not need to "declare" variables. In C++ you must "declare" all your variables.)

When you declare a variable, you're telling the compiler what kind of a variable it is. Kind of like how in basic variables were either numbers or strings, and strings were suffixed with a "$". In

In C++ there are more than just numbers and strings, there are lots of specific kinds of numbers, like ints and longs and floats and doubles. Since it's a low-level (or mid-level) language, C++ requires that you say how many bytes of memory is consumed by each variable.

You do that by saying the type of the variable before you start using it. So if you want a variable called "distance", you have to say
int distance; (32 or 64 bit (same size as the registers on the CPU, which is the 'bits' of the cpu) whole number, may be positive or negative)
or
float distance; (32 bits (1 register) floating point (decimal) number
or
long distance; (2 register, 64 bit number)
or
double distance; (2 register, 64 bit floating point (decimal number))

Those are the numbers, there's also the 'character' - named 'char'. It's an 8-bit, 1 byte, "number" that is commonly interpreted as a letter via an ASCII table.

For input, you want to use either
a) an array of characters
b) a "string"

I don't actually know how to use strings (heh), but an array is simply a bunch of one type of variables. Like
int myInts[40];
makes 40 integer variables consuming 1280 bits of memory on 32-bit cpus, and 2560 bits of memory on 64-bit cpus!

If you want to record a bunch of keystrokes, like the user would type in into a dbInput command, you'll need to use either a string or an array of characters. You can declare an array of characters like so:
char myLetters[256];
This will give you a variable named "myLetters" that can hold up to 255 characters, plus 1 special character that goes at the end of most strings (so you know where the end of the string is, if it's only like 10 letters long, the 11th letter will be the special character). It's not something that I can type on the keyboard, but it's ASCII value is 0, which may seem confusing. It's commonly written as '\0', or the backslash-zero characters. In this case two characters are used to represent one character that doesn't have a corresponding keyboard button.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 17th Dec 2007 22:24
Agreed. SadSack - I do this "Style" to help with spotting that junk -

(note this forum doesn't respect my style to the byte...almost but... so it may drift or look unaligned)



aersixb9
16
Years of Service
User Offline
Joined: 29th Nov 2007
Location:
Posted: 17th Dec 2007 22:28 Edited at: 17th Dec 2007 22:28
Actually, after reading his code one more time,

Should probably be:

Unlike in basic, you need to put ()'s around function calls. (Or "subroutine" calls) And you also need to capitalize the "I" on "dbInput(...)".
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 17th Dec 2007 22:55
sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 17th Dec 2007 23:58
Well, I should came sooner, I beew working on this for almost 3 hours. Ok I will tell you where I am at. I have went over the code 100 time and got it to compile with out any errors. That is nice.
But it will not load a object or the cube that it should if no object is enter. I think the problem is in the string, it is not being givien to the loadobject (string) or the object will not load.
I loaded some object into the program by using code and I could see then fine.
but every thing works fine but for the loading and no errors.
here the code:


here I think is the problem code:



I used the same loadobject to load the object. I just change it from :
dbLoadObject ("model",2);
to

dbLoadObject ("well1.dbo",2);
and it loaded ok.

I think it is in the string(model).
what would be the best wait to test it ,the model string? may be see if I can print it out.
Thanks I am going back to the work computer and work on it some more.
Thanks
renny
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 18th Dec 2007 01:07
dbPrint(model); should work.

Also - You have SetCurrentDirectory I use dbSetDir

Plus - I have better luck using forward slash - no fear about forgetting to make double backslashes all the time

sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 18th Dec 2007 01:40 Edited at: 18th Dec 2007 01:41
Well I got every thing working but the loadobject(model,2); and it will not print out. so that is where the problem is. Now how do I fix it.
This is how I declear the string:char model[100];

Then i have dbInput(),model;
here is what the help say about it.

dbInput
This command will accept input data from the keyboard and store the entry in the specified variable. The string that heads the input command is optional, and allows the user to provide an on-screen prompt for the data. The data is output to the screen as it is entered.

Syntax
void dbInput ( char* szStatement, int iInput )
Ihave tryed this many ways. dbInput (model) dbInput (model,2)
none would compile.

So all I can think it is is the string is not being save as a sting.
It just crazy to think I been working on this for three days and can't load one model. There got to be something wrong some where.
renny
sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 18th Dec 2007 02:33
Ok I made a C++ program where I made a char string and it work fine.
char will not work in DGK.
renny
aersixb9
16
Years of Service
User Offline
Joined: 29th Nov 2007
Location:
Posted: 18th Dec 2007 02:33
I think you should take a c++ class at your local (junior?) college.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 18th Dec 2007 02:40
Nah - He's pounding this stuff - (I'm doing same thing with Vertex and Normals - I really need a geometry class - I missed alot of that ) It's painful...but ... so fighting with this C++ syntax stuff

try: dbInput(&Model);

That tells C++ the "MEMORY ADDRESS" of the char model - and DB will "COPY" input data to that memory address.

jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 18th Dec 2007 02:41
Yes - mean the ampersand - and BTW - the Dead Giveaway is the help - where it says:
void dbInput ( char* szStatement, int iInput )

sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 18th Dec 2007 02:56
well it did not work dbInput(&Model);
I get this, it does not compile.
error C2065: 'Model' : undeclared identifier
Does anyone know what a undeclared identifier is?
Thank You
renny
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 18th Dec 2007 02:59
When you declare an array, the identifier itself is the pointer, you don't need the ampersand symbol.

Quote: "Does anyone know what a undeclared identifier is?"

Yes, it's a variable/function/etc that hasn't been declared. Remember that C++ is case-sensitive, so that error will go away when you fix the case of 'model' in that function call.

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 18th Dec 2007 03:03
That is it, I had it for today I am going back to NF. I can make heads and tails out of that.
renny
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 18th Dec 2007 03:06 Edited at: 18th Dec 2007 03:08
sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 18th Dec 2007 23:08
jason p sage, Yes I seen that in the tut you told me to goto. I had Model for most of the afternoon yesterday, no help.

This is what the help said about dbInput()
dbInput
This command will accept input data from the keyboard and store the entry in the specified variable. The string that heads the input command is optional, and allows the user to provide an on-screen prompt for the data. The data is output to the screen as it is entered.

Syntax
void dbInput ( char* szStatement, int iInput )
What should go into the ()? every time I put something in the ()dbInput("enter model name here", Model); I get an error. So what goes there?
Then Is this the right comm.? it said that(The data is output to the screen as it is entered.) does it goes also in the the string?

Go to the address below to see NF. From what I see, it is very nice to work with in C++ I can make char and have it work, not spend there days trying to make work.
http://www.nuclearglory.com/

Thank You
renny
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 19th Dec 2007 00:16 Edited at: 19th Dec 2007 00:17
As I said before, typing 'Model' won't work as you haven't got a variable defined as that. You have a 'model' but not a 'Model'. You are going to get an error every time if you do this.

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 19th Dec 2007 00:25
Benjamin,
I don't have any ideal what you are talking about Model is Model.
That is what I been using for two days now.
So how do you defined a char variable?
renny
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 19th Dec 2007 00:32 Edited at: 19th Dec 2007 00:55
Here Bro - Try this



REnny - Ben is talking about how C++/C are case sensitive... Look at the Letter "M" in his statement:

Quote: "You have a 'model' but not a 'Model'"


Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 19th Dec 2007 01:22
Quote: "So how do you defined a char variable?"

Look at a C++ tutorial.

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 27th Dec 2007 00:49
jason p sage,
Sorry it took so long, but with work and this time of the year, I just got the time to try your code. It worked nery nice. What I want to do is go line by line and write what each line is and does. Then if you have time to look at it, you will be able to tell me if I am wrong or right.
Thanks very much
renny
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 27th Dec 2007 04:40
No Problem. BTW - Benjamin is not being mean - in fact - he and many others are often here helping - but we usually like to see some effort before we invest time in people.

I like your suggestion, and would ask this as a challenge from the little code snippet I sent you.

Make Two "Input Statements".

1: Ask for first name.
2: Ask for last name.

Then - make first name scroll on to screen about in the middle, from the left, while the Last name scrolls on the screen from the right - and they stop when together (with a space in between).

Pick a easy common resolution 640x480 will do.

You CAN do this

sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 28th Dec 2007 01:33
Ok jason p sage, I will take on your challenge. I have other things I must do also. It will take a while for me to find the time, I will try to have it by the 15 of Jan.
ha ha ha I will try to make it interesting
renny
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 28th Dec 2007 02:27
Excellent - I look forward to it. I think its important to accomplish things - even seemingly little things - to get that feeling of "I Did It" because then when you've done a few - you actually WANT to dive in and learn deeper things. When you have an empty texteditor, a compiler, and a book that is bigger than the bible... well.. could drive someone away .. when there is so much neat stuff to do and try

sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 28th Dec 2007 16:55
I made two simple games in gdk all ready. C++ is just alot more code intense that basic.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 28th Dec 2007 17:42
True - you definately definately want to try to write reusable code as much as possible so you aren't always coding the same stuff over and over again - same holds true for all languages but C++ - basically Forces it on ya if you want to get things done with any kind of proficiency.

Quote: "I made two simple games in gdk all ready"

ROCK ON!

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 28th Dec 2007 21:33
I'm sure the syntax in DGDK is just: char* string = dbInput();

Dunno where you could put a message.

Your signature has been erased by a mod

Login to post a reply

Server time is: 2024-11-19 20:26:13
Your offset time is: 2024-11-19 20:26:13