|
Liberty BASIC Developer
Vol. 1 No. 2 August 2001
Contents:
Editors Note
LB News
Open Source: html editor
COMMAND Focus: Texteditor
Site links
Feed back
Legal Stuff
Editors Note
I hope that everyone is having a great summer. We have been away quite a bit doing the camping
thing and enjoying ourselves at the lake. It is always nice to have this type of family time
away from work and many of todays technological marvels.
Shortly after finishing the first issue and getting it up loaded to its new web site
my computer decided that it was going to crash. With much dismay I came to the realization
that the 17gig hard drive in my computer was not going to work or give up any of the
information which I had stored on it. ARG! Fortunately I had floppy backups for these
files and a recent cdrom of the data on my hard drive. So the toll of lost data was not to
great, but the work required to reload all of the software on to my system will be quite a chore.
I knew that my hard drive needed a major clean up, though this was not the way I wanted to go
about it. As of now I am still using a small temporary unit until my replacement arrives in the mail.
The whole point of me telling you all about this is to remember to do regular backups
of all your important data files. Having those recent backups, can greatly ease the pain of
a major system break down.
Along the same lines, it is always a good idea to make incremental backups of programs
that you are working on. An example of this would be to start with a program name of
eg. pgma0001. As you add more code or make adjustments, future saves would increment eg.
pgma0002, pgma0003. When you are just about finished and the program is working correctly
these early files can then be deleted. If you encounter a major error in a program, you can
just step back one file and try to see were the error occurred.
Hope that you find the second issue of Liberty BASIC Developer useful.
Enjoy!
Neil Tremblay
top
LB News
With summer upon us the message traffic on the 3 egroups to which I subscribe have slowed some,
but there is still some great information coming out. Most important is that Alpha testing of
LB ver3 has begun. Will be looking forward to the public release of it in the near future.
You can check out the
Captains log of what is being done on the Liberty BASIC web site.
On the lbexp egroup, message 181 posted by Alyce is an interesting routine. What I want to point
out is addition to being quite cool, the use of functions and subroutines which makes the main
code body easyer to read and follow. You also have reusable code which can be easily pasted into
another program. You should see an article about it in the LBNEWS letter. I look forward to seeing
it when it comes out.
top
Open Source: html editor Part 1
The idea for writing this article came after building the LB Dev web site.
I used a combination of an Automatic Web Site builder, MS Word and finally Notepad
to clean things up and to make the site appear and function the way I want.
I prefer using notepad for making a web site but would like some of the features of the
large commercial programs. What I need is, a super version of notepad were I would be able
to insert commonly used html tags easily. Hence here we go with our open source html editor.
The first thing that we will need to do is write our program specification, that is what we
would like our program to do. Ok i want a text editor with some editing functions. Some way
to insert common html commands. File handling would also be a good idea. Another thing
would be a help file. So lets list out what we have so far.
TEXTEDITOR
FILE
EDIT
COMMANDS
HELP
In this project we will use the built in texteditor of Liberty BASIC. I will not go into detail
about it here, as it will be covered in the COMMAND Focus section of this issue. For the FILE
section I want the following items, new file, load file, save file, save-as file, print and exit.
We could add additional items to this if we wish, but this is a good start to get the program up
and running. Next is the EDIT items. When we use the built in texteditor there is already a number
of functions added for us, so we will use them. They are undo, cut, copy, paste, clear, select all,
print selection, find/replace and find again.
Now here is were the real fun starts. COMMANDS. We will have to decide which html tags we wish
to use. Every one will have there own feel as to what they use the most and which are common. I
will lay this out the way I want, and you can modify your version to fit you. This is the benefit of being
an open source project.
Lets do a little side step here before we continue. Before we can carry on we will need to do a
little studying about html. There are quite a few good books out there which you could either
purchase or better yet borrow from your local library, which is one of my favorite sources. There
are also a number of web sites which have tutorials on writing html and creating web sites. One of
these is called HTML Goodies, it has quite a few tutorials to get you up to speed if your not a
html guru(I'm not, so I look here frequently). Look at the site links section of this issue to go
to that site.
I will be breaking up the commands into a couple of groups. These will be common, font, table,
links and graphics. Under the common heading I will use bold, italic, center and right. For font
I will use font, size and header. Table will have table, row and data. With the links and
graphics we need web links, page links, bookmarks, graphic files and one additional thing is
time/date.
The help section will have to contain at least help and about. Lets redrawn what we have now.
TEXTEDITOR
- LB text editor
FILE
- new file
- load file
- save file
- save-as file
- print
- exit
EDIT
- undo
- cut
- copy
- paste
- clear
- select all
- print selection
- find/replace
- find again
- exit
COMMANDS
- common
- font
- table
- link & graphic
- web links
- page links
- bookmarks
- graphic files
- time/date
HELP
- help
- about
It looks like we now have enough basic information to start creating the basic code structure.
Next month we will use the above program specification and create our program window with freeform
which is included with Liberty BASIC. You will need to have a registered version of Libert BASIC
to complete this project as it will exceed the maximum command limit for the unregistered version.
Happy programming!
top
- COMMAND Focus: Texteditor
As we are making our own HTML editor in this issue I thought that it would be a could idea to cover
this control at this time. Here is the command that must be issued prior to opening our window so
that we can use the texteditor. We get this from the Liberty BASIC help file.
TEXTEDITOR #handle.ext, xpos, ypos, wide, high
#handle - is the name assigned to the window in which this control is placed.
.ext - this is the unique name for this control within its window.
xpos, ypos - this is where the top left corner of our control is placed in its window.
wide, high - this sets the size of our texteditor control in its window.
Here is a complete list of the commands used with the texteditor control. They are almost all the
same for the texteditor window as well as some for the textbox control.
- print #handle.ext, "Some text"; or aText\\$;
- print #handle.ext, "!autoresize";
- print #handle.ext, "!cls" ;
- print #handle.ext, "!contents varname\\$";
- print #handle.ext, "!contents #handle";
- print #handle.ext, "!contents?"; input #handle.ext, string\\$
- print #handle.ext, "!copy" ;
- print #handle.ext, "!cut" ;
- print #handle.ext, "!font faceName width height" ; or "!font faceName size" ;
- print #handle.ext, "!line #" ; input #handle.ext, string\\$
- print #handle.ext, "!lines"; input #handle.ext, countVar
- print #handle.ext, "!modified?"; input #handle.ext, varName\\$
- print #handle.ext, "!origin?"; input #handle.ext, rowVar, columnVar
- print #handle.ext, "!origin row column";
- print #handle.ext, "!paste";
- print #handle.ext, "!select column row";
- print #handle.ext, "!selectall";
- print #handle.ext, "!selection?"; input #handle.ext, varName\\$
- print #handle.ext, "!setfocus";
Lets take a look at how each of these commands for the texteditor control will work. Even though
I will start with the autoresize command the remainder will not necessarily be in the order I have
displayed nor will I do a repeat of what is in the LB help file.
We will issue this command for the texteditor control right after we open the window.
It will automatically resize the texteditor control in its window, keeping it the same distance
from the border. This frees us from having to track and manually resize it on our own.
The font command can be used to change the font that is displayed in the texteditor control. Some
people may wish to use this for changing the font face or the size of text to make it easyer to
read. When specifing the font it may be necessary to use the underscore character to make the
font name a single variable. Here are 2 samples of this.
#main.te, "!font Arial 14";
#main.te, "!font Courier_New 15 20";
For a window with multiple controls we may wish to have the texteditor as the principle one. This
is done by setting the focus to it for input. This is accomplished with the setfocus command.
We may have to issue this command in several locations in our program.
There are several commands to get the typed information out of the texteditor control. They are
contents?, copy, cut, line# and selection?, with copy, cut and selection? being user controlled
selections. The other 2 are program defined selections. The contents? and selection? commands are used to
read into a string variable. The difference between these 2 commands is that contents? gets the
entire texteditor control, and selection? retrieves only the highlighted text. Neither affect what
is displayed in the window. The copy and cut command move the selected text to the clipboard,
with the later actually removing the selected text from the control. The last command of this
group is line#, which reads an entire line of text into a variable under program control.
Another command which is can be used in conjunction with cut and copy is selectall. This command
causes everything in our texteditor control to be selected.
Now to get information into our texteditor control we can use the following, print, contents and
paste. Print is the simplest of these it takes the following form and is appended to the end.
print #main.te, "Some important text"
Remember if you put a semicolon at the end additional text will be printed right after it on the
same line, other wise a lf/cr will be appended forcing more output to the next line. Paste takes
what is on the clipboard and inserts it at the current cursor position. The last way is the
contents command which comes in 2 forms. The first one replaces the contents of the texteditor
control with what is in our string variable. The second replaces the contents of the texteditor
control with the contents of a file with the specified handle. Note the word 'replaces', anything
in the texteditor prior to this command will be lost!
There are 3 commands availalbe to do with position in the editor. The origin command can be used
to get and set the text position within the texteditor control window. We are also able to set
the cursor position. This is accomplished using the select command with column and row variables.
I have 3 commands left to cover. The first 2 provided us with information about our texteditor
control. The first is the lines command, which when executed provides us with the current number
of lines of text in our window. You could use this for some looping function to check for something
or another. Next is the modified command, which can be used to check to see if text has changed so
that we will have a chance to save a file. Last but not least is the cls command, which if you are
familiar with most any version of basic will clear the screen, or in our case the texteditor
control. Warning! if this command is issued before data is saved, just say good bye.
Well that completes our over view of the available commands for the texteditor control. One
which I think would be useful that was not in the help text is select?. Where the select command
sets the cursor position in the editor window, select? would give you the current cursor position.
May be Carl will read this and think about it? Or have I just missed something some where. Let
me know what you think.
top
Site links
http://www.libertybasic.com Liberty BASIC home page
http://www.htmlgoodies.com HTML Goodies
http://alyce.50megs.com Alyce's Restaurant ??
http://lcsoftlb.50megs.com Liberty BASIC software from the Left Coast. Editors home site
http://lbdev.5u.com Liberty BASIC Developer home page
top
Feed back
All readers feed back is welcome whether its to do with this issue, future acticles
or comments in general. Send your message to mailto:lbdev@lbdev.5u.com
Any one who wishes to submit an article for publication, please send it to the editor. mailto:lbdev@lbdev.5u.com
top
Legal Stuff
The Liberty BASIC Developer ezine and lbdev.5u.com are © Neil Tremblay 2001 all rights reserved.
top
|