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 / Questions of Syntax

Author
Message
Slartibardfast
14
Years of Service
User Offline
Joined: 3rd Jul 2010
Location: Magrathea
Posted: 7th Jul 2010 13:17
I have found nothing in any references to clarify these:

Multiple Statements on a single line. Can this be done and how? Is it just the use of the colon ( to seperate them?

Using REM Statements on the same line as other Statements. I presume this is viable. Are there any other methods to define a Remark? i.e. an apostrophe? (').

Primarily I want to find out what works and what doesn't, but any comments as to 'good or recommended practice' are also welcome.

Thanks.
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 7th Jul 2010 14:30
Hi, multiple statements can be done with the use of the colon ':' to separate them.

Other symbols to define a remark is the '`' symbol and '//'.
To use them on the same line you can do this 'sync on : sync rate 60 // turn on sync'

Finally, a good practice is to not use the 'goto' command as it jumps about your code and becomes hard to coordinate.

Hope this helps

A clever person solves a problem, a wise person avoids it - Albert Einstein
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 7th Jul 2010 14:56
Quote: "good or recommended practice"

Ask 10 people and you'll get 10 different answers.

Anyway...
REM, ` (backquote) and // - comment up to the end of the line
REMSTART
REMEND - block comment, ends immediately past the REMEND

Multiple statements are separated by colon, but my advice (for what it's worth) is to not bother - the code should be laid out to be read best by you, not the compiler. Don't be scared by too much whitespace or using too much vertical space - the compiler doesn't care in the least, and it's everso slightly easier to debug too.

... and seeing as the GOTO spectre has raised it's head, I'd say to prefer not to use GOTO rather than rule it out totally - if you find yourself in the situation of using multiple levels of IF statements, or defining condition variable after condition variable, then I consider GOTO to be a reasonable substitute if it makes the resulting code cleaner and clearer to read.

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 7th Jul 2010 18:44 Edited at: 7th Jul 2010 18:47
The only time I use REM on the same line as a command is to let myself know just what the variables/UDTs/DIMs are... any other time it's on it's own line(s).

This is just a snip of a program I made (won't work on it's own).



Yeah, IanM is right don't bother with colon. The only time I use it when defining things that go together like x and y coordinates.



GOTO is a classic command that should be learned and used till you learn about better methods using GOSUB and/or functions. Without knowing the past you'll never know just exactly why the new methods are "better".


One thing not mentioned yet is indenting. When you don't indent it's really hard to follow where your loops start and end if you have multiple loops close together. I only use once space but many people use Tab.

Not indented:


Indented:


Slartibardfast
14
Years of Service
User Offline
Joined: 3rd Jul 2010
Location: Magrathea
Posted: 8th Jul 2010 01:13
I have been in IT for over 35 years (not always as a programmer I might add!), and I have to say that my first impressions of this community are very good. Well, excellent! Just the right mix of helpful advice and wit ! Thank you.

I am now starting to dabble with the Code. Nothing more than getting a feel for structuring at the moment, but I like to lay good simple solid foundations before getting down and dirty!

Although some of the responses are not necessarily new to me, they do re-enforce either my own attitudes or confirm my suspicions, and that is still most helpful and positive, and I am grateful for the time you have taken to respond.

You never know, in time I might even have a half decent program to present...

Keep up the good work! And yes, I will likely have more questions...

Login to post a reply

Server time is: 2024-11-24 14:37:16
Your offset time is: 2024-11-24 14:37:16