The Liberty Basic Newsletter - Issue #86
© 1st February 2001 Cameron Arnott
All Rights Reserved

Click here if you have to scroll left to right to read the newsletter

In this issue:

Attachments:

Proposed For Future Issues:

  • More Spotlights on Fellow Liberty BASIC programmers
  • Open Source Editor V17 - Adding runtime engine for LB2 w/command line
  • USING CommandLine$ WITH TOKENIZED FILES
                                             AND
    USING CommandLine$ IN THE OPEN SOURCE EDITOR
  • More Interesting Snippets from the LBNews Mailing list

Letter from the editor:

Back to the Top

Wow another month past already?  I can't believe it.  Time has flown so fast, too fast for me.  Well fellow programmers you only have 5 months to go to get all your entries and nominations in for the "2001 A Liberty BASIC Odyssey."  I hope you are all well on the way to programming and designing winners.  If you've forgotten or want to go over the rules again, they can be obtained from the Liberty BASIC Community Web site.  Please remember to send ALL entries and nominations to <bluesteel@gamebox net>.  Any entries uploaded directly to the files download area at 2001, A Liberty BASIC Odyssey (which is where ALL entries will be available for download so that you can know what your voting for) will NOT be a legal entry, thus not eligible to receive votes in the poll starting the July 1 2001.  You have all been warned -- no exceptions.

This has been a huge month for LBNews.  Not only has it moved from e-groups to yahoogroups and maintained over one thousand messages per month over the last four months, our membership now stands at 260 members.   If you haven't already done so, please take the time to answer the poll as to your experience level using Liberty Basic on the LBNews Polls so that I can try to balance the newsletter content.  So far only 31 programmers have filled in the poll.

There have been so many great snippets in the mailing list this month, I had an extremely difficult task trying to select just a few to place in the newsletter.  If you see or learn something new in Liberty BASIC, or even see a question that you think is worth a good detailed answer, please consider writing and article for the newsletter.  No matter how small or large, I can assure you that your contribution will be well received by the community.  To submit an article, send it to <bluesteel@gamebox net>.

Fellow programmers, it give me great pleasure to tell you all that the newsletter has found a new home at my ISP's <http://www.ecn.net.au> web hosting site.  Remember, to make sure you can always find it, use <http://lbn.cjb.net>.  It will always take you right to the current location of the newsletter.


Happy Programming,
Cameron Arnott

Spotlight on David Drake:

Back to the Top

This month's spotlight is on David Drake of Birmingham, Alabama, USA.  David is 32 years old, He has a web page at <http://www.foundrysearch.com> and his Email address's <ddrake@acipco.com> or <drake@apexmail.com>.  David's article follows:

I began programming in the 1980's with a TRS-80 Color Computer and Color BASIC.  Later came Microsoft BASICs, fortran, HTML and Liberty BASIC.

I have been happily cranking out Liberty BASIC code since 1997.  At one time I felt like one of the "experts," but the appearance of several new and quite talented young programmers in the family have forced me to re-think my experience level...  I suppose you could call me a "highly experienced beginner."

My work requires the occasional creation of small custom programs for reading data, doing recursive calculations, simulating industrial processes and so forth.  I used to code in FORTRAN, but the discovery of Liberty BASIC allowed me to create Windows-based versions of my programs in half the time.  Simply amazing!

Liberty BASIC, in my humble opinion, is the single easiest tool for quickly creating powerful Windows-based applications.  Users go through a shallow learning curve , so LB is suitable for even the least experienced beginner.  The best feature of Liberty BASIC comes free: the Liberty BASIC family!  Any programmer would kill to have the support group that we have.

My other interests include: My wife of ten years, my daughter (7) and son (4).  I also teach a first-grade Sunday School class and the second-grade choir at my church, as well as maintain the church's web site <http://www.fbcpelham.com>.  (Warning: Uncalled-for advertisement ahead): During the day I am a metallurgical engineer at American Cast Iron Pipe Company, producer of the world's finest ductile iron pressure pipe <http://www.acipco.com>.

My life has for years been centered around my church and my faith.  I teach children about God, and there is no higher calling.  Even though the LB group usually refrains from religious discussions, I don't believe that there's any harm in understanding a bit about why a body thinks the way he does.

Programming is also important to me.  My loving and tolerant wife has asked me why I like to spend up to two hours each morning writing code.  The only reply I can come up with is: "Some people see images in their mind and create oil paintings.  Some are inspired by Scripture and create moving musical compositions.  I get an idea in my head and write bad code."

In all seriousness, I suppose that programming really is a creative outlet for many people.  So the next time you are asked, "What's all that gibberish on the screen?," just tell them, "Why, it's the Mona Lisa."

As long as I have the floor, I'd like to pass out a few kudos:

  • To Brosco (alias Cliff Bros), who no longer haunts these halls, for his instrumental role in founding the Liberty BASIC community.
  • To Carl Gundel, for a first-class product.
  • To Doyle Whisenant, for unlocking for me the mysteries of API calls.
  • To Cameron Arnott, for taking on the unenviable task of creating this newsletter.
  • And to Alyce Watson, for the immeasurable help she has given to me and everyone else over the past few years.


What's New in Freeform for Liberty BASIC 2:
by David Drake
ddrake@acipco.com
January 7, 2001

Back to the Top

  • LB 2.0 added some new window types. Freeform now supports window_popup and dialog_popup window types.
  • LB 2.0 now supports the system default color "buttonface." This has been added to Freeform.
  • Users may now specify foreground and background colors for windows. Freeform supports this change.
  • Some ctrl-key menu shortcuts have been added:

ctrl+N New form

ctrl+S Save form

ctrl+O Open form

ctrl+c Copy selected control

  • Freeform now allows ctrl+C or right-click popup menu to copy a selected control.
  • Users may now relocate selected control with arrow keys.
  • Right-click popups are now context-sensitive (select control first!).
  • Menu redesigned to reflect new functions.
  • Places option in Settings menu to make tooltips "always on." If you are running Windows NT, Freeform will CRASH is tooltips are made active.
  • Win9x layout is now the default setting.
  • The size of a bitmap is now reflected in the form window (handles are in the right place).
  • LB 2.0 automatically adds an EDIT menu to a window in which a texteditor is placed. Freeform now automatically adds that menu to the form if it is not already present.
  • "Produce Code+Outline" action now produces complete stand-alone code, including an appropriate "trapclose" command.
  • Freeform allows the user to specify an initial window location (UpperLeftX and UpperLeftY).
  • The window size may be typed in as a property now.
  • Freeform now has a window properties box. Double-click on the form window. It looks pretty bad, however.
  • LB 2.0 now allows colors for some controls. Freeform now allows the user to specify colors for Combobox, Listbox, Textbox and Texteditor and reflects those changes in the Freeform display
  • Adds ability to place visible snap grid on form (dragging controls won't line up with grid, however)
  • Freeform now orders object front-to-back on the screen as they appear in the generated window (graphicboxes on bottom, texteditors next, groupboxes next, then all other controls in order of creation)
  • The user may now execute form code straight from Freeform (bypass copy and paste).
  • Added ability to specify default bitmap path in Settings menu.
  • Added trap that displays graphic-type windows without background and foreground color support.

 

Known Issues

  • When dragging a control, the control will not line up with the visible grid. I sure wish someone would fix this!
  • The new window properties box looks bad.
  • Freeform could really use a new controls properties box.
  • The window resizing handle is offset after adding a menu. I sure wish someone would fix this.

Freeform - Quickstart:
by David Drake
ddrake@acipco.com
January 7, 2001

Back to the Top

What is a graphical user interface (GUI)?

A Graphical User Interface (GUI) is simply images and words on the screen that allow users to interact with a computer program. In Liberty BASIC, a GUI is made up of a window (or windows) and a set of controls associated with that window.

Controls include text, clickable buttons, boxes into which one can type text, lists from which a user can pick a choice, check boxes and radio buttons which allow users another way to select from among choices, and boxes that group related controls together.

What is a visual GUI developer?

Visual GUI developers help the programmer create graphical user interface forms in a "what-you-see-is-what-you-get" manner. Forms are the windows that allow users to interact with programs.

What is Freeform?

Freeform is the free GUI developer distributed with Liberty BASIC. With Freeform, one can easily manipulate the appearance of windows and the controls on the windows, then automatically generate code to paste into a Liberty BASIC application.

The Freeform Main Screen

The Menu Bar

The Menu Bar is at the top of the Freeform main screen. You may access most of Freeform's actions by clicking on the drop-down menus.

File: New, Open, Save, Quit

Edit: Copy, Delete

Control: Properties, Move to Front, Move to Back, Set Box Colors

Menu: Add a Menu, Remove a Menu, Edit Menus

Window: Title, Type, Handle, Initial Location, Size, Background Color, Foreground Color, Font for Controls

Output: Produce Code, Produce Code+Outline, Test Code

Options: Auto Snap to Grid, Settings, Set BMP Path

The Toolbox

The Toolbox is the panel of buttons on the left side of the Freeform main screen. These 20 buttons provide shortcuts to most Freeform actions.

  Open a saved form file

  Save the current form

  Add a statictext control

  Add a text box control

  Add a clickable text button

  Add a clickable bitmap button

  Add a listbox

  Add a combobox

  Add a radiobutton

  Add a checkbox

  Add a groupbox

  Add a texteditor

  Add a graphicbox

  Choose the fill color for the control or window

  Open the properties box for currently selected control

  Delete currently selected control

  Move selected control to front

  Move selected control to back

  Produce code

  Produce code and outline

The Form Window

The Form Window is the window-like image to the right of the Toolbox. The Form Window is Freeform's representation of what your window looks like. Most of your pointing and clicking will occur within the Form Window.

Quick Start: Make a Simple Window

This section is intended for the beginning beginner. Work through this step-by-step guide to create, manipulate, save a form. The reader will learn how to produce and use the Liberty BASIC code generated by Freeform.

1. Start Liberty BASIC.

2. Select RUN and TKN from the Liberty BASIC menu.

3. Select FFRM2025.TKN (or whatever is the most recent release) from files in the LB20W directory to run Freeform. The default Freeform main screen is displayed.

4. Click on the STATICTEXT button in the toolbox . A prompt box will open requesting that the user type in the text to be displayed. Type in "Hello World" and press ENTER.

5. The Controls Properties box will appear. We'll address this later. Click on CANCEL to continue.

6. The text will appear in the upper left-hand corner of the form window.

7. Select OUTPUT and TEST CODE from the form menu. A file dialog window will open asking you to locate LIBERTY.EXE.

Find the directory in which liberty.exe is located (typically C:\LB20W) and click on OK. In a few seconds, a window entitled "untitled" will appear with the text "Hello World" in the upper left-hand corner.

Congratuations! You've created a fine window with Liberty BASIC.

8. Close the "untitled" window that just appeared.

9. Save the form you've created. Click on the "save" icon or select FILE and SAVE from the Freeform menu. Type in "myfirst.fr2" and the filename.

10. Now we'll manipulate the statictext control you created. Place the mouse pointer over the control and click the left mouse button once. You have selected the control. "Hello World" will be framed by four small squares.

These show the dimensions of the control.

11. Place the mouse pointer over the approximate middle of the "Hello World" control and click and hold the left mouse button. While holding down the left mouse button, move the mouse pointer around within the form window (called dragging). Notice that a rectangle follows the mouse. Release the left mouse button and the "Hello World" control has been dragged to its new location.

Congratulations! You've just moved a windows control.

12. Create a button-type control by clicking on the BUTTON button in the toolbox. Type in "Hello Button" into the prompt box that appears and click OK, then CANCEL the Controls Properties box.

13. Select the "Hello Button" control. The large square in the lower right-hand corner of the control is the resizing handle.

14. Place the mouse pointer over the resizing handle, then press and HOLD the left mouse button. You have grabbed the resizing handle. Drag the resizing handle down and to the right. Notice that a box appears around the "Hello World" control and will grow as you move the mouse. Release the left mouse button.

Congratulations! You have just resized a control.

15. Let's edit a control. Place the mouse over the "Hello Button" control and double-click. The Control Properties box will appear (image). In this window you can type in each property for the control. These properties are explained in detail in the "Controls" section of the tutorial.

16. For now, we'll just relocate the button. Click on the text box next to "x-org" and type in 50. Now do the same for the "y-org" box. Click on ACCEPT. The "Hello Button" control moves to its new location.

17. Add a menu. Click on MENU and ADD A MENU from the Freeform window.

18. In the Add a Menu window that popped up, type in "File" (without the quotes) under "Enter New Menu Name." Click ACCEPT.

Congratulations! You have just added a menu.

19. (Fix menu bugs before moving ahead) A menu is no good without menu items to select. Select MENU and EDIT MENUS from the Freeform menu. The Edit Menus dialog appears.

Select File from the available menus (should only be one) and then click NEW ITEM. Next to Name type in "Save" (without the quotes) and next to Branch Label type in "[save]" (without quotes, with brackets). (To learn more about branch labels, refer to the Liberty BASIC help files.) Click on ACCEPT. Notice that the Save menu item now appears in the Menu Line Items window. Add another menu item named "Open" with the branch label "[open]". Wait, you didn't want to do that. Well, you can delete the "Open" item from the list by selecting "Open" from the menu item list and click DELETE. Click CLOSE to save all menu changes.

20. Let's change the window a bit. Every window needs a title. Select the window (click where there is no control) then press the right mouse button. A popup menu with many choices will appear. The first choice is TITLE. Select TITLE, type "Hello Title" into the prompt box and press ENTER. The window's title changes.

21. Let's say that you do not want the user to be able to resize the window. That is a window without frames. Select WINDOW and TYPE from the Freeform menu. Select "window_nf" from the dropdown box in the "Select Window Type" window and click on ACCEPT. Notice that the resizing frame that was around the form window disappears.

22. Save the form and test the code (see 9).

23. Freeform's job is to produce code for you to use in a program. Select OUTPUT and PRODUCE CODE+OUTLINE from the Freeform menu. The code is displayed in the Freeform Output Window. Your code should look like this, give or take a few numbers:

nomainwin

WindowWidth = 550

WindowHeight = 410

BackgroundColor$ = "buttonface"

ForegroundColor$ = "black"

ComboboxColor$ = "white"

ListboxColor$ = "white"

TextboxColor$ = "white"

TexteditorColor$ = "white"

statictext #main.statictext1, "Hello World", 358, 286, 88, 20

button #main.button2, "Hello Button", [button2Click], UL, 50, 50, 240, 150

menu #main, "File", "Save", [save]

open "Hello Title" for window_nf as #main

print #main, "font ms_sans_serif 0 16"

print #main, "trapclose [quit]"

 

[main.inputLoop] 'wait here for input event

wait

goto [main.inputLoop]

 

 

[button2Click] 'Perform action for the button named 'button2'

'Insert your own code here

goto [main.inputLoop]

 

[save] 'Perform action for menu File, item Save

'Insert your own code here

[quit]

close #main

end

The code you create is automatically copied into the Windows clipboard. To use it, simply paste the contents of the clipboard into the Liberty BASIC editor and run it. LB will produce a window that looks something like this, depending on where you moved the "Hello World" and "Hello Button" controls:


A Liberty BASIC Form Primer:
by David Drake
ddrake@acipco.com
January 7, 2001

Back to the Top

Elements of a form

Window: The window is the rectangular box that contains controls, menus, images, etc.

Controls: Controls are objects in the window that the program uses to interact with the user. Controls include text, buttons, input boxes, and more.

Menus: Menus are controls that appear at the top of a window below the title bar (if the window has a title bar). The user interacts with the window by clicking on the menu items.

 

Windows

Types of Windows

Types of Windows in Freeform (there are more, you know)

window plain window

window_nf plain window without a resizing frame

window_popup plain window without resizing frame or titlebar

dialog supports tabbing between controls; does not support menus; cannot be minimized

dialog_nf dialog window without a resizing frame

dialog_modal dialog window that must be closed before control is returned to program

dialog_nf_modal modal dialog box without a resizing frame

dialog_popup dialog box without a titlebar

graphics plain window that supports direct graphics commands

graphics_nsb graphics window without scroll bars

graphics_nsb_nf graphics window without scroll bars or a resizing frame

Properties of Windows

Handle: The window handle is a name beginning with "#" such as "#main" or "#program." The handle is the name your program uses to interact with the window you create. For example, all controls have handles as well, and the handles are the name of the window plus an extention. For example, a button in a window named "#main" could have the handle "#main.button1."

Title: The title is the text that appears in the bar at the top of the window and in the taskbar. "Window_popup"-types do not have titlebars but can have titles.

Size: This is the pixel-size of the window.

Initial Location: This is the location on the screen that you want the window to appear when it is created. For example, you may want a window that pops up with a message to appear centered in the screen.

Background Color: This is the color that fills the window.

Foreground Color: This is the color of text that is written to the window.

Font: This is the font used to write text to the window.

 

Controls

Properties of Controls

X-Origin: Horizontal pixel location within the window of upper-left-hand corner of the control

Y-Origin: Vertical pixel location within the window of upper-left-hand corner of the control

Width: Width in pixels of control

Height: Height in pixels of control

Caption: Vivible text label associated with the control (if applicable)

Branchlabel: Location that program branches to when control is selected (if applicable)

Extension: Word/letter combination that is added to the window handle and identifies the control

Array: Arrayed variable that contains a list of items displayed in the control (if applicable)

Bitmap file specification: Name and location of bitmap file for button (bitmap buttons only)

Other properties assumed by Freeform:

Corner: Freeform always assumes Upper Left (UL) for the corner property.

Types of Controls

Bitmap Button

Description: A button made from a bitmap file. The bitmap may be any size. When the user clicks on the bitmap button, the program execution branches to [branchlabel].

Properties: x-org, y-org, bmp filespec, extension, [branchlabel].

Button

Description: A button on the window. When the user clicks on the button, the program execution branches to [branchlabel].

Properties: x-org, y-org, width, height, label, extension, [branchlabel]

Checkbox

Description: A checkbox on the window. When the user clicks on the checkbox, the checkmark in the control appears or disappears, and control branches to the appropriate branchlabel. When the checkbox is set (checkmark appears), control branches to [setbranchlabel]. When the checkbox is reset (checkmark disappears), control branches to [resetbranchlabel].

Properties: x-org, y-org, width, height, label, extension, [set branchlabel], [reset branchlabel]

Combobox

Description: Control that places a set of choices, contained in an array, in a scrollable dropdown box. Control is passed to [branchlabel] when the user makes a selection within the combobox.

Properties: x-org, y-org, width, height, extension, branchlabel, array

Graphicbox

Description: A rectangular control in the window that will receive graphics commands. Also, events like mouse movements, mouse clicks and keystrokes may be trapped in a graphic box.

Properties: x-org, y-org, width, height, extension

Groupbox

Description: This is a box drawn within the window. This box groups together any controls that fall within it. This is useful mostly with radio buttons. If you want several sets of radio buttons (i.e. Two buttons for selecting color, two for selecting size) you don't want the user to click on "green" and have "extra-large" reset. Placing a groupbox around the color radiobuttons and another around the size radiobuttons takes care of this.

Properties: x-org, y-org, width, height, extension, label

Listbox

Description: Control that places a set of choices, contained in an array, in a scrollable box. Control is passed to [branchlabel] when the user makes a selection within the listbox.

Properties: x-org, y-org, width, height, extension, branchlabel, array

Radiobutton

Description: A radio button on the window. When the user clicks on the radio button, the dot in the control disappears or appears and control branches to the [setbranchlabel]. When a different radio button is clicked, then this radio button is reset. The [resetbranchlabel] is required in the syntax but does nothing.

Properties: x-org, y-org, width, height, label, extension, set branchlabel, reset branchlabel

Statictext

Description: Text in the window.

Properties: x-org, y-org, width, height, label, extension

Textbox

Description: A control into which a user can type text and numbers.

Properties: x-org, y-org, width, height, extension

Texteditor

Description: A control into which a user can type text and numbers. This control is more advanced than the textbox because it has scroll bars and more features like a right-click popup edit menu and an automatic edit menu with typical editing commands.

Properties: x-org, y-org, width, height, extension


Interesting messages posted in LBNews in January:

Back to the Top

What is MDI:

Back to the Top

From: A. Watson [mailto:alycewatson@bigfoot.com]
Sent: Friday, 19 January 2001 12:04 AM
To: lbnews@egroups.com
Subject: Re: [lbnews] Re: [MDI]
At 07:58 AM 1/18/01 -0600, you wrote:
>Ok, now that we have it working and I can see what it is
>supposed to do.  Someone please tell me what 'MDI' stands for.
>    Ken

Multiple Document Interface.  Programs like MS Word and
PaintShopPro allow you to have multiple files and muliple window
types open at one time.  These MDI child windows remain within
the client area of the parent form.

Alyce


MDI in Liberty BASIC V2.01:

Back to the Top

From: Mitchell Kotler [smartestmanal1ve@netscape.net]
Sent: Thursday, 18 January 2001 6:21 AM
To: lbnews@egroups.com
Subject: [lbnews] Re: [MDI]
You mean you want to be able to type in the texteditor?!?!?!
You people want so much from me ;-) j/k

Seriously now, no i failed to notice this.  However im not giving
up.  here is the code that does work. (I hope).

'MDI.bas
'How to do MDI in LB
'(this time for real)
'
'By Mitchell Kotler

nomainwin

open "user" for dll as #user

WindowWidth=350
WindowHeight=350

menu #main, "File", "New MDI Window", [new.window],_
                    "New MDI Text Window",
[new.text]
open "MDI in LB" for window as #main
print #main, "trapclose [quit]"
print #main, "resizehandler [resize]"

hMain=hwnd(#main)

Type = _GWW_HINSTANCE OR 0

calldll #user, "GetWindowWord",_
hMain as word,_'handle of window that will contain controls
Type as short,_'flag for word value desired=instance handle
hInstance as word'instance handle of window is returned

dwStyle=_WS_CLIPCHILDREN OR _WS_CHILD OR _WS_VISIBLE OR _
        _WS_BORDER

calldll #user, "CreateWindow",_
        "MDICLIENT" as ptr,_ 'class name
        "" as ptr,_ 'title or string
        dwStyle as long,_ 'window style
        2 as short,_'x org
        2 as short,_ 'y org
        339 as short,_ 'width
        302 as short,_'height
        hMain as short,_ 'parent window
        0 as short,_ 'handle to menu = 0 for class menu
        hInstance as short,_ 'instance handle of parent window
        "" as ptr,_ 'always NULL
        hMDI as word'returns handle of this control

[wait]
wait

[new.window]

if child then [wait]

open "MDI CHILD WINDOW" for window as #child
print #child, "trapclose [close.child]"

hChild=hwnd(#child)

'new code here: set style to child and off of popup
Type=_GWL_STYLE or 0

calldll #user, "GetWindowLong",_
hChild as short,_
Type as short,_
style as long

style=style or _WS_CHILD
style=style xor _WS_POPUP

calldll #user, "SetWindowLong",_
hChild as short,_
Type as short,_
style as long,_
result as long


calldll #user, "SetParent",_
hChild as short,_
hMDI as short,_
result as short

flags=_SWP_NOSIZE or _SWP_NOZORDER
calldll #user, "SetWindowPos",_
hChild as short,_
0 as short,_
5 as short,_ 'x
5 as short,_'y
0 as short,_
0 as short,_
flags as short,_
result as short

child=1

goto [wait]

[close.child]
child=0
close #child
goto [wait]

[new.text]

if text then [wait]

open "MDI CHILD WINDOW" for text as #text
print #text, "!trapclose [close.text]"

hText=hwnd(#text)

calldll #user, "GetParent",_
hText as short,_
hTextPar as short

Type=_GWL_STYLE or 0

calldll #user, "GetWindowLong",_
hTextPar as short,_
Type as short,_
style as long

style=style or _WS_CHILD
style=style xor _WS_POPUP

calldll #user, "SetWindowLong",_
hTextPar as short,_
Type as short,_
style as long,_
result as long

calldll #user, "SetParent",_
hTextPar as short,_
hMDI as short,_
result as short

flags=_SWP_NOSIZE or _SWP_NOZORDER
calldll #user, "SetWindowPos",_
hTextPar as short,_
0 as short,_
5 as short,_ 'x
5 as short,_'y
0 as short,_
0 as short,_
flags as short,_
result as short

text=1

goto [wait]

[close.text]
text=0
close #text
goto [wait]

[resize]

h=WindowHeight-3
w=WindowWidth-3

flags=_SWP_NOMOVE or _SWP_NOZORDER
calldll #user, "SetWindowPos",_
hMDI as short,_
0 as short,_
0 as short,_
0 as short,_
w as short,_'width
h as short,_'height
flags as short,_
result as short

goto [wait]

[quit]
if text then close #text
if child then close #child
close #main
close #user
end


The key to fixing it is that it cant have both WS_CHILD and
WS_POPUP style at the same time, so i took the WS_POPUP
style off.

-Mitchell


>From: Doyle Whisenant <mechanic@sonet.net>
>Subject: Re: MDI
>
>Mitchell Kotler wrote:
> 
> You got it right with this Brent!
> 
>
>Mitchell did you notice when the windows lose the focus you
>can't click on the window and regain it? You lose the ability
>to type into the edit window because of this!
>
>Ooops!
>
>-- 
>Doyle Whisenant
>mechanic@sonet.net
>http://mechanic.webjump.com

For your convience a copy of MDI.BAS has been attached to this newsletter.


Getting the Length of a Struct:

Back to the Top

From: lbgui@aol.com
Sent: Tuesday, 30 January 2001 3:30 PM
To: lbnews@yahoogroups.com
Subject: [lbnews] Re: STRUCT
Hi Ken,

I'm not sure if it's documented, but LEN() works on STRUCTs as
well as strings. See the example.

----------------------------------------

Struct Point, x As short, y As short
Print Len(Point.struct)

----------------------------------------
4

Brent

http://members.aol.com/b6sw

--- In lbnews@y..., "Ken Lewis, Sr." <kenlewissr@s...> wrote:
> Hi all;
> I Need to determine the amount of memory that a  'STRUCT' 
> takes up for a project I have adopted. Aside from counting
> the variables by type and adding all the bytes up,
> (there must be a million or so in this struct <G>),
> is there another way???  Maybe something like 
> sizeof(struct.point).  I think adding them up is probably the
> only way. But I am sure that many of you know
> quite a bit (byte?) more than I do.
> 
> As always any help will be greatly appreciated
> 
> Thanks;
>         Ken


Getting around "Create Pen" bug in LB 2.01:

Back to the Top

From: andrew@binniea.freeserve.co.uk
Sent: Tuesday, 9 January 2001 9:59 AM
To: lbnews@egroups.com
Subject: [lbnews] Re: bugs in LB2.01
You would be best of using the set pixel api call:

callDll #gdi, "SetPixel",_
hDC as word,_    'handle of graphic box or window
x as word,_      'x co-ordinate
y as word,_      'y co-ordinate
rgbcol as long,_ '24bit colour (rgbcol=
                 '(blue*65536)+(green*256)+red)
result as long   'actual colour used



--- In lbnews@egroups.com, carlg@w... wrote:
> Alyce is right about this. I will try to fix this in LBv2.02.
> Are you using the color command to paint a palette of colors
> for a color chooser?  You might consider loading an image of
> a palette from a bitmap until I can fix this.
> 
> -Carl
> 
> --- In lbnews@egroups.com, "Cameron Arnott" wrote:
> > Is there any way around it... ?
> > 
> > 
> > Cameron Arnott
> > http://lbn.cjb.net/index.htm
> > bluesteel@G...
> > blue_steel@G...
> > cameron@B...
> > 
> > > -----Original Message-----
> > > From: A. Watson [mailto:alycewatson@b...]
> > > Sent: Monday, 8 January 2001 9:08 PM
> > > To: lbnews@egroups.com
> > > Subject: Re: [lbnews] bugs in LB2.01
> > > 
> > > 
> > > At 04:22 PM 1/8/01 +1000, you wrote:
> > > >2 "cant create pen error"
> > > >
> > > >this error seems to pop up more frequently the less free
> > > memory i have on my
> > > >system
> > > 
> > > Some of us noted and reported this bug a long time ago.
> > > When you change the "color" in a graphics command, you
> > > are using the GDI function "CreatePen".
> > > Perhaps old pens are not destroyed when new ones are
> > > created,
> > > causing the loss of memory.  Only Carl can answer that
> > >  one.  Making a bunch of "color" commands causes this
> > >  error.  Perhaps Carl can fix it for a future version.
> > > 
> > > alycewatson@c...
> > > alycewatson@e...
> > > alycewatson@b...


Writing code that works:

Back to the Top

From: Rory Davis [n7cr@bellsouth.net]
Sent: Friday, 12 January 2001 9:07 AM
To: lbnews@egroups.com
Subject: [lbnews] Writing code that works (was: Encryption and
sequential files)

---- Snipped from message as this is the Subject matter

I have to warn you,  I'm not here to give you a quick answer.
You'll either curse me or thank me later. But this is how I work.

Instead of fixing your code for you, I'm going to show you how to
find the bug and fix it yourself and offer a couple of
suggestions and hints on how to catch your bugs before you
compile.

Suggestion #1.
Always keep in mind that the compiler will not catch every
mistake you make.  Even if the compile is successful, it still
doesn't mean that your code is correct. Try not to get in the
habit of bashing out code, then letting the compiler catch your
syntax errors. Strive to eliminate bugs BEFORE you hit the
compile button.  Make it a matter of pride to produce smooth
compiles without error messages.

Suggestion #2:
Follow Carl's advice in the tutorial and COMMENT LIBERALLY
even if you'll be the only one reading the program. Commenting
may take time at the keyboard, but it doesn't affect execution
speed. What it does do is allow you as the programmer to define
your concepts more clearly than from the code alone.
And remember, you may come back to this program weeks, months or
even years from now and by then you'll have forgotten what
exactly you were doing.

I write my programs in short functional snippets, while the idea
is fresh in my mind. After hours of cogitation, sudden bursts of
frenzied coding. I then go back and comment each major operation
of that snippet.  That doesn't mean EVERY line of code, usually
it means when a variable is changed, an I/O operation or other
action that isn't obvious from the code itself. Not only am I
commenting, I'm proofreading my syntax, looking for missing
parenthesis, etc.

It helps me catch typing errors. It also forces me to examine
exactly what I'm doing as far as the actions I'm taking at the
time. Often, I'll realize (while I'm commenting) that the snippet
isn't doing exactly what I want it to do because the comments
stop making sense. It's like writing a story.  You can get as
detailed as you want. The object of commenting is to make sure
you understand every function of code as you're writing it. Just
remember to write the comments clearly enough so you can
understand what you said when you read it in the future.

And if I'm not in a real hurry, I'll include a synopsis of the
snippet at the beginning of the code, and tell myself in words
exactly what I'm trying to do.  That way, if I have to stop
coding before the snippet is done I can come back and see what I
need to do next.

Suggestion #3:
Structure your code. Use indentations inside of for/next and goto
loops, inside of if/then/else branches, etc. The tutorial has a
lot of good information on that subject.  Hitting the tab key
takes no time at all, and clean code is a lot easier to debug
than when it all starts at column 1. And it's absolutely
necessary when doing nested loops and if/then/else statements.
Put blank lines before every branch [label].

Suggestion #4.
Use descriptive labels, handles and variable names. Take this
statement:

open filename$ for input as #1        'This means I have to keep
                                      'track of what #1 is.

A better way to do it is to use this statement:

open filename$ for input as #clearfileIN
open encrypted$ for output as #cryptfileOUT

'description is up to you.

Suggestion #5.
When trying out a new concept, eliminate everything except for
the bare essentials. Ask yourself, (I do this all the time)
"What is it that I'm trying to do here? What is the barest
minimum code that it will take to accomplish what I want?  Do I
really need to have this function in order to accomplish the
task?"

If I don't understand a concept, or if I'm testing a new
algorhythm, I eliminate everything else and concentrate on just
the part that I don't understand or that doesn't work. I don't
use cursor changes, timers, dialog I/O boxes or anything else. If
possible, I use the minimum of user I/O to test the function.
All the extra stuff can be added once I get the concept to work.
The object is to make the concept work. All else is icing on the
cake. I understand that your primary concern of the crypto
routine was speed. My primary concern is that the encryption
works for you. There are ways to make it go faster. But first,
get it to work.

-------------Rest of message cut out as it dealt with the actual
             problem not suggestions on how to program
			 


New GUI development tool:

Back to the Top

From: ddrake@acipco.com
Sent: Friday, 19 January 2001 6:47 AM
To: lbnews@egroups.com
Subject: [lbnews] New GUI development tool available
Hello all.

I've uploaded a new program package to the mailing list archives.
It's called Mapper.  Mapper is a little utility that helps you
map bitmap images and create the Liberty BASIC code for on-click
and on-mouseover events.  It works pretty well, and is a
graphics-specific alternative to Freeform.

Download it from:
http://www.egroups.com/files/lbnews/Coding+Tools/mapper.zip

- David Drake

For your convience a copy of Mapper.zip has been attached to this newsletter.


Controls demo:

Back to the Top

From: Dennis McK [dlm81854@accs.net]
Sent: Tuesday, 16 January 2001 10:10 AM
To: lbnews@egroups.com
> Subject: [lbnews] Controls demo fixed
Hi all,

First, thanks Alyce for pointing out the error of my gosub ways
and thanks Rory and Tony for the info.

Just for the record the corrected code is in the files section,
file name ctlevents.zip as well as on my web site.

Dennis

----- here is his original message
Attached is a demo program that shows some ways to monitor and use control and mouse events in window-type windows. It's a further developement of code that I posted earlier.
 
Here's a list of the main features.
 
Tab to the next control.
Define your own tab order for controls.
Run a branch, sub, or function for a button if the enter key is pressed while that button has the focus.
Use mouse and keyboard events for controls created with API.
Know when left or right mouse button is down.
Determine when left or right mouse clicks occur.
Detect which control is clicked with the mouse.
Know when the mouse pointer is moving.
Detect when controls get or lose the focus.
Detect key presses for any control.
Remove tabs or carriage returns when entered into textboxes.
Set the cursor at the end of text in a textbox when it gets the focus.
Auto drop combobox lists.
Use different branches, subs, functions for left click, right click, and return key press.
Make global variables visible inside subs and functions.
 
Almost all of the code is in reuseable functions and sub routines.
 
Enjoy,
Dennis

For your convience a copy of ctlevents has been attached to this newsletter.


Better Tabbing in window-type windows:

Back to the Top

From: carlcourt@aol.com
Sent: Monday, 15 January 2001 1:41 PM
To: lbnews@egroups.com
Subject: Re: [lbnews] Re: Better Tabbing in window-type windows
<<Now if anyone can demonstrate how to keep the actual tabs from 
being entered into the text of the textboxes & comboboxes we
would really have something useful, hint hint.>>

I couldn't find this code during the "tabbing" discussion, but I
just found it.

CarlC

For your convience a copy of NAVIGATE.BAS has been attached to this newsletter.


Dialog box location:

Back to the Top

From: Brian D. Pugh [bdpugh@hipperholme19.freeserve.co.uk]
Sent: Monday, 15 January 2001 6:00 AM
To: lbnews@egroups.com
Subject: Re: [lbnews] dialog box location?
Hi All

Here's another way to centre a Dialog Window, in case some
of you have forgotten (watch for wrapped lines):


rem Centreing a Dialog Modal window with the MoveWindow API call

open "user" for dll as #user

nomainwin
    left=int((DisplayWidth-420)/2):top=int((DisplayHeight-276)/2)
    WindowWidth=420:WindowHeight=276
    button #main,"Close",[Exit],UL,294,215,80,22

open "Dialog Modal" for dialog_modal as #main
    print #main,"trapclose [Exit]"
    h=hWnd(#main)
    calldll #user,"MoveWindow",h as word,left as short,_
	top as short,WindowWidth as short,WindowHeight as short,_
    1 as word,result as void
    input loop$

[Exit]
    close #user:close #main
    end

Hope this helps someone!

Brian


Adding A 3d look to Dialog Box:

Back to the Top

From: Brian D. Pugh [bdpugh@hipperholme19.freeserve.co.uk]
Sent: Sunday, 14 January 2001 4:57 AM
To: lbnews@egroups.com
Subject: Re: [lbnews] dialog box location?
Bill and David

Looks even better with a bit of 3D !

Brian

For your convience a copy of prompt2.bas and Ctl3dv2.dll has been attached to this newsletter. This version is the updated and tweaked version written by David Drake and modified by Bill Jennings and Brian D. Pugh.