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 / Splitting source code lines for ease of reading

Author
Message
bodmcn
15
Years of Service
User Offline
Joined: 6th Oct 2010
Location:
Posted: 23rd Oct 2010 06:13
Hi,

Is there a way of splitting source code lines, especially for IF statements, in DBPro?

eg.

IF ( A = B AND
( X = Y OR Z = 2 ) AND
( C = D )
)


I get a syntax error when try it, is there a continuation character than can be utilised?
Hockeykid
DBPro Tool Maker
18
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 23rd Oct 2010 06:30 Edited at: 23rd Oct 2010 06:30
Well, you could do



bodmcn
15
Years of Service
User Offline
Joined: 6th Oct 2010
Location:
Posted: 23rd Oct 2010 06:44
For that specific example, it is true; but if some of the comparisons are OR then this is not applicable; as in the following:



Splitting long IF statements to logical groupings makes the code much easier to read, so I was just checking if there were an escape character (similar to the \ in C macros) or another method to allow this.
Hockeykid
DBPro Tool Maker
18
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 23rd Oct 2010 07:18
Well it still allows you to cut it down, atleast a little bit but no as much as other languages.



But thats about the only way I can think of.

bodmcn
15
Years of Service
User Offline
Joined: 6th Oct 2010
Location:
Posted: 23rd Oct 2010 07:30
I guess that would be a no... :-(

Ah, well.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd Oct 2010 13:46 Edited at: 23rd Oct 2010 13:49
Just use the _ character at the end of the line. Check the setting in the DBPro editor - look at Tools/Options/Text Editor and you should see the line concatenation option.

Edit But in your example it would be better to use brackets as follows:

bodmcn
15
Years of Service
User Offline
Joined: 6th Oct 2010
Location:
Posted: 23rd Oct 2010 13:49
Ah - excellent indeed!!!

Many thanks
Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 23rd Oct 2010 21:14
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd Oct 2010 21:23
True, but the thread title was

Quote: "Splitting source code lines for ease of reading"


Brackets can help readability even if they are not necessary according to the rules of precedence.
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 23rd Oct 2010 21:49
according to the convention you're using for A=B and C=D, shouldn't you do:


?




...sorry I'm just being a jerk.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th Oct 2010 02:44
Quote: "according to the convention you're using for A=B and C=D, shouldn't you do:"


Yes, but I couldn't be bothered to be that picky.
bodmcn
15
Years of Service
User Offline
Joined: 6th Oct 2010
Location:
Posted: 25th Oct 2010 04:09
Um... the original query was about continuation of statements across multiple lines which was answered. The examples were purely examples and not to reflect any actual logic; sorry for any confusion.

Login to post a reply

Server time is: 2026-07-22 03:51:18
Your offset time is: 2026-07-22 03:51:18