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.

DarkBASIC Professional Discussion / Why will this code not work?

Author
Message
Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 17th Dec 2012 03:01 Edited at: 17th Dec 2012 03:05
Just playing around and can't figure out why this code does not work. It will open up and give you the choices. I am only trying to get the N choice to work. when I push N or n it crashes the output screen and says that that window will close the screen. Here is the code.




Thanks
Dragonslayer[
Dar13
18
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 17th Dec 2012 03:08
It's because you're trying to use uninitialized variables and an unrecognized logical operator.

This should work:


Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 17th Dec 2012 03:20
Thanks I get it now! It does not help to do this when I am very tired. I did have it working earlier, then did it over. I want to use select and case to get all of these options working. I am just playing around to see where I can take this and learn different commands.

Thanks for the help!
Dragonslayer
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 17th Dec 2012 05:22
Have a look at Inkey$() too
Very handy function!

Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 18th Dec 2012 00:01
Yes that and mouse commands!
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 18th Dec 2012 10:03
Correct solution:

Dar13
18
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 18th Dec 2012 13:58
mr Handy's solution works too, though mine does as well. I didn't think that select-case would work with string literals(it doesn't in DGDK/C++), so I just went with an if-statement.

Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 20th Dec 2012 02:59
I got it to work with a string literal before I checked back on this post. I have been working through the Hands on volume 1 book. I tend to blow through the reading and get to the programming and then spend 3 days trying to get something to work. If I would have just slowed down and read the stuff really good I would have caught it the first time.

I must have red that section 3 or 4 times before I finally actually saw that you can use string literals.
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 20th Dec 2012 08:31
@Dar13


*** Merry Chuckmas! ***
Dar13
18
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 20th Dec 2012 12:18
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 20th Dec 2012 12:21 Edited at: 20th Dec 2012 12:23
It's about how to use strings in select in C++. It's a cheat but it works. As you see, it's a integer value that contains... string value You can improve code, 'cause now it can't see difference between "LeeBamber" and "eLeBamerb"

*** Merry Chuckmas! ***
Dar13
18
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 20th Dec 2012 13:45
Yeah that won't work right in C++. That code wouldn't be able to tell the difference between "dar13" and "rad13", which is a big deal. Explanation of why and some solutions can be found here.

mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 20th Dec 2012 14:39 Edited at: 20th Dec 2012 14:43
That *i will give you extra protection:
Quote: "CheckSum=CheckSum+asc(mid$(value$,i))*i"

At least now it knows if you are "dar13" of "13dar"

The best (and professional) thing is to calculate md5 But I don't have any snippet

p.s. checksum still has weak point: 4123 and 2341 are equal it's a special pattern. But this code is great for internal usage, where you know that you won't hack it

*** Merry Chuckmas! ***

Login to post a reply

Server time is: 2026-07-07 20:45:10
Your offset time is: 2026-07-07 20:45:10