The Liberty Basic Newsletter - Issue #83
© 1-November-2000  Cameron Arnott
All Rights Reserved
In this issue:
Attachments:
Proposed For Future Issues:
  • More interesting code snippets
  • Spotlight will do more interviews with more LB Programmers
  • Liberty Basic on the Net
  • How to access our chat channel on irc.dal.net #Liberty BASIC

Letter from the Editor: Back to the Top

Greetings one and all,

Well another month has passed and what a busy month it's been.  We now have a total of 207 official members in the group, of which 28 are new members this month.  There are a total of 10,689 messages in the LBnews mailing list here at egroups.com, of which this month boasts the record total of 1149 messages posted to our mailing list.

Carl has now got Liberty Basic Merchandise for sale
"Liberty BASIC 2" T-shirts, mugs and mouse pads for sale!
!Attention! SPECIAL reduced price of the great flaming "Liberty BASIC 2" T-Shirt.   This is a good quality shirt and a bargain at the special price of $10.99 (not including $4.00 shipping in the US).  Special price will remain until LB 2.0 ships!

The Liberty BASIC CoWeb site has now been re-launched.  The new site is password protected to prevent that awful vandalizism we experienced earlier this year, so if you want to take part, just email Carl Gundel and ask for an account.
The new site is located at http://libertybasic.swiki.net

It gives me Great pleasure to announce "2001, A Liberty BASIC Odyssey" is now open for entries.

The contest is to help promote Liberty BASIC, show people what can be done using Liberty BASIC and how.  It's also a showcase for people show off their contributions to the Liberty BASIC community.

All nominations and submissions must be in by the 1st July 2001 (no extensions).

You can enter or nominate as many times as you like, however when it comes time to vote you only get one vote in each category.

The voting polls will open at lbnews after that and will remain open until the 1st October 2001; every member of lbnews is eligible to vote in all categories.

Winners will then be announced by the 14th October 2001

The prizes:  The winners of each section get the choice of either a "Liberty BASIC 2" T-shirt and Mug or A Liberty BASIC registration (for the current version at the time the competition closes.)

ALL prizes are being donated to the "2001, A Liberty BASIC Odyssey" contest by Carl Gundel.
The prizes are Carl's way of thanking everyone for all the work and effort that goes into helping the Liberty BASIC community grow, and for all the help which is provided in all forms.

Here are the categories available to all to enter:

Best LB content Web site:

Owners of the web site can't nominate themselves, they have to be nominated by at least one member of the mailing list.
Please send your nominations to Cameron Arnott.
With the subject line: Best LB content Web site nomination.
In the message URL for the web site/page and an email address of the owner.

Best LB newsletter contribution:

The author of the article can't nominate themselves.  They have to be nominated by at least one member of the mailing list.
Please send your nominations to Cameron Arnott.
With the subject line: Best LB newsletter contribution nomination.
In the message state the newsletter issue number, article header and the author.

Best mailing list contribution:

The author of the article can't nominate themselves.  They have to be nominated by at least one member of the mailing list.
Please send your nominations to Cameron Arnott.
With the subject line: Best LB mailing list contribution nomination.
In the message state the subject of the message being nominated, the date of the message and the author.

Logo Design Suggestions:

Please send your nominations to Cameron Arnott.
With the subject line: Logo Design Suggestion nomination.
Then attach your graphic to the message.

Best Utility program written in Liberty BASIC:

This section has 3 skill levels so that the playing field is even

Beginner:
Intermediate:
Advanced:

All entries are to be written solely using Liberty BASIC commands (you are only allowed to access the standard Windows DLL's, i.e., no third party DLL's).  No TKN files will be accepted.  You nominate your experience level of programming.
Please send your nominations to Cameron Arnott.
With the subject line: Best Utility program entry.
Then attach your source code to your message.

Best Game written in Liberty BASIC:

This section has 3 skill levels so that the playing field is even

Beginner:
Intermediate:
Advanced:

All entries are to be written solely using Liberty BASIC commands (you are only allowed to access the standard Windows DLL's, i.e., no third party DLL's).  No TKN files will be accepted.  You nominate your experience level of programming.
Please send your nominations to Cameron Arnott.
With the subject line: Best Game entry.
Then attach your source code to your message.

Outstanding contribution to the Liberty BASIC community:

You can't nominate yourself.  You have to be nominated by at least one member of the mailing list.
Please send your nominations to Cameron Arnott.
With the subject line: Outstanding contribution nomination.
In the message state the persons name, email, and their contribution that you think is outstanding.


Spotlight on Fellow Liberty BASIC programmer
Stephen from KiwiSoft
Back to the Top
This month's spotlight is on Stephen.  We all know him as Stephen_NZ or as kiwisoft.
Unfortunately, he hasn't been able to get to a scanner to digetize a photo of himself.  He is 13 years old and has a web page at http://kiwisoft.50megs.com .

Stephen can be contacted on his email address kiwi_soft@hotmail.com  or on the irc.dal.net, chat channel #Liberty BASIC, where he is an assistant operator.
Stephen has had no previous programming experience.  Liberty BASIC was his first programming language, which he has been using now for one and half years.
Stephen says that his level of proficiency in using Liberty BASIC as intermediate.  He took up programming in Liberty BASIC because he wanted to make his own games and applications.  He found Liberty BASIC on the web and the rest is history.
Stephen rates Liberty BASIC 11/10 as a programming language.
His other interests include Tramping (Hiking), Soccer and Rugby

I asked Stephen if there was anything else he'd like to add
Stephen's responce:
Favorite jokes:
New Windows Messages :
"Error reading FAT record! Try the SKINNY one? (Y/N)"
"Your hard drive has been scanned. All stolen software titles have been deleted and the police are on their way."
"This will end your Windows session.  Do you want to play another game?".
"To 'shut down' your system, type 'WIN'".
"Bad or missing mouse! Spank the cat! (Y/N)"
"Windows Virus scan 1.0 - 'Windows found: Remove it? (Y/N)'"
"BREAKFAST.SYS halted...  Cereal port not responding."

How to use INI files in your Liberty BASIC programs
By Stephen - KiwiSoft
Back to the Top

Here is Stephen's article on how to use INI files in your Liberty BASIC code.  In it he shows you how to read and write INI files and has included a sample program.  This is an excellent follow-on from Alyce's version in newsletter issue #66.  LB2Beta* is required for this version as opposed to LB1.42 in newsletter #66.

Thank you Stephen for your contribution to the newsletter.

Ini files are files that consist of 3 things:
Sections eg: [keys], [fonts]
Keywords = Strings eg: up = w, editor = ms_sans_serif 0 16

We can use INI files in just about every program that saves the user's preference's.  INI files are very easy to access from Liberty BASIC, using two simple API calls:
"WritePrivateProfileString" and "GetPrivateProfileString".

Now let's put the calls in functions so they are easy to access.  First we will make the "WritePrivateProfileString" Sub  Note: there is no need to return anything so a Sub is a better option than a Function.  So lets write our Sub:

sub write2ini section$, keyword$, string$, filename$
        section$= section$ +Chr$(0) 'Null terminate all the strings
        keyword$= keyword$+Chr$(0)
        string$= string$+Chr$(0)
        filename$= filename$+Chr$(0)
        calldll #kernel, "WritePrivateProfileString", _ ' make the call
                section$ as ptr, _ ' The section
                keyword$ as ptr, _ 'keyword
                string$ as ptr, _ 'String
                filename$ as ptr, _ 'and the file name for the INI file
        write2ini as word
end sub

Now for the "GetPrivateProfileString" Function:

function readfromini$(section$, keyword$, filename$)
        size = 500 'Size of buffer
        nothing$=chr$(0) ' basically nothing
        string$=space$(size)+chr$(0) 'Make a buffer in the memory
        calldll #kernel, "GetPrivateProfileString", _ ' make the call
                section$ as ptr, _ 'section ie: [fonts]
                keyword$ as ptr, _ 'The keyword for the string to be held
                nothing$ as ptr, _
                string$ as ptr, _ 'The string to receive then contents of the keyword
                size as word, _ 'Size of buffer
                filename$ as ptr, _ 'The INI file to read from
        result as word
        'Get everything except chr$(0)
        string$ = trim$(string$) : readfromini$ = left$(string$,len(string$))
end function

Attached is initest.bas  -- a complete sample program to write and read an INI file.
Note:  Windows automatically makes the INI file if there is no INI present.
If there is no path, then the INI file will be automatically be in the Windows directory.

Interesting Code Snippets posted in LBNews in October: Back to the Top

Here is a selection of code snippets and attachments sent to the mailing lint during the month of October.

Two examples of the new window type "window_popup" requires LB2beta3.
From Alyce,  Email alycewatson@charter.net

WINPOP1.BAS
'winpop1.bas
'popup a secondary window from
'the program window

    WindowWidth=200:WindowHeight=200
    UpperLeftX=10:UpperLeftY=10
    button #1.open, "Open Popup",[openpop],UL,10,10
    button #1.close, "Close Popup",[closepop],UL,10,50
    button #1.exit, "Exit",[quit],UL,10,90
    open "Test" for window as #1

[loop]
    wait

[openpop]
    WindowWidth=298:WindowHeight=198
    UpperLeftX=310:UpperLeftY=110
    statictext #winpop.s, "Alt-F4 Will Close Me!",20,20,298,50
    open "title not displayed" for window_popup as #winpop
    popopen=1
    goto [loop]

[closepop]
    close #winpop
    popopen=0
    goto [loop]

[quit]
    if popopen=1 then close #winpop
        close #1:end
        nomainwin

WINPOP2.BAS
'winpop2.bas
'fullscreen, no titlebar window!
nomainwin
WindowWidth=DisplayWidth
WindowHeight=DisplayHeight
graphicbox #p.g, -1,-1,3000,3000
open "" for window_popup as #p
print #p.g, "down; fill 240 195 30"
print #p.g, "backcolor 240 195 30"
print #p.g, "font arial 40"
print #p.g, "place 100 100;|Alt-F4 Will Close Me!"

wait


Here is an example of how to create and use a floating button that pops up in random places on the screen.  (I had to edit the code to fix 2 print statements that got split in the email)  Hit the escape key to exit
From Mitchell Kotler, Email smartestmanal1ve@netscape.net

FLBUTTON.BAS
'Floating button
'by Mitchell Kotler

'some code stolen from Alyce

nomainwin

UpperLeftX=100
UpperLeftY=100

WindowWidth=100
WindowHeight=50

graphicbox #main.g, -1, -1, 202, 202

open "main" for window_popup as #main
print #main, "trapclose [quit]"

print #main.g, "down; size 2; backcolor lightgray; color white; line 1 1 1 49; line 1 1 99 1; color black; line 1 49 99 49; line 99 1 99 49; place 6 33; font arial bold"
print #main.g, "|Push Me!"
print #main.g, "Flush; when leftButtonDown [mc]; when leftButtonUp [mc2]; when characterInput [cc]; setfocus"

h=hwnd(#main.g)
h2=hwnd(#main)

open "user" for dll as #user
calldll #user, "GetDC",_
h as word,_
hDC as short
close #user

open "gdi" for dll as #gdi
calldll #gdi, "CreateRectRgn",_
0 as short,_
0 as short,_
100 as short,_
50 as short,_
hRegn as short

[wait]

wait

[quit]

close #gdi
close #main
end

[mc]

X=MouseX
Y=MouseY
calldll #gdi, "PtInRegion", _
hRegn as word, _
X as word, _
Y as word, _
inR as word

if inR>0 then
calldll #gdi, "InvertRgn",hDC as short,hRegn as word,r as ushort
beep
butt=1
end if
goto [wait]

[mc2]
if butt = 1 then
butt=0
calldll #gdi, "InvertRgn",hDC as short,hRegn as word,r as ushort
end if

X=int(rnd(1)*(DisplayWidth-1))+1
Y=int(rnd(1)*(DisplayHeight-1))+1

toTop = -1 or 0
flags = _SWP_NOSIZE
open "user.dll" for dll as #user
calldll #user, "SetWindowPos", _
h2 as ushort, _
toTop as short, _
X as short, _
Y as short, _
0 as short, _
0 as short, _
flags as ushort, _
result as void
close #user

goto [wait]

[cc]

if Inkey$=chr$(27) then [quit]
goto [wait]

Another message from Mitchell Kotler contained this code for using windows cursors in Liberty BASIC v2.x

CURSOR.BAS
'Cursor Example by Mitchell Kotler
'How to use LoadCursor and SetCursor to access more Window's Cursors
'Run under LBv2.0

'BEGIN
open "user" for dll as #user

nomainwin

timer 2000, [changeCursor]

statictext #1.s, "", 20, 20, 100, 20

open "Cursor Example" for window as #1

print #1, "trapclose [quit]"

hInstance=0 'Keep this set to zero to use Window cursors

CursorName=32511

goto [changeCursor]

[loop]

scan

'This changes the cursor
calldll #user, "SetCursor",_
hCursor as short,_
result as short

goto [loop]

[quit]

close #user
close #1
end

'This loads the cursor and returns the cursors handle
[loadCursor]
calldll #user, "LoadCursor",_
hInstance As short,_
CursorName As long,_
hCursor As short
Return

'This routine changes which cursor is loaded
[changeCursor]
CursorName=CursorName+1
if CursorName=32517 then CursorName=32640
if CursorName=32647 then CursorName=32648
if CursorName=32663 then CursorName=32512

print #1.s, CursorName

gosub [loadCursor]
goto [loop]