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.

Newcomers DBPro Corner / More than one command on a line. Is this allowed?

Author
Message
Ones and Zeros
17
Years of Service
User Offline
Joined: 7th Jun 2007
Location: Western NY
Posted: 16th Jan 2013 19:21
Hello all, its been a long time since I've been on this site. I bought DBP way back in 2007 and played a little bit but now I'm trying to get back into it. So I'm starting over. While I'm waiting on my new copy of DBP to come I am using the free version. So while trying to practice I am running into problems with more than one command on a line. I thought I read that you have to seperate them by a semicolon but I get a parameter unknown error. Should I just use a gosub to do more than one thing based on a IF THEN statemnet?
ex) If A = 1 Then print"Hello World"; B = 3; Set Cursor 2,b
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 17th Jan 2013 02:33
use a colon :

Virtual Nomad @ California, USA . DBPro V7.7 . Matrix1Utils 05.27.12
AMD Phenomâ„¢ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 17th Jan 2013 07:02
Hello Ones and Zeros - Welcome back

Yes Colons :

BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 20th Jan 2013 21:44
Barring that, this would be a better option than GOSUB:

I know, DBP never uses semicolons. Messes me up so much.

http://brianmacintosh.com
"'Who's that primitive entity accessing sliding collision data from my bridge?!', the troll roared." - TheComet
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 20th Jan 2013 22:23
Quote: "I know, DBP never uses semicolons"

It does in the variable argument functions like print



"Why do programmers get Halloween and Christmas mixed up?"
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 20th Jan 2013 22:35
True. Not for line termination or anything like that, though!

http://brianmacintosh.com
"'Who's that primitive entity accessing sliding collision data from my bridge?!', the troll roared." - TheComet
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 21st Jan 2013 16:21 Edited at: 21st Jan 2013 16:21
@ Ones and Zeros





Not near a compiler, but if this works you're in luck.

@ BMacZero



TheComet

http://blankflankstudios.tumblr.com/
"Man being a noob sucks! " - OBese87
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 21st Jan 2013 18:08
Hah, nice, I should use that next time I'm in DB.

http://brianmacintosh.com
"'Who's that primitive entity accessing sliding collision data from my bridge?!', the troll roared." - TheComet
Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 11th Feb 2013 00:42
TheComet,

Quote: "@ BMacZero

#constant ;

print "hello world";
wait key;
end;
"


You're a massive smart arse I found this hilariously funny for some reason!

thenerd
15
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 11th Feb 2013 02:19
@Bmaczero and Agent,

Funny thing is, that works without the constant declaration as far as I can tell.

BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 11th Feb 2013 02:39
Huh, you are right. I could have sworn I ran into issues with this in some other code. Could be that there are some specific constructs that don't like it.

Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 14th Feb 2013 02:17 Edited at: 14th Feb 2013 02:18
I really don't like the use of colons in DB. Wouldn't it be more logical given the nature of basic to use THEN instead? After all isn't this exactly what THEN does?
Example:

if spacekey() then print "BOOP"
if spacekey() : print "BIP" : endif

Isn't if a then b then c then d more legible than if a then b : c : d?

^ That's what she said.
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 14th Feb 2013 02:44
I guess that seems like that would read "if a then b, if b then c, if c then d", whereas the current syntax reads like "if a then b and c and d". It makes enough sense to me, anyway.

Ortu
DBPro Master
17
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 14th Feb 2013 06:05 Edited at: 14th Feb 2013 06:08
Quote: "Isn't if a then b then c then d more legible than if a then b : c : d?"


I don't know, multiple 'then' feels more like an elseif structure to me.

Also, rather than mixing then and : together, I would do

if a : b : c : d : endif

it's cleaner and also more compressed, which is the main point of putting it all on one line right?

Personally, I prefer to avoid then in general and ususally try to avoid cramming multiple commands on one line, though there are exceptions like some select/cases

It's interesting how different everyone's personal habits are, and how they formed.



Login to post a reply

Server time is: 2024-11-23 13:45:09
Your offset time is: 2024-11-23 13:45:09