The Liberty Basic Newsletter - Issue #84
© 1st December 2000 Cameron Arnott
All Rights Reserved
In this issue:
Attachments:
Proposed For Future Issues:
  • IRC Guide for Fellow LB'ers
  • More Spotlights on fellow Liberty BASIC programmers
  • More code snippets / attachments from the mailing list
  • A story on the history of Liberty Basic

Letter from the Editor Back to the Top

Wow, November went so fast, with three beta releases of Liberty BASIC V2 with the release version just around the corner Carl certainly has been busy.

It has also been another bumper month in the mailing list with 226 subscribers and over 1300 messages being posted and setting another new record, of which i have made a selection of interesting code and interesting tips for the archive.

"Thanks Giving" was celebrated this month.  I for one am thankful for everyone's support, help, kind wishes and praise for what I am doing for the Liberty BASIC community.  I'd also like to thank Carl for writing such a powerful, easy to use and learn programming language, for putting up with all of our suggestions and nags about improvements, and to sort through them all to see which of them should be implemented in Liberty BASIC.

There are a growing number of very worthwhile projects on the go and in development here are some just to name a few:

  • Visual Liberty BASIC - An editor / development system for programming in Liberty BASIC
  • Liberty Basic Development Studio - An editor / development system for programming in Liberty BASIC
  • Cheetah - A programming language written in Liberty Basic
  • LB Web Browser - written in Liberty Basic
  • Sprite maskers - Written to do Batch processing
  • FreeForms - GUI Window designers
  • painting programs and compactors
  • Games - Lots of them.  Too many to mention here!

    As you can see, Liberty BASIC can be used to develop a wide range of programs.  We have programmers from the age of thirteen right up and (way) past forty years of age.  All enjoying, learning, writing programs, helping others write programs and generally having a good time.

    Don't forget the "2001, A Liberty BASIC Odyssey" you can find the refined and amended rules for the contest on http://libertybasic.swiki.net

    The Red-Hot Price on the "flaming" LB2 T-Shirt is about to finish.  When LB2 is released to the public the price of the shirt will revert back to its normal price.  You can purchase this and other Liberty Basic Merchandise


    Happy Programming
    Cameron Arnott - AKA Blue_Steel
    blue_steel@globalfreeway.com.au

  • Spotlight on a fellow LB programmer - Brandon Watts Back to the Top

    This month's spotlight is on Brandon Watts, unfortunately he doesn't have a picture of himself on his computer that he can send us.  He is 14 years old and has his own web page at http://www.wattsware.com.  His Email address is brandonwatts@ga.prestige.net.  Previous programming experience was for 3 months using QBASIC.  He has been using Liberty BASIC for about a year and a half.  Brandon rates himself as an intermediate programmer using Liberty BASIC.  Brandon started programming in Liberty BASIC for it's ease of use, it's power, and the great online community.  He Says "I found it one day just searching the web for a basic programming language.  I was very delighted when I found out how great it was!" Brandon rates Liberty BASIC a 9.9 out of 10.  "It's the only language I use anymore! :=)"  Brandon's other interests include being the lead guitarist in a band called "Korrosion".  Gotta love the name!  "I also enjoy sports like basketball and baseball, and getting together with friends".

    I asked Brandon for a few words for all of you.  This is what he said:

    I just wanted to say what an honor it is to be a member of such a great programming group.  Everyone here has been kind and helped me out VERY much.  For that, I say thank you.


    Software Archives - By Brandon Watts
    http://www.wattsware.com
    Back to the Top

    So you have just created an awesome program.  Now you are excited to let the world know about it.  This can be one of the most exciting stages in software development.  The feeling of accomplishment is wonderful.  One of the best ways of advertising is software archives.  These sites on the internet hold programs from different companies and people.  Some are freeware, some are shareware.  Many people visit these sites, and downloads of your software can be abundant.  But before you submit your software to these sites, there are a few things that you should know.

    Make sure your program is good.  That may sound obvious, but it can be one of the most important factors to consider.  Since many people will be downloading your product, opinions could be formed about the quality of your software.  Some of these sites even have people that will review your programs.  What they say will affect how many people download the software.

    Debug.  This goes along with making sure your program is good.  I have heard of examples of people having obvious errors in their programs.  This is very embarrassing. I will admit my own shortcomings in this matter. In one of my programs, I had a menu item open a text file.  It worked fine for everyone using Windows 98.  However Windows 95 changed the name of the file a little bit.  This caused an error that could crash the program.  Just make sure everything is compatible with all versions of the operating system you develop for.

    Offer comprehensive help and contact information.  Make sure you include a great help file.  It will help them use your product, and a better help file will make some people use your product longer.  Contact information will let them know that you are ready to help them should problems arise.  Offer a variety of ways to contact you.  There is a service called Onebox, which gives you a free phone number.  You can check your messages from a phone or log into your account on the net.  I use it, and love it.  Their address is:

    http://www.onebox.com

    Now you are ready to upload your program.  The process is very easy, and they ask you a few questions about file size, name, website, etc.  Make sure the information you type in is correct.  Here is a list of some of the major ones you should submit to:

    http://www.hotfiles.com
    http://www.download.com
    http://www.tucows.com
    http://www.32bit.com

    You can also use programs that do it for you. I suggest the program SoftSubmit.  It is made by AnalogX.  It has a huge list of archives to submit to.  Get it at:

    http://www.analogx.com

    These software archives also make it easy for you to update your programs listing when you make new versions.

    Be patient.  Many of these sites are so backed up, it can take forever to be listed.  One of the programs I submitted to download.com took them over two months for them to get back to me!

    Uploading your software is very easy.  Just make sure you follow the steps in this article, and your product is sure to be a hot download.


    Binary Searches    - By Richard Miller Back to the Top

    The first principle is to halve the search range after each unsuccessful compare.

    The second principle is that the values to be searched must be in sequential order.

    Example 1: (binsrch.bas)

    First, an array is filled with even integers from 2 to 3998.  The reason for skipping odd values is to show what happens when a value is not found.  I chose to make the array a string array, so the values have to have leading zeros added to make them all four characters long.  Likewise for the values to be looked up.  There is also code to not allow searches outside the table range.

    The actual search always starts in the middle of the range.  I calculated that by adding the top and bottom values and dividing by two.

    For this demonstration, I chose to drop the fractional portion of the calculated pointer.  This means the top-most array element can not be found.  I believe that if the result is rounded up, the top-most value could be found, but the bottom-most element could not be found.  The values in the table or array to be searched, and the search ranges should be set with this decision in mind.

    The main principle is embodied in this statement :

    If lkp$<tbl$(x) then ' compare lookup value to array element T=x ' take the lower half by setting top to current index Else ' take the upper half B=x End if

    If the searched value is less than the array element, the top of the search range is set to the current value of x, otherwise the bottom of the search range is set to the current value of x.  The search range is cut in half either way.  Then the new range's midpoint is re-calculated, and a new comparison is made.

    The lookup value may not be found in the table.  I checked for two consecutive comparisons to the same array element to establish a not found condition:

    If tbl$(x) = prev$ then [not] ' not found Prev$=tbl$(x) ' save previous not found element

    When a searched-for value is not found, returning a flag value is an appropriate action.  This demonstration only prints an error message.


    Example 2: (dlirsrch.bas)

    This program is a more practical, real-world example.  The binary search is written as a function.  The table limit has to be passed to the function so that it can be used inside the function.  I also chose to pass the bottom value of 1 each time, to avoid an assignment statement inside the function.

    The program first reads a file of records into an two dimension array (or table).  The count of records added to the table becomes the top limit in the search:

    While not(eof(#3)) Pjt$(pjtCtr,1)=pjtNbr ' store data item to check Pjt$(pjtCtr,2)=munt$ ' store data item to return wend

    The program then reads a data file, and calls the lookup function for every record

    After returning from the function, the program either writes an output record with the found value appended, or prints an error message.

    Within the function itself, the value of the function is set to null and is then used in a while-wend statement.  The value of the function is set to the found value or a flag value.  Either case ends the while-wend loop.

    This statement returns a real value if the search value is found in the table:

    If lkp$ = pjt$(x,1) then lookupPjt$ = pjt$(x,2)

    This statement returns a flag value if the search value is not found:

    If pjt$(x,1) = ppjt$ then lookupPjt$ = "ZZ"

    This statement cuts the search range in half:

    If lkp$<pjt$(x,1) then T=x Else B=x End if

    If the only purpose of the binary search is to validate a value, then both the found and not-found values could be flags, and tested for appropriate action after being returned from the function.


    Code Snippets/Attachments posted in LBNews in November: Back to the Top

    I'm trying a new layout for this section.  please give feedback.  The new format includes the actual message submitted as opposed to my attempts to describe their content.  Every message listed in these newsletters are a selection which I deem worth keeping for prosperity, if you know of other messages that are worth keeping and would like them listed in here then please send me the relevant info about the message; ie: the author,subject,date and a brief description of the message.  Thank you.

    From: Brandon Watts [brandonwatts@ga.prestige.net]
    Sent: Wednesday, 1 November 2000 9:07 AM
    To: lbnews@egroups.com
    Subject: [lbnews] Title Change
    Attachments:title.bas

    Hello,

    Here is a neat little program that will change the title in a window to what the user types.  It does this automatically.  I was going to use this in Cheetah.  The user types the title in the Title box, and the Demo window updates.  I still might use it.  There is a little flicker, but that's to be expected.  It is simple, but I hope you enjoy it!

    Brandon Watts
    http://wattsware.com

    From: carlg@world.std.com
    Sent: Wednesday, 15 November 2000 12:50 PM
    To: lbnews@egroups.com
    Subject: [lbnews] Three dimensional arrays

    Just thought I'd post this little snippet.  Just got a question about how to do 3 dimensional arrays in LB.  This is not directly supported, but you can simulate them easily, as shown below.  Four or more dimensions are also double.

    -Carl
    'make an array big enough to hold information 10 by 10 by 10 dim myArray$(10, 100) 'set the value in 3D space call set3D$ 4, 5, 6, "I'm here" 'now print out the value at that location print get3D$(4, 5, 6) end sub set3D$ x, y, z, stringValue$ myArray$(x, y + z * 10) = stringValue$ end sub function get3D$(x, y, z) get3D$ = myArray$(x, y + z * 10) end function

    From: ddrake@acipco.com
    Sent: Wednesday, 22 November 2000 1:23 PM
    To: lbnews@egroups.com
    Subject: [lbnews] Try two interesting coding tools

    Hello all.

    I've just completed two coding tools.

    (1) Code Beautifier: I wrote this originally for myself.  My code tends to look ugly when I'm done, but Code Beautifier cleans it up by capitalizing keywords, indenting for loops, subs, functions, and so forth, and by evening up whitespace.  All these are options you can turn off and on, too.

    http://www.egroups.com/files/lbnews/beauty.zip

    (2) Shortcut 1.0: Another one I created for myself.  I just couldn't keep up with the latest changes in version 2.0.  Finally I made this little tool to help me find the statements I needed.  Shortcut 1.0 lets you select an LB 2.0 command from a list (separated by category, if desired) and copies an example snippet to the clipboard.  Simply paste it into the LB editor (or whatever).  Also, it's set for "always on top" for easy access.

    http://www.egroups.com/files/lbnews/shortcut.zip

    If you get a chance to try either of these, I'd appreciate it.  This version of Beautifier has not damaged any of my programs (yet).  The commands list file that comes with Shortcut is certainly incomplete, but I'm sure there are experts in the community who could really improve it (hint hint ;-))

    Thanks!

    -David Drake

    From: A. Watson [alycewatson@charter.net]
    Sent: Sunday, 26 November 2000 11:59 PM
    To: lbnews@egroups.com
    Subject: Re: [lbnews] Re: more about cursors...

    >At 07:32 PM 11/25/00 -0000, you wrote: >I posted the original message and thought that this had to be done >internally (something CarlG would have to do from within but this >got me thinking so i went at it to make it work. Here it is! use > any cursors in LB with no flickering! > >'Cursor Example by Mitchell Kotler

    Mitchell, I wanted to have a list of cursors, to make it easier to access the one I wanted, so I modified your code a bit.

    Thanks for the example!

    Alyce
    'Cursor Example by Mitchell Kotler 'How to use LoadCursor and SetCursor to access ' more Window's Cursors 'No more flickering! 'modified Nov 26, 2000 awatson DIM Cursors$(27) Cursors$(1) = "512 arrow" Cursors$(2) = "513 I beam" Cursors$(3) = "514 hourglass" Cursors$(4) = "515 crosshair" Cursors$(5) = "516 up arrow" Cursors$(6) = "640 4 way arrow" Cursors$(7) = "641 icon" Cursors$(8) = "642 nwse" Cursors$(9) = "643 nesw" Cursors$(10) = "644 ew" Cursors$(11) = "645 ns" Cursors$(12) = "646 nesw" Cursors$(13) = "648 no sign" Cursors$(14) = "649 pointing hand" Cursors$(15) = "650 arrow and hourglass" Cursors$(16) = "651 arrow and question" Cursors$(17) = "652 big ns" Cursors$(18) = "653 big ew" Cursors$(19) = "654 big nesw" Cursors$(20) = "655 big n" Cursors$(21) = "656 big s" Cursors$(22) = "657 big w" Cursors$(23) = "658 big e" Cursors$(24) = "659 big nw" Cursors$(25) = "660 big ne" Cursors$(26) = "661 big sw" Cursors$(27) = "662 big se" 'BEGIN nomainwin statictext #1.s, "", 20, 20, 200, 20 combobox #1.c, Cursors$(),[changeCursor],20,60,150,300 open "Cursor Example" for window as #1 print #1, "trapclose [quit]" print #1.c, "selectindex 1" print #1.s, Cursors$(1) h=hwnd(#1) call setClass h goto [changeCursor] [loop] call SetCursor CursorHandle scan goto [loop] [quit] close #1 end 'This routine changes which cursor is loaded [changeCursor] print #1.c, "selection? item$" cursorNum=val(str$(32)+word$(item$,1)) CursorHandle=LoadCursor(cursorNum) print #1.s, "32"+item$ goto [loop] sub SetCursor hCursor open "user" for dll as #user calldll #user, "SetCursor",_ hCursor as short,_ result as short close #user end sub 'This loads the cursor and returns the cursor's handle function LoadCursor(CursorName) open "user" for dll as #user calldll #user, "LoadCursor",_ 0 As short,_ CursorName As long,_ hCursor As short close #user call SetCursor hCursor LoadCursor=hCursor end function sub setClass hWnd index=_GCW_HCURSOR or 0 'which part to set value=0 'set it to null open "user" for dll as #user calldll #user, "SetClassWord",_ hWnd as short,_ index as short,_ value as short,_ result as short close #user end sub

    From: Mitchell Kotler [smartestmanal1ve@netscape.net]
    Sent: Tuesday, 31 October 2000 7:13 AM
    To: lbnews@egroups.com
    Subject: [lbnews] Re: Background processing V 2

    Hey I wrote a program that will do what you want.  You should be able to adjust it to do what you want.

    'by Mitchell Kotler nomainwin notice "Hit Ctrl + Q to quit" open "user" for dll as #user 'not defined in LB VK.Q=81 VK.FIVE=53 [top] calldll #user, "GetAsyncKeyState", _VK_CONTROL as short,_ ctrl as short calldll #user, "GetAsyncKeyState", VK.Q as short,_ Q as short calldll #user, "GetAsyncKeyState", VK.FIVE as short,_ five as short calldll #user, "GetAsyncKeyState", _VK_SHIFT as short,_ shift as short 'if the result of the function is less than 0 then the key is down if five<0 and shift<0 then notice You hit the percent key if ctrl<0 and Q<0 then [quit] goto [top] [quit] notice Good Bye close #user end

    You will be able to use other programs and if at any time the keys are hit this will respond.  Just be sure to always have some way to quit.

    -Mitchell