Brosco's LB Resource Centre Newsletter
Issue #1 - April, 1998

This newsletter is best viewed with your Email program Mazimised to 
Full Screen.

Thank you for subscribing to my newsletter - I trust you will find it
informative - if not - the unsubscribe information is at the bottom of
this email.  If you have problems unsubscribing, please send me an
email directly.

The few lines at the top of this newsletter have been inserted by the
Newsletter Service provider.  This is the only SPAM that you will receive
by subscribing to the newsletter.

I will be trying very hard to make this newsletter have content for
everyone, but my main concentration will be for the newer LBers.  I
encourage any newbies to send me suggestions for topics that they
would like to see discussed.  That does not mean that I want you to
send "How do I ..." type questions.  The message board at LB4ALL and
the EMailing List are the places for those types of questions.  I
also encourage the 'older hands' to submit articles that may be of
interest to others.

IN THIS ISSUE:
1)  Resources for getting assistance with LB.
2) "a thunking we will go...", the background story.
3) Snippet of the Month:  Adding new entries to ComoBoxes.

                        ************************************

1)  Resources for getting assistance with LB.

When I first started with LB, I was constantly asking questions, and
the assistance I received from the above  two resources was fantastic.
Sometimes I would get an answer that fixed the problem, but I was
still none-the-wiser about why it worked!!  Thats where this 
newsletter comes in.  Here I have the space and the time to be 
able to explain in a little more detail the WHY behind the answer.  
If you have an area that you don't understand, the chances are that 
others are having the same poblem, so send it in and I will try to 
answer it.  If I can't, I will try to enlist the resources of one 
of the LB gurus to give an explanation.


Message Board vs the Email List. - where should you post your questions?

There are no rules on this and each person has his own preference.  My
personal preference is to use the Message Board for questions and the
Email list for announcements and general discussion.  My reasons are
very simple.  When there is a lot of activity on the Email list, 
people may read your question, but if they can't answer immediately, 
they may never get back to it - it just gets lost in a list of 
archives.  On the message board, not only is the message held there 
for a long period, but the 'threads' of responses are maintained as 
well.  When I am viewing the Message Board, I look first at the 
postings that haven't received an answer at all, then I look at 
the other messages that I haven't read. But, I repeat, this is 
just my personal approach - others may see it differently.

For information on how to SUBSCRIBE to the Email list,
go to Carl's Liberty Basic site:
http://world.std.com/~carlg/basic.html
and click on 'NEWS".  At the bottom of this page you will find the
details for subscribing.

For the Message Board - go to Garrett's LB4ALL site:
http://www.in-syte.com/lb4all/lb4all-b.html
On the left hand side of the page you will see 
his 'Table of Contents'.
Click on 'LB Message Board'.

If you are not currently accessing these two facilities, you are 
missing out on the best sources of LB assistance available.

A third resource is the LB Chat Room.  This is used every few weeks 
for a get together.  Watch for announcements on the Message Board 
for scheduled chat times.  To get directly to the Chat Room, use 
the following URL:
http://www.in-syte.com/lb4all/lbchatrm.html

                       ************************************

2) The big news in April. "a thunking we will go...", the background story.

The ability to access 32 bit API functions from Liberty Basic.  OK, 
I know, its not really a topic for the newbies, but a lot of the 
background information is, so read on!

Windows 3.x is a 16 bit Operating System.  Even though the 386 CPU and
onwards gave 32 bit capabilities, the extra power and facilities 
weren't utilised until the release of Win32 and later, Win95.  
Programs written for the 16 bit enviroment cannot directly access 
32 bit facilities.  Liberty Basic, although it is a programming 
language, is in reality just another program, and is written for 
the 16 bit world.  This means that although LB allows the 
programmer to issue API calls - they can only be of the 16 bit 
variety.  The fact that you may be running Windows 95 does NOT 
change anything.

As soon as LB was given the ability to make API calls, several 
programmers started experimenting.  Regularly, there would be a 
question posted like: "Hey, I found this great new API function 
that does .........., but when I try to use it in LB, the system 
crashes! Why?" And the answer usally came back:
"Thats a 32 bit Function - you can't access that one from LB".

Then early in April, Garrett posted a very stupid question:
"Other 16 bit programs access 32 bit facilities, via a method called
'THUNKING', why can't LB do this?".
Within an hour or two, Brian Pugh sent Tom Record a DLL that enabled
'thunking' (Brian has troubles with uploads with his ISP).  Tom posted
the DLL on his site immediately so that it was available for everyone
to download.  I quickly grabbed this and wrote a small sample program
in LB that accessed the 32 bit functions and posted the program to the
Message Board.  Over a period of 12 hours, we went from:
                'thats impossible'
                       to
     'oh that - just use the Call32.dll - ho-hum.'

Call32.dll was written for the Visual Basic programming community by
Peter Golde and posted as FREEWARE.  Thank you Peter.
(Peter has been sent a copy of this Newsletter).

The moral of the story is: "There is no such thing as a stupid 
question"  - so dont be shy with your questions, no one will 
laugh at you - and perhaps your question might just lead us to 
yet another discovery!

                ************************************

3) Snippet of the Month

Have you ever noticed that some professional programs have ComboBoxes
that allow the user to add extra entries by typing into the ComboBox
itself!  Here's my code to allow you to do this:

' ComboBox data entry - writen by Brosco, April 1998
'
    nomainwin
    dim Fonts$(100)
    Fonts$(1) = "Arial"
    Fonts$(2) = "Courier"
    Fonts$(3) = "Courier_New"
    Fonts$(4) = "System"
    numF = 4

    WindowWidth = 170
    WindowHeight = 160

    StaticText #w.t1, "Select a Font, or Type one in to Register it", _
                      10, 10, 125, 50          ' *** Note 1

    TextBox #w.f, 10, 65, 125, 24              ' *** Note 2
    ComboBox #w.fs, Fonts$(, [fontClick], 10, 65, 145, 120

    Button #w.default, "OK", [okClick], UL, 25, 95, 50, 25 ' *** Note 3
    Button #w.quit, "Close", [close.w], UL, 85, 95, 50, 25

    open "Font Selection / Register" for Dialog as #w
    print #w, "trapclose [close.w]"
    print #w.fs, "selectindex 1"
    print #w.f, Fonts$(1)

[loop]
    input var$
    goto [loop]

[fontClick]                                       ' Note 4
    print #w.fs, "selectionindex?"
    input #w.fs, i
    a$ = Fonts$(i)
    print #w.f, a$
    goto [loop]

[okClick]                                         ' Note 5
    print #w.f, "!contents?"
    input #w.f, a$
' See if the new font already exists
    print #w.fs, "select ";a$
    print #w.fs, "selectionindex?"
    input #w.fs, i
    if i > 0 then
        notice "This Font is already registered!"
        goto [loop]
        end if
    numF = numF + 1
    Fonts$(numF) = a$
    sort Fonts$(, 1, numF
    print #w.fs, "reload"
    notice "New Font has been added!"
    goto [loop]

[close.w]
    close #w
    END
' end of program snippet ***************************

NOTES about this code.

1) Notice that when you run this program that the StaticText 
   automatically wordwraps over 3 lines.

 StaticText #w.t1, "Select a Font, or Type one in to Register it", _
                       10, 10, 125, 50

2) The Textbox is positioned so that it neatly covers all of the 
   ComboBox except for the 'expand button'.
   With Dialog windows, contols are placed on the screen in the 
   reverse order to that specified.
   If you use this technique in another type of window, reverse the
   order of TextBox and ComboBox

    TextBox #w.f, 10, 65, 125, 24
    ComboBox #w.fs, Fonts$(, [fontClick], 10, 65, 145, 120

3) By giving the OK button a name of Default, windows will 'pass 
   contol' to [okClick] code if the user presses 'Enter' after 
   entering a new name.  (This only works for Diaglog windows).

    Button #w.default, "OK", [okClick], UL, 25, 95, 50, 25

4) The [fontClick] code.  "selectionindex?" is used to see which 
   font has been selected. That entry is then printed to the 
   TextBox so that the user can see it.

5) The  [okClick] code. First we use the "!contents?" command to 
   retrieve what the user typed in.
   Next we use the "select " command to see if this entry is already 
   in the array.  We could have just searched our Fonts$ array, but 
   this is easier!
   If the font name is already in the array - it is ignored.
   If not - we add it to the array, sort the array and then "reload" it.

                         ************************************

Newsletter written by: Brosco.
Comments, requests or corrections to: brosco@orac.net.au

Translated from Australian to English by an American:
Alyce Watson.  Thanks Alyce.
