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 / IF structure from Hands on Darkbasic pro not working

Author
Message
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 23rd Jun 2013 12:38 Edited at: 23rd Jun 2013 12:39
Hi, I am reading Hands on Darkbasic pro vol. 1 and it tells me I should be able to make an IF structure like this:

But the compiler tells me the IF condition only takes one parameter :-( Is it the book that is giving me some bad info or am I doing something wrong here?

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Scotty1973
AGK Backer
15
Years of Service
User Offline
Joined: 2nd Jun 2011
Location: Burton-on-Trent, uk
Posted: 23rd Jun 2013 12:50
Hi

Dont know about the if statement but you can use Select statement instead :


Hope this helps, as it seems to be what you are trying to do.

Scotty
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 23rd Jun 2013 13:01 Edited at: 23rd Jun 2013 13:01
I wanted to create a "catch all" IF structure like this:


The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Scotty1973
AGK Backer
15
Years of Service
User Offline
Joined: 2nd Jun 2011
Location: Burton-on-Trent, uk
Posted: 23rd Jun 2013 13:07
Ok no problems just add a Default case to the statement to catch any other number that isn't selected in the case statements:



This should catch all.

Scotty
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 23rd Jun 2013 13:38 Edited at: 23rd Jun 2013 13:46
Okay, thank you I just find it odd that there is a useless IF example in the learning book :-( The problem with the select method might be that it only accepts one variable for selecting. Does it only accept integers or can you also use strings and reals??

EDIT: Now the book introduced something else that seems useless:

Is this something that used to be in DBPRO and have become obsolete??

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 23rd Jun 2013 13:55
That's odd...

Should be:



t is a variable which counts from 1 to 3.

TheComet

Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 23rd Jun 2013 14:14
I know, I just thought "Yay, I can do a FOR without any variable being used" but I guess not :-(

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 23rd Jun 2013 16:53
Weird mistakes in the book.

Scotty1973
AGK Backer
15
Years of Service
User Offline
Joined: 2nd Jun 2011
Location: Burton-on-Trent, uk
Posted: 23rd Jun 2013 17:49
Yes you can use strings or real numbers in the select statement.

Looking at the stuff your putting in the code box it looks a bit like pseudocode, which is written more like english for people to understand more and won't work on the computer.

Scotty
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 24th Jun 2013 10:10
It tells me that FOR and ENDFOR are commands :-(

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Burning Feet Man
18
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 24th Jun 2013 12:42 Edited at: 24th Jun 2013 13:34
My favourite style of check is this;



Anyone know what this technique is called? Is it a "Bitwise" check?

Oh, almost forgot, expanding on my above example;



Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 29th Jun 2013 15:32
Quote: "Anyone know what this technique is called? Is it a "Bitwise" check?"


I think that method is called "Binary selection", binary meaning that it can choose between two selections. There are also "Multiway selection" where it can choose between several selections, like SELECT CASE, multiple IF - ENDIF or multiple IF - THEN. I actually don't know if this answers your question Or if you meant something else with "Bitwise"

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
AlistairS
13
Years of Service
User Offline
Joined: 28th Apr 2013
Location: U.K.
Posted: 11th Jul 2013 13:55
@Cybermind

Sorry I've taken time to respond to your post but I have only just noticed it.

The Hands On DBPro book does not claim that DBPro has the structures you refer to. Those structures are used in structured English to describe the algorithm in a way that is independent of the language you finally code in.

If the book does not make that clear, I'm sorry, but no one else has ever mentioned this problem to me.

If you or anyone who has bought the book is in need of help with its contents, please email me. You will find details of the address on our website (www.digital-skills.co.uk).
basjak
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 11th Jul 2013 22:15
you're looking for a multiple way selection. this is mentioned in DBpro book but it says clearly that it is not available in DBpro coding so instead you should use:

variable = 3
if variable = 1
output = 1
else : if variable = 2:
output = 2
else :if variable = 3:
output = 3
endif : endif : endif

do
print output
loop

MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 11th Jul 2013 23:14
Quote: "The Hands On DBPro book does not claim that DBPro has the structures you refer to. Those structures are used in structured English to describe the algorithm in a way that is independent of the language you finally code in."


^ This

Quote: " If the book does not make that clear, I'm sorry, but no one else has ever mentioned this problem to me.
"


Pretty sure it makes them very clear in book 1 Page 0 [Before Page 1] and it is titled in huge Bold letters...

Language Syntax Diagrams

Love the books and thank you for them! they are priceless to me! albeit I only have the PDF versions....... hope I can get the printed ones someday...

Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 12th Jul 2013 06:06 Edited at: 12th Jul 2013 06:09
@basjak and burningfeetman - SELECT--CASE is made for when you want to execute different code on different values of the same variable.
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 13th Jul 2013 21:44
@AlistairS:
Quote: "Those structures are used in structured English to describe the algorithm in a way that is independent of the language you finally code in."
Sorry, I did not notice that :-P

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 15th Jul 2013 18:47
I did not mean to "bad mouth" the book by the way! I think it is great reading and a good introduction to DBPRO. I am missing some basics as I just learned DBPRO on my own and I think this book does a great job telling the needed to know about getting into DBPRO Just to clarify

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 21st Jul 2013 01:53
That is psoudo code in the book
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 21st Jul 2013 02:08
Quote: "psoudo "

^
pseudo or more accurately Pseudocode

Login to post a reply

Server time is: 2026-07-07 09:51:35
Your offset time is: 2026-07-07 09:51:35