Liberty Basic is develeopped by Carl Gundel
Original Newsletter compiled by Alyce Watson and Brosco
Translation to HTML: Raymond Roumeas

The Liberty Basic Newsletter - Issue #47 - AUG 99

"Knowledge is a gift we receive from others." - Michael T. Rankin


In this issue:

  1. Programmer's Spotlight on David Mosley
  2. David Mosley in his own words
  3. Flowcharting in a new way, by David Mosley

In future issues:

Procedure Parameter Passing and Encapsulation, by Herman

Serial Communications, by Herman

Thunking with call32.dll


1)Programmer's Spotlight on David Mosley

David is a frequent contributor to discussions on the LB Newsletter mailing list, where his friendly and helpful input is enjoyed by everyone. He has taken the time to write an article AND sample program for the newsletter on Flowcharting. We can all use his advice to help us plan and outline our programs.

THANKS DAVID!!!

Contact David P. Mosley at:

mailto:pmosle-@infoway.lib.nm.us


2)David Mosley in his own words:

Hi,

My name is David Mosley and I have been programming in Liberty Basic for about 2 years now. I first started to write programs 15 years ago. That was when a really fast computer was a 8085 or a 286. I first started with a Commodore 64 (the 64 stands for the memory that it had - 64k.) That is when I learned Flowcharting; I had to, because we had so little to work with that we had to watch every little piece of the program in order to get it to fit.


3)Flowcharting in a new way:

Flowcharting is simply writing down the flow of a program. You start with the start of the program, list all variables and non-variables, arrays, dims, and other things that you might have that you want to put into the program. Then you go to the next step in the program and write that down, etc..

Below is an example of the way that I do a Flow chart in Liberty Basic. You can copy the program into LB, then right click and go to Branches. You will see that there is a branch called [flowchart]. This is the flow chart for the program.

FLOWCHART SAMPLE PROGRAM:
(watch for line wraps!)
 
[main.BeforeLoad]
NOMAINWIN 'Turn off main window
 
'** Set Window Attributes
UpperLeftX = int((DisplayWidth- 630)/2) 'Center window horizontally on
screen
UpperLeftY = int((DisplayHeight- 471)/2) 'Center window vertically on
screen
WindowWidth = 630
WindowHeight = 471
 
'** Add Window Controls
texteditor #main.te1 , 1, 1, 623, 427
 
 
Menu #main, "&File", "&Load", [main.load], "&Save", [main.save], |,
"&Exit", [main.exit]
Menu #main, "&Edit" '** Display window
OPEN "Example Editor" For window AS #main
Print #main, "TRAPCLOSE [main.CloseWindow]"
 
 
[main.AUTORESIZESetup] 'Enable Graphic Boxes and Text Editors can
automatically resize
Print #main.te1 , "!AUTORESIZE";
 
[main.InputLoop]
Input eventCheck$ 'Check for events
 
 
[main.CloseWindow]
 
CLOSE #main
END
 
[main.load] 'Insert code for the menu item "&Load"
filedialog "Open file","*.txt",Filename$
print #main.te1,"!cls";
open Filename$ for input as #1
print #main.te1, "!contents #1";
close #1
print #main.te1,"!origin 1 1";
tempfilename$=Filename$
Filename$=""
Goto [main.InputLoop] 'Check for more user events
 
[main.save] 'Insert code for the menu item "&Save"
open tempfilename$ for output as #1
print #main.te1, "!contents?";
input #main.te1,temp$
print #1,temp$
close #1
Goto [main.InputLoop] 'Check for more user events
 
[main.exit] 'Insert code for the menu item "&Exit"
close #main
end
Goto [main.InputLoop] 'Check for more user events
 
'**********************************************************************
[FlowChart]
'1) ( ) Open window and set up varables for use
' Variables for use ( Filename$-Local
' temp$-Local
' tempfilename$-Global)
'2) ( ) Open file with Filedialog(Filename$)
' a) ( ) Print the file to textbox editor named as te1
' b) ( ) Put the slider control back to top
' c) ( ) transfer Filename$ to tempfilename$
' d) ( ) clear Filename$
' e) goto input
'3) ( ) Save file branch
' a) ( ) open tempfilename$ to save file as output
' b) ( ) save contents of editor te1
' c) ( ) Close file and goto input
'4) ( ) Close program

Let's look at #1) Read the flow chart outload and see if it makes sense. (Hint - you can also do this when you get a bug in your program. It will help you find it. If it sounds OK, then it probably is ok.)

The ( ) mark is used to check off when you have done the coding. I have named the Variables and also put down if they are local or global. This will help to see if you have used this variable before and to see if you can use it again in the program without losing any info. The global variables are used throughout the program. The local variables are used just where they are put into the flow chart so you can use them again in another area of the program.

This flow chart is a simple one. If you get into a program that is 500 or more lines long, you can see how handy this is to use, and it could save some time in the debug and coding of your program.

I hope this article has helped you to see the value of Flowcharting your program first. It may take some time to do this but it is well worth the effort.


Newsletter compiled and edited by: Brosco and Alyce.

Comments, requests or corrections: Hit 'REPLY' now!

mailto:brosc-@orac.net.au

or

mailto:awatso-@mail.wctc.net