Liberty BASIC Community Forum
« Errata for "Beginning Programming with LB" »

Welcome Guest. Please Login or Register.
Nov 22nd, 2017, 01:34am


Rules|Home|Help|Search|Recent Posts|Notification

Problems installing Liberty BASIC? Read the Vista/Win7 Installation FAQ
Looking for a categorized List of Bug Reports? Visit the Liberty BASIC Bug Tracker

« Previous Topic | Next Topic »
Pages: 1 2  Notify Send Topic Print
 sticky  Author  Topic: Errata for "Beginning Programming with LB"  (Read 865 times)
Alyce Watson
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Female
Posts: 14917
xx Errata for "Beginning Programming with LB"
« Thread started on: May 8th, 2010, 05:38am »

Use this thread to report typos or other errors for the book, Beginning Programming with Liberty BASIC

You can find the book at Lulu.com, where it has received several excellent customer reviews, as well as a five star rating from readers.

Beginning Programming with Liberty BASIC on Lulu.com

You can also find it on Amazon.com, where it has also received a five star rating from readers, as well as excellent reviews and comments.

Beginning Programming with Liberty BASIC on Amazon.com
User IP Logged

Alyce
Liberty BASIC Workshop - a complete IDE for Liberty BASIC


Alyce's Restaurant
for Liberty BASIC code, tools and references
edw2011
Junior Member
ImageImage


member is offline

Avatar



YIM YIM AIM
PM

Gender: Male
Posts: 59
xx Re: Errata for "Beginning Programming with LB
« Reply #1 on: Jul 6th, 2010, 9:06pm »

In my readings and tinkerings, I noticed that Chapter 3's explanation of how string comparison works is largely inaccurate with respect to greater than/less than operations.

The book states that strings are compared alphanumerically by their ASCII values. However, my experimentations have made it clear to me that this is not the case. Strings in Liberty BASIC seem to be compared alphabetically, with uppercase letters alphabetically preceding (being less than) their lowercase counterparts. Following is a quote from the book:

" 'Red' really does come before 'blue'. The answer lays in the uppercase R. The reason why is a little esoteric, but in a nutshell it's because most programming languages compare and sort strings alphanumerically instead of alphabetically.

Under the covers every numeric, alphabetic and other symbol you can type in or read on the screen is given a unique numeric value, known as an ASCII value...Each letter has an upper and lower case, and each case of a letter has it's own unique numeric value. Uppercase letters A to Z have ASCII values 65 to 90, and lowercase letters a to z have ASCII values 97 to 122."

Testing this in Liberty BASIC shows otherwise:

Code:
'does not print anything contrary to what the book says
IF "Red" < "blue" THEN PRINT "less"
 


The book states that "Red" should come before "blue". However, running the above code does not produce the expected print. It would seem that Liberty BASIC does in fact compare strings on an alphabetic basis and not by the constituent characters' ASCII values.

TL,DR

String comparison in Liberty BASIC is not alphanumeric as the book says. ASCII values seem to play no part in greater than/less than operations. Rather, comparisons are done alphabetically. Spaces come first, followed by punctuation, then numbers, then alphabetic characters. Uppercase letters come directly before their lowercase counterparts like so: AaBbCcDdEe...
User IP Logged

Evan Williams
CSE, Lehigh University
Software Development Intern, Bentley Systems
Liberty BASIC Newbie
edw2011
Junior Member
ImageImage


member is offline

Avatar



YIM YIM AIM
PM

Gender: Male
Posts: 59
xx Unnecessary use of GOTO in examples after CH5
« Reply #2 on: Jul 7th, 2010, 3:39pm »

Another potential issue:

In Chapter 5, Beginning Programming with Liberty BASIC introduces GOSUB/RETURN, CALL/SUB/END SUB, and FUNCTION/END FUNCTION. We were also previously introduced to the FOR/NEXT and WHILE/WEND iterators in Chapter 4. The book correctly and lucidly explains why these are a much more maintainable and readable alternative to the vaunted GOTO statement. 99% of the time, there is a better alternative to the GOTO; the GOTO is notorious for two things:

1. Unintentionally creating infinite loops that can take ages and massive hair loss to find and fix

2. Unreadable and unmaintainable spaghetti code

Chapter 5 has no problems at all. It clearly explains both types of subroutines and functions extremely well and also points out the numerous advantages they have over GOTO.

However, in Chapter 6, a lot of the example code reverts back to unnecessary use of GOTO's and branch labels where WHILE/WEND's, subroutines, and other techniques learned in previous chapters would have been more appropriate.

I'm not trying to say that GOTO is an unspeakably evil abomination that should never be used. I think of GOTO as a set of training wheels for the complete programming tyro that remain in place until he/she learns about iterators, subroutines, functions, and all that good modular stuff. But, using it in example code after that introduction to modularity where other more readable techniques would have been possible is something that could very well foster bad practices for the complete newbie.
« Last Edit: Jul 7th, 2010, 3:47pm by edw2011 » User IP Logged

Evan Williams
CSE, Lehigh University
Software Development Intern, Bentley Systems
Liberty BASIC Newbie
edw2011
Junior Member
ImageImage


member is offline

Avatar



YIM YIM AIM
PM

Gender: Male
Posts: 59
xx Re: Errata for "Beginning Programming with LB
« Reply #3 on: Jul 7th, 2010, 3:51pm »

Not wanting to be entirely negative, I will also point out that I just finished Chapter 6's exercises and am currently on Chapter 7. So far, my overall opinion of the book is overwhelmingly positive =)

Carl has done a remarkable job of explaining programming concepts to the complete beginner in accessible language. I also like how he introduces programming jargon through using common language and everyday situations. The book is so far a gentle, yet very effective, introduction to programming.
User IP Logged

Evan Williams
CSE, Lehigh University
Software Development Intern, Bentley Systems
Liberty BASIC Newbie
variableAsPlanned


member is offline

Avatar




PM


Posts: 96
xx Re: Errata for "Beginning Programming with LB
« Reply #4 on: Jul 7th, 2010, 11:00pm »

edw2011 describes a compositional writing problem that needs fixing:

Quote:
Chapter 5 has no problems at all. It clearly explains both types of subroutines and functions extremely well and also points out the numerous advantages they have over GOTO.

However, in Chapter 6, a lot of the example code reverts back to unnecessary use of GOTO's and branch labels where WHILE/WEND's, subroutines, and other techniques learned in previous chapters would have been more appropriate.


That would be an opportunity to revise both chapters for the next edition of the book. In fact, those example programs in that chapter 6 which rely on GOTO instead of the higher level methods could be used as exercises for chapter 5 or 6. Maybe some of the Liberty BASIC forum members, or you, could rewrite some of those example programs.
User IP Logged

CarlGundel
Administrator
ImageImageImageImageImage


member is offline

Avatar

author of Liberty BASIC


Homepage PM


Posts: 2833
xx Re: Errata for "Beginning Programming with LB
« Reply #5 on: Jul 8th, 2010, 4:25pm »

Thanks for the feedback. I'll consider this carefully when I sit down for an second edition. You have to remember of course that the book teaches BASIC. A very large part of any BASIC community is going to ebrace GOTO, and the book pays attention to this.

-Carl
User IP Logged

author of Liberty BASIC
http://www.libertybasic.com
Stefan Pendl
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Computers are like babies, you must teach them what you like them to do ...


Homepage PM

Gender: Male
Posts: 5297
xx Re: Errata for "Beginning Programming with LB
« Reply #6 on: Jul 9th, 2010, 04:53am »

I recently introduced a coworker to BASIC using the Shoptalk software.
It was really hard to convert the tutorial examples from using GOTO to using loops for him.

I would use GOTO only, if it is really needed, but use loops as much as possible.
User IP Logged

Stefan

Make sure to read and follow the Forum Guidelines

Liberty BASIC Pro 4.04, Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
bystander
New Member
Image


member is offline

Avatar




PM


Posts: 5
xx Re: Errata for "Beginning Programming with LB
« Reply #7 on: Jul 9th, 2010, 06:49am »

As for me, I would really really like to hear from Carl the reason beside LB string sorting.
Especially if he speaks about sort by ASCII in his book.
(if there are post with his own words, feel free to point me there).
User IP Logged

edw2011
Junior Member
ImageImage


member is offline

Avatar



YIM YIM AIM
PM

Gender: Male
Posts: 59
xx Re: Errata for "Beginning Programming with LB
« Reply #8 on: Jul 9th, 2010, 11:58am »

on Jul 8th, 2010, 4:25pm, CarlGundel wrote:
Thanks for the feedback. I'll consider this carefully when I sit down for an second edition. You have to remember of course that the book teaches BASIC. A very large part of any BASIC community is going to embrace GOTO, and the book pays attention to this.


Yeah, that is true. For someone learning BASIC as a first language or coming over from an assembly language, GOTO would seem rather appealing because it is easily understood. My first language was C++, which is why I guess my opinion of GOTO differs.

Functionally, of course, there is nothing wrong with the GOTO. It actually works pretty well for a small program. However, what I meant was that GOTO doesn't scale very well to the development of larger applications, where it becomes harder to follow the logical progression of non-modularized code. However, realizing this on my own when I was first starting out with GWBASIC was a much more fulfilling learning experience than having someone else flatly tell me not to use GOTO (almost as awesome a moment as that great "aha" when I first understood LISP/Scheme =P), so I can see your point. And, as I said, GOTO is not totally evil. Telling someone to never use it before they can understand why is almost as educationally harmful as never saying anything.

That said, I would like to point out that I did like your unbiased evaluation of the GOTO statement in one of your Idea Break sections.
User IP Logged

Evan Williams
CSE, Lehigh University
Software Development Intern, Bentley Systems
Liberty BASIC Newbie
CarlGundel
Administrator
ImageImageImageImageImage


member is offline

Avatar

author of Liberty BASIC


Homepage PM


Posts: 2833
xx Re: Errata for "Beginning Programming with LB
« Reply #9 on: Jul 9th, 2010, 12:51pm »

I spend most of my time programming in Smalltalk. There is no GOTO statement, and there isn't even a SELECT/CASE statement. These things aren't necessary for software development. On the other hand, every once in a while you find yourself in a situation where you want to use GOTO but simply cannot do anything of the sort. wink

GOTO is a part of BASIC and always will be, and any language that wants to appeal to BASIC programmers will need to appeal to they way they like to write code.

-Carl

on Jul 9th, 2010, 11:58am, edw2011 wrote:
Yeah, that is true. For someone learning BASIC as a first language or coming over from an assembly language, GOTO would seem rather appealing because it is easily understood. My first language was C++, which is why I guess my opinion of GOTO differs.

Functionally, of course, there is nothing wrong with the GOTO. It actually works pretty well for a small program. However, what I meant was that GOTO doesn't scale very well to the development of larger applications, where it becomes harder to follow the logical progression of non-modularized code. However, realizing this on my own when I was first starting out with GWBASIC was a much more fulfilling learning experience than having someone else flatly tell me not to use GOTO (almost as awesome a moment as that great "aha" when I first understood LISP/Scheme =P), so I can see your point. And, as I said, GOTO is not totally evil. Telling someone to never use it before they can understand why is almost as educationally harmful as never saying anything.

That said, I would like to point out that I did like your unbiased evaluation of the GOTO statement in one of your Idea Break sections.
« Last Edit: Jul 9th, 2010, 12:52pm by CarlGundel » User IP Logged

author of Liberty BASIC
http://www.libertybasic.com
edw2011
Junior Member
ImageImage


member is offline

Avatar



YIM YIM AIM
PM

Gender: Male
Posts: 59
xx Re: Errata for "Beginning Programming with LB
« Reply #10 on: Jul 14th, 2010, 10:58am »

There is a very minor error in Chapter 7's exercise, the one where you add code to a given program to read from and write to arrays.dat. The code sets array size to 50, but when this number of entries is reached, the code still says, "All ten name slots are used!" as it did in previous examples.
« Last Edit: Jul 14th, 2010, 10:59am by edw2011 » User IP Logged

Evan Williams
CSE, Lehigh University
Software Development Intern, Bentley Systems
Liberty BASIC Newbie
CarlGundel
Administrator
ImageImageImageImageImage


member is offline

Avatar

author of Liberty BASIC


Homepage PM


Posts: 2833
xx Re: Errata for "Beginning Programming with LB
« Reply #11 on: Jul 14th, 2010, 3:47pm »

on Jul 14th, 2010, 10:58am, edw2011 wrote:
There is a very minor error in Chapter 7's exercise, the one where you add code to a given program to read from and write to arrays.dat. The code sets array size to 50, but when this number of entries is reached, the code still says, "All ten name slots are used!" as it did in previous examples.

Thanks for that.

-Carl
User IP Logged

author of Liberty BASIC
http://www.libertybasic.com
edw2011
Junior Member
ImageImage


member is offline

Avatar



YIM YIM AIM
PM

Gender: Male
Posts: 59
xx Re: Errata for "Beginning Programming with LB
« Reply #12 on: Jul 16th, 2010, 10:53am »

I've just confirmed that the above error also exists in Week 3's Challenge Exercise in the JustBASIC .chm tutorial, and in Lesson 3's Challenge Exercise in the Liberty BASIC Tutorial.
User IP Logged

Evan Williams
CSE, Lehigh University
Software Development Intern, Bentley Systems
Liberty BASIC Newbie
edw2011
Junior Member
ImageImage


member is offline

Avatar



YIM YIM AIM
PM

Gender: Male
Posts: 59
xx Re: Errata for "Beginning Programming with LB
« Reply #13 on: Jul 19th, 2010, 05:50am »

In Chapter 10, the Accelerated Buttons Idea Break section has a typo:

"Just as we can use accelerators with menus we can also do this with buttons. All we need to do it use the ampersand & character in our BUTTON statement."

That "it" should probably be an "is" if I'm not mistaken.
« Last Edit: Jul 19th, 2010, 05:51am by edw2011 » User IP Logged

Evan Williams
CSE, Lehigh University
Software Development Intern, Bentley Systems
Liberty BASIC Newbie
edw2011
Junior Member
ImageImage


member is offline

Avatar



YIM YIM AIM
PM

Gender: Male
Posts: 59
xx Re: Errata for "Beginning Programming with LB
« Reply #14 on: Jul 21st, 2010, 10:16pm »

In Chapter 11, the instructions for the exercise contain a typo. The exercise requires the previously uncovered use of a listbox control. Just before showing example code for a listbox, the book says:

"...Here is a short program that shows how to use a listbox control:

This let's take this idea and add some other controls to the dialog box:"

I'm not sure what the original intent exactly was, but I'm pretty sure that "This" should be a "Then".
User IP Logged

Evan Williams
CSE, Lehigh University
Software Development Intern, Bentley Systems
Liberty BASIC Newbie
Pages: 1 2  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Liberty BASIC Community Wiki
Wikispaces
Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls