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 / Can't get IF and DO statements to work

Author
Message
Raybrite2
15
Years of Service
User Offline
Joined: 16th May 2009
Location: Cyberspace
Posted: 10th Jun 2009 07:32
I am going through the tutorials with DB Lite and cannot get the IF statement to work.
I get a syntax error.
Same thing with the DO statement

v=0
DO
(snytax error. unrecognized command)
What am I doing wrong?

I moved this from the FPS forum where I mistakenly put it before.
Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 10th Jun 2009 07:33
Is that the full code? If not post the hole code.

Raybrite2
15
Years of Service
User Offline
Joined: 16th May 2009
Location: Cyberspace
Posted: 10th Jun 2009 07:40
I just posted it on the other one.
Answer here.
Thanks.
Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 10th Jun 2009 07:41
Use this for the if



With an if there must be a then

Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 10th Jun 2009 07:45
And for the other part use this



You put v-v+1 it should be v=v+1

Sorry for double post

BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 10th Jun 2009 07:47
Sometimes the error checking won't always stop on the right line, try searching for something questionable a couple lines above it. Also, try closing your IF statements and your DO loops, with ENDIF and LOOP respectively. Perhaps it is just the wrong error message.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 10th Jun 2009 07:48
Quote: "Sometimes the error checking won't always stop on the right line, try searching for something questionable a couple lines above it. Also, try closing your IF statements and your DO loops, with ENDIF and LOOP respectively. Perhaps it is just the wrong error message"


Maybe we cross posted but the fixes i gave him work.

BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 10th Jun 2009 07:51 Edited at: 10th Jun 2009 07:54
Oh wow, you got 2 posts in before I could get one!

[EDIT]
For the record, All if's don't need then's.

There are several ways to format an if statement:

For one operation you can do:


For two or more, it is usually advisable to do this:


Optionally, you can add an ELSE case, to do something else if the condition is not met:



Note that the do's are not the DO command, but I though them in there to make it a little easier to read (that is, IF A then do B)

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Raybrite2
15
Years of Service
User Offline
Joined: 16th May 2009
Location: Cyberspace
Posted: 10th Jun 2009 08:08
The IF statement worked.
The DO statement still stops after I type DO and press enter.
I tried putting the first two lines together and I get the same thing.
Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 10th Jun 2009 08:10
With the do statement you need a loop statement where you want to end the loop.

Raybrite2
15
Years of Service
User Offline
Joined: 16th May 2009
Location: Cyberspace
Posted: 10th Jun 2009 08:13
I never get that far before it gives the error.
I have the loop statement at the end.
It stops as soon as I enter the DO statement.
I am going to look at TDK's tutorials and see what he did there. I know he probably followed the same thing or something close to it.
I can also try it with the Crimson Editor I have. Maybe that will show something.
I must find the answer somewhere.
Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 10th Jun 2009 08:16
DO is paired with the LOOP statement. One way to think of it, is that DO is the starting point of the code to be looped, and LOOP is the end.


DO

;... put code in here that you want to run in within the loop

LOOP


In DarkBasic Do has no other operation.

Raybrite2
15
Years of Service
User Offline
Joined: 16th May 2009
Location: Cyberspace
Posted: 10th Jun 2009 08:25
TDK's tutorial says it is the most basic of loops. He also says they do not use it. that is about all they say about it.
I guess you could use a different kind of variable to do the same thing. I will leave this as a mystery for now. I don't seem to be able to get the complete loop into the computer before it gives me an error.
With Dark Basic they evaluate it every time you hit enter so you really will get that every time you try it.
Oh well,
Back to the tutorial. I will try to keep inputting to see what happens. Maybe it will clear up in the end.
Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 10th Jun 2009 08:33
It shouldn't give you an error until you test it.

Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 10th Jun 2009 08:37
The code is not evaluated until you 'compile' it (Press F5). It Sounds like you're trying to enter code through the DarkBasic CLI. Which will pop up (in the lower section of the screen) if you press ESC, while a DarkBasic program is running.

The CLI is debugging purposes really, not entering new code. By that i mean, through the CLI you can query and change the values while the program is in a 'paused' state.

However to exit a DarkBasic program back to the Code editor use the F12 key (from memory)

Raybrite2
15
Years of Service
User Offline
Joined: 16th May 2009
Location: Cyberspace
Posted: 10th Jun 2009 08:42
How do I get from the help screens to the proper one? I only know how to use the CLI to enter things. Is there a different way to do this.
I usually find something in the help screen and then click on CLI in at the top of the screen.
I downloaded the program so it don't come with a manual.
Raybrite2
15
Years of Service
User Offline
Joined: 16th May 2009
Location: Cyberspace
Posted: 10th Jun 2009 08:46
That worked. I typed it in and then executed it and it worked fine. Don't know what it was supposed to do but it looked pretty.
Thanks a lot.
Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 10th Jun 2009 08:49
Don't know if you figured it out but when you open the program it gives you a place to type then you hit f5 to execute the program.

That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 10th Jun 2009 18:09
i think he got it, otherwise heres how DBC works:

you run the program

it pops up with a black and purple window (assuming you're not using Dark Edit)

that window is where you type the code

you compile it using f4 (this only checks the syntax, if doesnt run the program)

you compile it and run it with f5

when you are done running it you press f12 to exit back to the code window

the CLI is basically only used to see what would happen if you moved the camera or changed the location of a line or other little experiments

also note the the CLI doesnt write that code into the program, when you hit f12 it wont be there

There are only 10 kinds of people in the world, those who understand binary and those who dont
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 10th Jun 2009 18:36
Quote: "I am going through the tutorials with DB Lite and cannot get the IF statement to work."


My question is why are you wasting your time with Darkbasic Lite? It's cheaper but oh so limited.

No Music
No SoundFX
No Bitmaps
No Textures
No 3D Objects
No stand alone .EXE
Not compatible with enhancement packs

http://darkbasic.thegamecreators.com/?f=lite

Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 10th Jun 2009 20:45
Quote: "No stand alone .EXE"


? sure about that?

Robert The Robot
18
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 10th Jun 2009 21:30
That's what the link says:
Quote: "you cannot save an EXE file from the Lite version "


Mind you, I think the key differences are not so much that you're limitedin what you can code, you're just not given any of the media that comes with the full version of DBC.

Quote: "No Music
No SoundFX
No Bitmaps
No Textures
No 3D Objects"

You can write a DBC program to use this kind of thing, you're just not given any in DBC lite.

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 10th Jun 2009 21:35
forgot DB had a lite version when he said light I just thought he meant not DBP

Robert The Robot
18
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 10th Jun 2009 21:44
Easy mistake to make, I didn't realise DBC had a lite version until I followed the link

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 11th Jun 2009 06:38 Edited at: 11th Jun 2009 06:39
Quote: "Mind you, I think the key differences are not so much that you're limitedin what you can code, you're just not given any of the media that comes with the full version of DBC."


Oh I see. That explains why it was written in "meg"'s for the bitmaps and textures. Still not making a stand alone .EXE has to be frustrating. When I first tried the Darkbasic Classic trial it took all of 30 minutes for me to want to buy Darkbasic Pro asap. I don't think they even had a Lite version back then.

arbiter chewbacca hybrid
16
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 11th Jun 2009 16:32 Edited at: 11th Jun 2009 16:33
Do isn't a statement
So you can't say something like



Vista is a paradox created by Bill Gates to force the noble pc gamers of america to console I am here to change that. [link]www.kdlproductions.webs.com[link]
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 11th Jun 2009 16:50
Latch was just showing a example like you just did.

New Site! Check it out \/
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 11th Jun 2009 18:57
i was afraid of this, wen latch wrote the pseudo code using the word do

the do command accepts no parameters, all you type is do

what it does is trigger an "endless" loop, it repeats the same commands over and over again



this will make and rotate a cube

the do loop repeatedly increases the angle variable then rotates the cube accordingly

see how anything between the do and loop commands is done over and over

There are only 10 kinds of people in the world, those who understand binary and those who dont
Raybrite2
15
Years of Service
User Offline
Joined: 16th May 2009
Location: Cyberspace
Posted: 13th Jun 2009 07:30
I solved the origninal problems. Thanks to everyone.
As to why I am using DB Lite, I am thinking about getting the full package that has a bunch of things in it including DB Pro and DB Lite. I wanted to see if this is for me or should I go back to my other program by someone else that makes 2D games.
I don't have access to my printer right now as I am at my other residence. Will be going there tomorrow. Then I can print out the full DB Pro tutporial book to use as a guide. It is the same tutorials that I have now with all the code in it and the pictures.
Also it is indexed.
Thanks. I am learning it now as days go by.
Thanks again.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 14th Jun 2009 12:24
Quote: "i was afraid of this, wen latch wrote the pseudo code using the word do

the do command accepts no parameters, all you type is do

what it does is trigger an "endless" loop, it repeats the same commands over and over again"


When did Latch write anything in this thread?

Enjoy your day.
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 14th Jun 2009 12:40
You must be so well known, that you get credit for things you didn't even do...

TheComet


Make the path of your enemies easier with Waypoint Pro!
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 14th Jun 2009 19:37
rofl

sorry that was bn2

There are only 10 kinds of people in the world, those who understand binary and those who dont

Login to post a reply

Server time is: 2025-05-15 17:04:47
Your offset time is: 2025-05-15 17:04:47