Liberty Basic is develeopped by Carl Gundel
Original Newsletter compiled by Alyce Watson and Brosco
Translation to HTML: Raymond Roumeas

  The Liberty Basic Newsletter - Issue #28 - FEB 99

"The only stupid question is the one you don't ask"!

IN THIS NEWSLETTER

Common Errors, a Troubleshouting Guide

COMING SOON!

Watch this space for Stev Harney's Skinning Cats, Part 3 - coming soon!

Keep an eye on Side by Side Software for the newest version of BMPworks.dll. It includes 8 new features, including 90 and 270 rotations and screen captures.

Email Alyce awatso-@wctc.net if you would like to beta test it.

Watch for a message from Carl Gundel, who promises that the alpha version of Liberty BASIC 2.0 will be ready for testing SOON!


If you’ve ever gotten an error message or had a program crash, you are NOT alone! Here are some common problems, their probable causes, and maybe a fix. Brosco and Alyce are preparing a troubleshooting/debugging guide. Here is what we have so far for the troubleshooting part. Please send in more of these as you find them, and save others from banging their heads against the wall! Please send comments also. When replying, be sure to cut out all you can from this newsletter, and just leave the part that is pertinent to your reply. Thanks to all who have contributed to this list already!

THANKS!!!

Common Errors: a Troubleshooting Guide

INDEX OUT OF BOUNDS

GROUPBOX WILL NOT DISPLAY

CONTROLS WON’T SHOW

SYNTAX ERROR - RESERVED WORDS

GRAPHICSBOX ERROR

SYNTAX ERROR - FIRST LINE OF CODE:

LOOP ERRORS

GRAPHIC TEXT WON’T PRINT

SEMI-COLON IN GRAPHIC TEXT

BACKSLASH WILL NOT PRINT

DIALOG WINDOWS NOT POSITIONED CORRECTLY

CANNOT TAB BETWEEN TEXTBOXES IN DIALOG

CONTROLS DISPLAY IMPROPERLY IN DIALOG

INCORRECT VALUE

POWER FUNCTION ERROR

INCORRECT USE OF FULL STOP

CANNOT OPEN DLL

DLL CALL ERROR

GRAPHICS WINDOW API CALL FAILURE

VARIABLES DON’T WORK IN COMMANDS

FILE OPEN ERROR

VERSION DIFFERENCE

PRINT NUMBER ERROR

PRINT USING

DIALOG WILL NOT ACCEPT INPUT

LB EDITOR EDIT/FIND

"END IF" WITHOUT "IF" ERROR

BRANCH LABEL NOT FOUND

CHANGE RUNTIME ICON

SETUP EXTERNAL PROGRAMS ERROR

INDEX OUT OF BOUNDS

This error is often caused when you try to load a bitmap whose resolution is more than 256 colors. Note that this is not the number of colors that show in the bitmap, but the format in which it was saved. To prevent this error, check the resolution of all bitmaps that will be used in a program in your Paint program. If your program allows a user to choose a bitmap, you may either load the bitmap with NviewL16.DLL or BMPworks.DLL, which allow bitmaps of any resolution to be loaded, OR try the following code snippet:

filedialog "Open Bitmap..", "*.bmp", picFile$
if picFile$ = "" then [inputLoop]
open picFile$ for input as #pic
pic$=input$(#pic,29)
close #pic
picDepth=asc(right$(pic$,1))
picCols=2^picDepth
if picCols > 256 then
notice "The chosen bitmap cannot be loaded with LB."
goto [inputLoop]
end if
loadbmp "tempPicture", picFile$

GROUPBOX WILL NOT DISPLAY

The proper syntax for using a GroupBox is as follows:

 GROUPBOX #handle, "string", xpos, ypos, wide, high

If you put a fill stop (.) , also called a period or dot, in the handle of your groupbox, it will not display.

Wrong:

GROUPBOX #1.grb, "Color Choice", 10, 30, 300, 200

Correct:

GROUPBOX #1, "Color Choice", 10, 30, 300, 200

CONTROLS WON’T SHOW

All controls - buttons, bmpbuttons, statictext, textboxes, texteditors, groupboxes, graphicboxes, listboxes, comboboxes AND menus must be listed BEFORE the window that will hold them is opened. You cannot properly add a control to a window after you have issued the OPEN command.

SYNTAX ERROR - RESERVED WORDS

Words that have meaning as functions and commands in LB cannot be used as variables, handles and branch labels.

Wrong:

OPEN "Printer Choice" for dialog as #print

In this statement, #print is specified as the handle of the window, but it generates a syntax error because PRINT is a reserved word in LB.

GRAPHICSBOX ERROR

There is a documentation error. The command is GRAPHICBOX

SYNTAX ERROR - FIRST LINE OF CODE

If you have some part of your code highlighted (for cut and pasting) LB tries to start compiling at the point of the highlight - not the start of the program. This, by the way, is intentional - it allows for debugging small sections of code - rather than the whole program.

LOOP ERRORS

If you use For....Next loops to search arrays, do not use code like this:

for i = 1 to 100
if a$ = array$(i) then goto [found]
next i

Always exit the loop correctly.

for i = 1 to 100
if a$ = array$(i) then found = i: i = 100
next i
if i <= 100 then goto [found]

GRAPHIC TEXT WON’T PRINT

When you want to include a text print command, there must NOT be a space between the semicolon and the backslash. Correct way:

 print #w, "place 20 20"; color black;\some text to be displayed"

Be sure to use the PLACE statment before trying to print graphic text. The default location for the pen when you open a window is (0,0). When you print text, it is printed with the pen position used as the Bottom left hand corner of the text - NOT - the Upper Left corner.

SEMI-COLON IN GRAPHIC TEXT

Windows thinks that there is another graphics print command coming when it encounters a semicolon.Since its not a graphics command the /*....*/ will be ignored.

BACKSLASH WILL NOT PRINT

In graphic command, thebackslash (\) is a signal to tell the program that text will follow immediately. You can make the backslash print, though, if you use the pipes (|) character instead of a backslash to signal graphic text.

Example:

 print #w, "|C:\pics\family\rover.bmp"

The result will look like the following on your graphic window:

 C:\pics\family\rover.bmp

DIALOG WINDOWS NOT POSITIONED CORRECTLY

UpperLeftX and UpperLeftY don’t work with dialog windows. Dialog windows are opened as close as possible to the position of the cursor. To position a dialog window you must set the position of the cursor first. Read the 'Setting Windows size and Place" in the LB Help file.

CANNOT TAB BETWEEN TEXTBOXES IN DIALOG

A dialog window allows you to tab through the controls in a window. Tab will cycle through ALL controls, in the same order in which they are listed before the window is opened. If you mingle textboxes with other controls, the focus of the window will TAB through the other controls also. List all textboxes together in the order they should be tabbed through to avoid this problem.

CONTROLS DISPLAY IMPROPERLY IN DIALOG

In most windows, controls are displayed in the order they are listed. In dialog windows, they are displayed in reverse order. If you want to fill a dialog window with a graphicbox, then have other controls appear within the graphicbox, the graphicbox must be listed LAST, just before the window is opened.

INCORRECT VALUE

Sometimes the VAL() function loses all places after the decimal point. This will happen if the string has a space at the end. (Thanks Joe B. for publishing this one!) Use trim$ to trap this error.

Try this and see for yourself:

a$="2551.390"
b$="2551.390 "
c$=trim$("2551.390 ")
print val(a$)
print val(b$)
print val(c$)

POWER FUNCTION ERROR

The power function will cause a program crash if the base number is zero or a negative number. Try trapping this eventuality in your code, as follows:

if n = 0 then [loop] ‘traps 0 before the ^ operation can begin
p = abs(n) ‘changes n to positive value
m = p^3

INCORRECT USE OF FULL STOP

The character FULL STOP (.) - also known as a period or dot - may be used within a variable name or a branch label. The following are acceptable uses in LB:

credit.one = 17 ‘a variable name with full stop
[get.color] ‘a branch label with full stop

The following uses are incorrect. You may not use a DOT in a handle, other than as an extension for a control belonging to a window. Note that for a control, you may only use the one DOT.

textbox #w.text ‘correct usage to designate extension for control
textbox #w.text.1 ‘INCORRECT - TOO MANY DOTS
 
open "series.txt" for input as #s.one ‘INCORRECT - may not use dot
open "Game" for graphics as #g.p ‘INCORRECT - may not use dot
open "user.dll" for dll as #user.dll ‘INCORRECT - may not use dot

CANNOT OPEN DLL

This error happens when a program cannot find a DLL which is called. DLL files should be in the same directory as the program code, in the Windows directory, or in Windows\System.

DLL CALL ERROR

This error usually means that a call was made improperly. Check the spelling of the code routine that makes the API call. In the name of the function call, capitalization counts, so check for upper/lower case usage. Make sure the correct number of parameters is used and that all parameters are of the correct ‘type’ such as long, ptr, etc.

GRAPHICS WINDOW API CALL FAILURE

Calls to User.DLL do not work on graphics windows directly You must first make the API call to GetParent, then use the Parent handle in calls to SetWindowText, and similar calls.

VARIABLES DON’T WORK IN COMMANDS

Some places where variables will NOT work:

1) Window Controls. You cannot use variables to specify parameters when setting up controls. You must use actual numbers.

correct:

textbox #w.box, 10, 10, 200, 26

incorrect:

x = 10
textbox #w.box, x, 10, 200, 26

2) You cannot DIM an array to a variable, but you CAN REDIM an array to a variable:

incorrect:

x = 300
DIM array(x)

correct:

x = 300
REDIM array(x)

3) Printing to handles. Sorry, but you can NOT do the following:

for I = 1 to 10
print #w.i, "FONT ARIAL 0 20"
next I

Some places where variables WILL work:

1) Graphics commands. You must be sure that blank spaces appear where needed and that variable sequences are joined to quoted sequences properly, either with semi colons or (+) characters.

all of these are correct:

print #w.gb, "box ";extentX;" ";extentY
print #w.gb, "box " + str$(extentX) + " " + str$(extentY)
 
print #w.gb, "place 20 ";yValue
print #w.gb, "place 20 " + str$(yValue)
 
msg$ = "Please choose another one."
print #w.gb, "\" + msg$

2) Many other places - see examples:

all of these are correct:

msg$ = "Liberty BASIC is Great!"
notice msg$
print msg$
print #w.textbox, msg$
 
x=2
print str$(x)
print x
notice x
notice str$(x)
 
y$="4"
notice y$
notice val(y$)

FILE OPEN ERROR

There are changes between Lbv1.4 and Lbv1.41 in the way files are opened for input. In 1.4, it is acceptable to try to open for input a file that does not exist. If it doesn’t exist, it will be created. In v1.41, trying to open a file for input that doesn’t exist will generate an error. The best practice is to check for a file’s existence before issuing an open statement. Use the FILES command as follows:

filename$ = "readme.txt"
 
dim info$(10, 10)
files "c:\lb14w\", filename$, info$(
qtyFiles = val(info$(0, 0))
if qtyFiles = 0 then [inputLoop]
 
open filename$ for input as #f

VERSION DIFFERENCE

Code written for Lbv1.41 will often not run on v1.4. Added commands like HBMP, RESIZEHANDLER and LOCATE will cause a program crash in a version earlier than 1.41.

PRINT NUMBER ERROR

The print command may lose some accuracy that is accomplished with math functions. Although the math function gives a correct answer, the print command may round the number and give an incorrect answer.

PRINT USING

print using("####.##", variable) sometimes adds or subtracts a penny.

DIALOG WILL NOT ACCEPT INPUT

If a dialog box will not accept input, make sure NUM LOCK is selected (on the keyboard).

LB EDITOR EDIT/FIND

If the FIND feature doesn’t work, either try again with the BACKWARD option clicked, or make sure your cursor is set at the beginning of your program code. The same is true for EDIT/REPLACE.

"END IF" WITHOUT "IF" ERROR

The format for this is to have the IF CONDITION THEN on one line, with a new line for the code to execute if the condition is met, then a new line for the END IF statement.

BRANCH LABEL NOT FOUND

This can be caused by having a branch label, followed immediately by another branch label, like the following:

[begin]
[start]

CHANGE RUNTIME ICON

To change the runtime icon successfully, first make sure that you are using an icon that is 32x32 and formatted for 16 colors only. Then, set configure your display to 16 colors - YES, 16 colors! Reboot your computer, run Liberty BASIC, change the runtime icon, then reconfigure your display to its normal setting and reboot.

SETUP EXTERNAL PROGRAMS ERROR

If you have tried to setup external programs to run from LB’s RUN menu, you may have found that it doesn’t seem to work. When you close the dialog that allows this set up, you are told to close LB, then restart. Upon restart, your new programs should be listed under the RUN menu. If they are not, it is because the LB-ini file that contains this information is written in the current directory. This file will exist in the directory you were using when you changed the setup. Either copy it to your LB root directory, or run the setup again, but be sure you are IN the LB root directory.


Newsletter compiled and edited by: Brosco and Alyce.

Comments, requests or corrections: Hit 'REPLY' now!