Free Web Site - Free Web Space and Site Hosting - Web Hosting - Internet Store and Ecommerce Solution Provider - High Speed Internet
Search the Web

Liberty BASIC Developer
LBDev ezine

 

Home
About
Current Issue
Past Issues
Files
Links
FAQ
Contact

Liberty BASIC Developer

Vol. 1 No. 4 October 2001

Contents:

Editors Note

LB News

Open Source: html editor

COMMAND Focus: Timer

Site links

Next Month

Feed back

Legal Stuff

Editors Note

I must first say to all who have been effected by this past month's event that my prayers are with you. I would also like to ask that everyone pray for the leaders of our countries, to give them the strength and insight to endure what will probably be very trying times.

PEACE

Neil Tremblay

top

LB News

Work continues on Liberty BASIC 3. Looking at the captains log I see that Carl is working on adding call back ability to it. This should allow more functionality, and the way I understand it is for outside programs to call functions within LB.

One recent message from Patric to the Libertybasic news group, LB-tech had an attachment of a data logging program. If you get a chance to look at this, it contains 2 programs. The first does data logging using the inp/out functions to collect data from an external source and display it on a graph. DO NOT RUN this program as it will lock your computer if you do not have the I/O card. The second program "which you can run", will display in a graph the selected data file. What I like is the use of the inp/out functions and the graphical display of data. Nice work Patric.

top

Open Source: html editor Part 3

Well here we are back again looking at our HTML editor. First I would like to thank Brian Davies and Mike Bradbury for all the work which they have done to add more functionality to the HTML editor.

Here are the additions made by Brian Davies
- Form Tags
- Insert Basic HTML and ASP pages
- Form Controls and some options
- added KILL temp.html to keep from leaving an extra file on hard drive

Here are the additions made by Mike Bradbury
Added - background colour to editor window
Added - background/bgproperties to basic html code
Added - Insert HTML for Frames, Javascript and Update info (date/time)
Moved - Time/date from Links menu to Insert menu
Added - mailto: to Links menu
Button renamed and font set
. Added - Combobox for common tags
Changed - html tags unified to lower case, which may become the standard recommendation.
Changed - Font menu
Added - Legend value for 'Reset' button

Also thank Alyce Watson for creating a folder in the files section of the LBexp group for holding the different versions of the HTML editor. So if you are looking for the most resent version, this is the place to look.

I decided that after using the editor for a while that there would be a couple of more functions that I would like. Here is a list of the things which I've added to the editor which you may find useful.
Added - file path and name to title bar
Added - exit test for file saved.
Added - enhanced common codes bold,italic,center and right to allow highlighted text to have command applied to it.
Added - enhanced paragraph code to common commands

This first item displays the name of the current file that is being worked on in the title bar of the HTML editor window.
Here is the call for the subroutine and the subroutine.

call winTitle edTitle$+fileName$

sub winTitle wTitle$

hParent = hwnd(#main)
open "USER" for dll as #user

calldll #user, "SetWindowText", _
  hParent as word, _ 'use Parent window handle here
  wTitle$ as ptr, _
& nbsp;result as void
close #user

end sub

The next item is something which I had forgotten place in the original version. This just checks to see if the file had been saved prior to exiting the program. This used the "fileSaved()" function.

The last thing added was an enhancement to the common commands. Normally when creating a text page I will enter the text for the page and then go back and hand edit it so that the page looks the way I want. I found though that I needed to do some cut and paste as the commands would locate their start and end commands together. Wanting to make my life a little easier, if i could just highlight the text and get the tags to bracket it, I would be happier. So here is the code that I came up with.

[boldOn] 'Perform action for menu Common, item Bold on

print #main.textedit1, "!cut"; 'get highlighted text if any
print #main.tb, "< b>"; 'print start command
print #main.tb, "!select 4 1"; 'set cursor position
print #main.tb, "!paste"; 'put highlighted text if any
print #main.tb, "< /b>"; 'print end command
call htmlinsert
wait

This program still has plenty of room for improvement and added functionality. Next month I will see if I can get to making a table wizard and maybe improving the entry of page links and graphic images. There is also another item which needs to be produced and that is a help file. What else would you do to get more from the HTML editor?

Happy programming!

top

COMMAND Focus: Timer

For this month's COMMAND Focus we are going to take a look at the "Timer" function. Here is the basic command as it is listed in the Liberty BASIC help file.

TIMER milliseconds, [branchLabel]


First off starting with the basic command, "timer" can be upper, lower or combination of case. Next is the milliseconds setting of when the timer if fired. Last is the [branchLabel] where program execution jumps to when the timer is fired. Now I can just here what you might say, "Isn't that special", but what good is to me in my programs.
There is only one thing that it can do, and that is periodically send your program to the specified branch label. But it doesn't end here. What you decide to do when the timer is fired is almost limitless. Here is a small program which updates a clock once a second.

nomainwin

WindowWidth = 145
WindowHeight = 150
UpperLeftX = int((DisplayWidth-WindowWidth)/2)
UpperLeftY = int((DisplayHeight-WindowHeight)/2)

statictext #main.time, "xx:xx:xx", 25, 30, 90, 20
button #main.12hour, "12 Hour", [twelveHour], UL, 25, 75, 40, 20
button #main.24hour, "24 Hour", [twentyfourHour], UL, 70, 75, 40, 20

open "Clock" for window_nf as #main

print #main.time, "!font courier_new 8"
print #main.12hour, "!font ariel 6 10"
print #main.24hour, "!font ariel 6 10"
print #main, "trapclose [exit.main]"
timer 1000, [update]

[twelveHour] 'set up twelve-hour mode

twelveHourFormat = 1
time$ = ""

prefix$ = ""
wait

[twentyfourHour] 'set up twentyfour-hour mode

twelveHourFormat = 0
time$ = ""
prefix$ = " "
wait

[update]
print #main.time, formatTime$(twelveHourFormat)
wait

[exit.main] 'code to close program

close #main
END


function formatTime$(twelveHourFormat)

hours = val(left$(time$(), 2))

if twelveHourFormat = 1 then
if hours > 11 and hours < 24 then
suffix$ = " PM"
else
suffix$ = " AM"
end if
if hours > 12 then

hours = hours - 12
'suffix$ = " PM"
else
if hours = 0 then hours = 12
'suffix$ = " AM"
end if
else
suffix$ = ""
end if
x$ = time$()
formattedTime$ = prefix$+right$("0"+str$(hours), 2)+mid$(time$(), 3)+suffix$
formatTime$ = formattedTime$
end function

Another example of using the timer function can be found in the Liberty BASIC news group at message number 699. This has multiple trigger points of timing intervals from a single function. I really like the flashing lights.

A couple more points that you should know about are that you can change the timer interval during your program for what ever your reason. Look at the following command.

timer 0

This now disables firing the timer. If we now want to restart the timer we can issue the following command.

timer 250, [doingWhatsneeded]

So this gives us the ability to change the interval of when the timer is fired, where the program should go, if it should go at all.

The timer function can add some very powerful features to your programs. You can use it to control the speed of games by how often your sprites are moved, when keys or the joystick is checked. I have been working on using it to poll microcontrollers connected to the serial port my computer. Let your imagination run wild and program!

top

Site links

http://www.libertybasic.com Liberty BASIC home page

LB-tech program by Patric

HTML editor Open source, code

http://lcsoftlb.50megs.com Liberty BASIC software from the Left Coast. Editors home site

http://lbdev.5u.com Liberty BASIC Developer home page

top

Next Month

  • Open Source: Html Editor
  • Command Focus: Call/Sub

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:neiltrem@hotmail.com

Any one who wishes to submit an article for publication, please send it to the editor. mailto:neiltrem@hotmail.com

top

Legal Stuff

The Liberty BASIC Developer ezine and lbdev.5u.com are © Neil Tremblay 2001 all rights reserved.

top

 
Copyright (c) 2001 Neil Tremblay
2571