Lladnar Enterprises
Sometimes when using Liberty BASIC, there are error messages presented while compiling (called compile-time errors) and while running a program (called run-time errors). Here are some compile-time errors: Syntax error - This means that some error was made while typing in a BASIC statement. You should examine the line and look for typing mistake. Type mismatch error - This means that you tried to use a string where a number should be used, or a number where a string should be used. Here are some run-time errors: Branch label [exampleLabel] not found - The program tried to GOTO or GOSUB to a label that doesn't exist. Float divide by zero exception - The program tried to divide a number by zero, which is not possible to do. File filename not found - This error can occur when attempting to load a bitmap image from a disk file into memory using the LOADBMP statement, and when no file of the specified filename is found to exist. Bitmap named bitmapname not found - This error can occur when attempting to save a bitmap from memory to a disk file using the BMPSAVE statement, or when attempting to use the DRAWBMP command, and a bitmap name is specified which doesn't exist in the program's memory. Control type fonts are set with: !FONT face_Name width height - An error was made specifying the font for a control (controls which return this error include button, textbox, radiobutton, checkbox). undefined struct: structname - An expression referred to the name of an undefined struct (see the help file for information about the STRUCT statement). root.field.struct undefined - An expression referred to a field which is undefined for a struct which is defined (named root in this example). Errors when using serial communications - There are a handful of run-time error messages which terminate program execution. These usually correlate to API function call failures that occur when attempting different operations. In this case, the error is reported by Windows, but the description of the reported error is generated by Liberty BASIC. Here is a list of the error messages: The following run-time errors are indications of more subtle problems in Liberty BASIC. If you see one of these errors, send email to carlg@libertybasic.com describing in as much detail how the error happened. If you have BASIC code that can reproduce the error, please include it in your message. Index: n is outside collection bounds The collection is empty Object is not in the collection Path and Filename Complete Path and Filename References to a complete path and filename indicate that the drive letter and all folders and sub folders are included in the file specification. A complete path and filename is returned by the FILEDIALOG. An example of a complete path and filename is as follows: C:\My Documents\My Programs\Games\mygame.bas Filename Alone References to a filename without path information indicate that the disk filename is used with no drive or folder information. In Liberty BASIC, use of a filename without path information assumes that the file exists on disk in the DefaultDir$. An example is as follows: mygame.bas Sub Folder A file that exists in a subfolder of the DefaultDir$ is written by first identifying the sub folder(s), each followed by a backslash, then the filename, like this: images\background.bmp gamefiles\images\badguy.bmp Relative Path Relative paths to files that exist in folders at the same level in the directory tree, (or in a higher level), use the ".." designation to indicate "go up one level from the DefaultDir$". Filenames are usually designated by including a dot and a file extension that specifies the type of file. Filenames ending in ".txt" are text files, (for instance), while filenames ending in ".bmp" are bitmaps. Folders do not typically have extensions. The names below with extensions indicate files, while the names without extensions indicate folders. Here are some examples of relative paths: ..\smiley.bmp 'go up one level to access the file ..\images\redbox.bmp 'go up one level to access the file in the images folder ..\..\customer.txt 'go up two levels to access the file ..\..\data\names.dat 'go up two levels to access the file in the data folder Hard-coding Path and Filename The phrase "hard-coding" when referring to path and filename information indicates that the pathname specified in the progarm code contains the entire file specification, including the drive letter and all folder information as well as the filename. If a program is meant for use by the programmer alone, on a single computer, this method works, as long as no changes are made to the directory structure. When any changes are made to the directory structure or filename, the program code must be changed as well. Caveat It is very unlikely that other users of a program will have the same directory structure on their computers as the programmer who writes the code. For this reason, it is best to use one of the other path naming options listed above that does not depend upon all users having the same directory structure on their computers. Filenames Used in Code Some commands that use path and filename specifications are: