Page 1 of 1

List of fancy little QuickBasic coding tricks

Posted: Tue Sep 11, 2007 2:37 pm
by ThemePark
Ya okay, quirks is not the best word to use, but with my mental English dictionary being shut down, it'll do for now.

BASICally what I'm wondering is if there is a book or a website that deals with all the little fancy things in QuickBASIC, that set the line between a so-and-so programmer, and a show-off programmer.

Like for instance, Mac's use of INPUT$(1) in ... 5080#15080

Or how Dav is able to put a comment at the end of a DATA sentence by using a colon in ... 5039#15039

Those little things that is not common knowledge and that is perhaps not always found in the QuickBasic help, but that can really add something to a program, and make it better and easier to read. That is the kind of list that I'm looking for.

Re: List of fancy little QuickBasic quirks

Posted: Tue Sep 11, 2007 3:56 pm
by Mac
{quote="ThemePark"}between a so-and-so programmer, and a show-off programmer.{/quote}

"show-off"?? LOL!

Anyway, I haven't seen any collection of coding tricks. Mostly, I pick them up from reading other people's code. Maybe someone like Solitaire brings my attention to INPUT$ which I had previously ignored. So I start using it where I might have previously coded

So I would say to just keep reading other people's code and look for good ideas. I learn one every day. For example, I want to split a string which I know has one delimeter comma+space and a left and right side length >0.
Possibly "abc, def" into "{abc} {def}".

For a long time I would have coded this:

Code: Select all

k$ = "abc, def"
y = INSTR(k$, ", ")
PRINT "{"; LEFT$(k$, y - 1); "} {"; RIGHT$(k$, LEN(k$) - y - 1); "}"
But lately, having seen the MID$ trick, I code this

Code: Select all

k$ = "abc, def"
y = INSTR(k$, ", ")
PRINT "{"; LEFT$(k$, y - 1); "} {"; MID$(k$, y + 2); "}"; 
A lot cleaner. The point: everyone can benefit from studying the code that others have written.


Posted: Tue Sep 11, 2007 8:25 pm
by ThemePark
Thanks Mac, programming tricks is a better phrase to use so I changed the title accordingly.

You have a good point, and the few tricks I've noticed so far have also been from looking at other people's codes. For instance, using semicolon instead of plus in a print sentence makes it look cleaner to me, something I had never thought of doing.

But if there has never been compiled such a list, are there any coding examples that people could give, that contain some sort of trick, either to make the program work faster, or look cleaner? Perhaps code from posts in here? The more little tricks I learn, the better I can tidy up my code and the less likely I should be with making spaghetti code, i.e. by gaining coding experience through example.

Posted: Tue Sep 11, 2007 8:52 pm
by Mac
Well, if you are really serious about advanced techniques, see ... 1069000429

Otherwise, as I said, just look at code. You can see a lot of my programs at ... 1152556572

but you are better off looking at programs from many programmers, not just a few. So here are the works of many programmers:

(Heh - That should keep you busy awhile)


Posted: Tue Sep 11, 2007 9:23 pm
by ThemePark
Pft, only took me 5 mins to go through all that, including programs.

Thanks mac, this is exactly what I was talking about, so it should be very useful in my learning process. And yeah, it should take me a while to go through it. :P

Posted: Thu Sep 13, 2007 9:00 pm
by moneo
Another excellent source of BASIC programming techniques can be found at Ethan Winer's homepage. Several years ago. Ethan was a respected BASIC expert, and wrote many articles for PC Magazine. He's now into music.

Go to:
Select "Programming" from the top menu.
Near the bottom of the page download a zip file with a free version in text mode of his book "BASIC Techniques and Utilities Book."
Put all this into a separate directory (folder).
You'll find a wealth of information there.

Good luck..... Moneo