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 Discussion / IF Command help

Author
Message
PaulDr
12
Years of Service
User Offline
Joined: 3rd Aug 2007
Location:
Posted: 3rd Aug 2007 15:54 Edited at: 22nd Feb 2013 07:29
[Deleted]

Coding isn't like riding a bike. If you fall down, you have to rebuild half the bike before you can get up just to crash again.
Libervurto
13
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 3rd Aug 2007 19:33 Edited at: 3rd Aug 2007 19:33
I'm posting because I can't see any posts here?
Nothing. huh?

Your signature has been erased by a mod because it was rubbish.
Latch
13
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 3rd Aug 2007 22:58
@PaulDr

If notepad.exe is in your main windows directory, DarkBASIC should be able to find it without you having to supply a path:

Execute File "notepad.exe","",""

If you need to specify the system directory, don't use the method you employed "%SystemRoot etc." use the DBC command WINDIR$()

path$=WINDIR$()+"\system32\"

Execute File "notepad.exe","",path$

Enjoy your day.
Libervurto
13
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 4th Aug 2007 02:38 Edited at: 4th Aug 2007 02:39
Woah! I can see your code now and to be honest I wish I couldn't!
You have some pretty good ideas, but you sure need to look at some tutorials (there are loads on the DBC board).
I would especially recommend you look at loops, functions and sub-routines as this program could use a few. I'll give you a little help with a FOR NEXT loop to get you going.
You wrote this:


When you could have written this:


And seeing as you use this "..." printing a couple of times you could make it into a gosub (sub-routine) or a function.
Which of these do you think is best to use?

FUNCTION


or GOSUB


Once you've done TDK's basic tutorials you should be able to pick the best one

Your signature has been erased by a mod because it was rubbish.
PaulDr
12
Years of Service
User Offline
Joined: 3rd Aug 2007
Location:
Posted: 4th Aug 2007 02:47 Edited at: 22nd Feb 2013 07:29
[Deleted]

Coding isn't like riding a bike. If you fall down, you have to rebuild half the bike before you can get up just to crash again.
TDK
Retired Moderator
16
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 4th Aug 2007 05:13
Quote: "I know that the code is painful on the eyes, and theat its the more difficult way to go about things, but I'm not worried about simplifying the code yet."


But...

The point is that you need us to help you sort out your problem and to do so, we have to read and understand your code.

With such badly written and unindented code, it makes it very difficult and many just won't bother.

Don't get me wrong, I'm not having a dig at your code - we all had to start somewhere and I'm sure my very first programs were just as untidy.

I honestly believe that you really should throw that away and start again - after reading a few beginners tutorials. Start with tutorials 1 to 4 for beginners as one of the things covered is a basic skeleton program layout which you can easily build on.

They also explain how to avoid spaghetti code by writing procedural code - and avoiding Goto.

If we can follow your program, then you are much more likely to get a solution to your problem.

I notice that your Execute File lines have no backslashes at all and

%SystemRoot%system32notepad.exe

shouldn't need anything more than

notepad.exe

(Goto Start..Run and type Notepad.exe then press Enter. Notice it still runs without entering the path)?

TDK_Man

Sinani201
12
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 4th Aug 2007 06:37
Do you want it to open notepad, or write to a text file?
I think only in DBCe, there are file reading and writing commands that take out the hassle of opening notepad. So if you wanted to take info from a .txt file... I think it would be like this:


Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
Libervurto
13
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 4th Aug 2007 17:21
I've found your problem.

You aren't checking for "Writing", you are checking for "Write".
If your code had been neater it wouldn't have taken me another day to find that, and you would have spotted it yourself anyway.
The way you structure your code is 80% of how good a programmer you are. Without a good structure you can't expand your code and you'll find you keep having to start-over.
Do the tutorials, I'd like to see something from you when you've learnt a little more

Your signature has been erased by a mod because it was rubbish.
PaulDr
12
Years of Service
User Offline
Joined: 3rd Aug 2007
Location:
Posted: 6th Aug 2007 03:27 Edited at: 22nd Feb 2013 07:29
[Deleted]

Coding isn't like riding a bike. If you fall down, you have to rebuild half the bike before you can get up just to crash again.
Insert Name Here
12
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 8th Aug 2007 22:04
Quote: "Woah! I can see your code now and to be honest I wish I couldn't!
You have some pretty good ideas, but you sure need to look at some tutorials (there are loads on the DBC board).
I would especially recommend you look at loops, functions and sub-routines as this program could use a few. I'll give you a little help with a FOR NEXT loop to get you going.
"

When you hear these word uttered, you know you're going to get the OBese87 treatment.

I never tell the truth.
That ain't a paradox.
I always tell lies is though.
Libervurto
13
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 8th Aug 2007 22:20 Edited at: 8th Aug 2007 22:27
Quote: "I know that it is a mess and if you don't want to look through it and help don't."

I do want to help, if I didn't I would just ignore your post.
It's just that messy code is almost impossible for anyone to follow.

I'm writing a tutorial on how to structure your code, I'm not just bitching at you, being able to write tidy code will make your life a lot easier .
http://forum.thegamecreators.com/?m=forum_view&t=111855&b=10

Practising is a great way to familiarise yourself with the commands, but to be honest you need to learn about loops before you can write a program like this.

You've taught me something new, I thought "$" had to be at the end of a string name.

@INH
Quote: "When you hear these word uttered, you know you're going to get the OBese87 treatment."

lol, I managed to hold back on this one

Your signature has been erased by a mod because it was rubbish.
TDK
Retired Moderator
16
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 10th Aug 2007 02:21
Quote: "You've taught me something new, I thought "$" had to be at the end of a string name."




It does!

TDK_Man

Libervurto
13
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 10th Aug 2007 02:36
i tried and it seemed to work

Your signature has been erased by a mod because it was rubbish.
KYP
14
Years of Service
User Offline
Joined: 5th May 2005
Location: 01110000
Posted: 10th Aug 2007 06:14
This is pretty unrelated, but why are the first four sounds loaded numbers 1,2,6, and 7?

You'll eat a muffin. You'll eat it and LIKE IT!!!
TDK
Retired Moderator
16
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 10th Aug 2007 08:27
Quote: "i tried and it seemed to work"


Oh yes, it works, I wasn't saying it didn't work - I just meant that it shouldn't work.

The $ symbol should ONLY be placed at the end of a variable's name in the case of a string. Putting it in the middle is a definite no-no - whether it works or not.

TDK_Man

Libervurto
13
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 11th Aug 2007 02:22 Edited at: 11th Aug 2007 02:26
Quote: "
The $ symbol should ONLY be placed at the end of a variable's name in the case of a string. Putting it in the middle is a definite no-no - whether it works or not.
"

yeh especially when after the $ you have the characters "do" lol

Quote: "This is pretty unrelated, but why are the first four sounds loaded numbers 1,2,6, and 7?"

umm... because those are the numbers he wanted for some strange reason.
It doesn't make any difference what number you choose, as long as it is unique. some people have made functions so that you dont have to worry about remembering numbers, you just assign the result of a formula to the variable name you want.
e.g.


Your signature has been erased by a mod because it was rubbish.

Login to post a reply

Server time is: 2019-09-19 18:13:34
Your offset time is: 2019-09-19 18:13:34