**Fast FAQ:** These issues were discussed by newcomers on the boards. Have a quick scan even if if you have programming experience. experience. Something will be relevant now or in the near future. future. Hopefully little bells will ring when you are feeling perplexed. I'm going to split this into two parts. Firstly perplexed. First some general concepts about Liberty and the environment it creates and then error handling. The section on error and then handling tackles those errore that slip past Liberty's compile time check. **Liberty's programming environment:** **Write Run Compile Execute:** Liberty code is drafted in the IDE and stored as a .bas file. When you click on Run or or Debug, your code is first compiled, any any coding errors cause the compiler to stop and and report. When error free the compiled code goes to runtime and your instructions are executed and appear on screen in whatever window type you have specified. So, specified. So, running a program is a two step process, seamless, but still two steps. Optionally Optionally a .tkn file can be created; it is a a precompiled program that saves a little time when when starting up. The .tkn also secures your code from prying eyes. **Debug:** The compiler will do some of the debugging for you. Once you get to runtime the Ladybug Ladybug icon is your best friend. Go Go on, click it. Spend as much time with the debugger as as the IDE. Click on the >>> animate icon and watch your program program run line by line. If If it gets a runtime error it stops on the offending line and you can see the content of all your variables at that moment in time. **Window Types:** The first window type you will encounter is Liberty's mainwin. This is the default window type type and is essentially a testing testing and debugging window. As soon as you are competent you you will be using other window types. It It is great for your first steps into programming and you can write quite complex programs in in this environment, but but it has limits. It cannot produce a GUI style interface. It's styled as a a traditional DOS console and cannot produce colored colored text. Neither does it support the traditional traditional inkey$() statement, only input$(1). The essential difference is that program flow program flow stops and waits for input. You will use the mainwin for development and debugging and a standard Window for almost everything else. A standard window provides GUI controls like listboxes, buttons and checkboxes. There are specialised windows for graphics, text and dialogs. Be aware they exist and take time to choose the correct window type for the task in hand, but have a good reason to move away from the standard window type. You will use the mainwin for development and debugging and a standard Window for almost everything else. A standard window provides GUI controls like listboxes, buttons and checkboxes. There are specialised windows for graphics, text and dialogs. Be aware they exist and take time to choose the correct window type for the task in hand, but have a good reason to move away from the standard window type. **Looping Stop Break Kill:** Endless loops are an endearing feature of all programming languages. A simple loop like WHILE WHILE WEND can consume all all of the processor cycles that Liberty can get hold of and if if you don't have dual core your PC will freeze as well as the program. If program. If you are in trouble press CtrlBreak Then navigate to the IDE and from the Menu select Run, Run, Kill BASIC Programs. Do Do put SCAN inside loops. Scan is a very important command that causes Liberty to check check for mouse or keyboard input. Don't code delay loops like FOR n=1 TO 50000 : NEXT. Liberty operates in a multithreaded environment where processing cycles are shared. A delay loop like that hogs the processor. Use TIMER if you need a pause, or better still WAIT for the next event. Don't code delay loops like FOR n=1 TO 50000 : NEXT. Liberty operates in a multithreaded environment where processing cycles are shared. A delay loop like that hogs the processor. Use TIMER if you need a pause, or better still WAIT for the next event. **GUI program flow:** Know a bit about BASIC? Cool. To make the transition to GUI you need to have the concept of of "events" firmly in your mind. You You set up events, the keyboard might trigger an event, the mouse mouse might trigger an event, and the timer might trigger an event. event. A listbox might trigger an an event. Each event has a handler, a code block that will be called when the event fires. Typically at the end of this code block there will be a WAIT statement. Program execution sits sits and waits here till another event event fires then it shoots off to action that. You may also use Subs Subs to handle events. Events Events repeat, you need to switch them off if you don't want them to fire again. The TIMER statement statement catches a lot of folks out, out, switch it off immediately it has fired if you want it to be a a one shot event. Subs Subs are self contained and don't know much about the outside world. If an event that has a branch branch label handler fires while you you are in the sub it's going to fail. Switch off events going into a a sub or ensure the event is handled by a sub itself. Best not to to mix subs and branching to labels labels in GUI code. **Include:** Include is not relevant to Liberty BASIC. For a start the system is complete in itself and needs no no libraries attached. There are are no restrictions on code size so there is no need to page in and out out segments of code. Code banks are available that let you you cut and paste blocks of reusable code code directly to the program. The IDE allows you to jump about the program in a variety variety of ways. Liberty ways. Liberty also provides direct access to Windows API and third party dll files. Typing **Typing & Dimming variables:variables:** If you are used to typing variables forget it, this is automated within Liberty. Anything that has has a fractional value beyond the decimal decimal point is stored as a float, anything else is stored as as a long (4Byte) value. As As in any computer language you have to to be aware that comparing two float values is problematic, problematic, they are never really equal. > or < is ok but don't try and see if one float if floatA = another float. UsefloatB. Use Int() or add epsilon if you must. Variables Variables initiate automatically with 0 or "" values and in general don't need dimmed though you you can if that’s your habit. Arrays Arrays initiate automatically with 10 elements, if you intend to use more more than 10 elements you must dimension the array. Arrays Arrays are global by default others must must be specified as global. Liberty Liberty can hold a whopping 70Mb of variable data at any one time. Beyond that you need to to page data in and out from file. **Graphics:** Liberty has a drawing pen, if you don't have that Down you won't see any graphics. So set the the pen down as the first step in any any graphics operation. Liberty Liberty has a Flush command that consolidates recent drawing operations into a segment. The The segment resides in memory and and can be redrawn instantly. You must Flush if you want graphics graphics to stick on screen and not be wiped out if another window window passes over them. You You must Flush if you want to print or scale graphics to the printer. Be aware that Flush consumes memory, use it sparingly and delete any segments you don't need. You can use use up your 70Mb of memory in in a split second if you misuse the command. **Sorting:** Liberty sorts in Lexographic or Dictionary order. This is different from ASCII order which you you may be more used to. It is possible possible to arrange for the sort to be in ASCII order just be aware aware of the difference. **Trivia:** If you use the Using(###.##) statement you will get a % in front of your number if it is too big big to fit in the template. The printer printer dialog is not able to change from the default printer. Goto Goto [label] needs a command after the label not another [label]. Kill Kill program may leave the the program in the kill list even though it’s killed. **Liberty Runtime Errors:** A tip,Tip, don't cry "bug”, you may feel foolish later :) try reading this and especially try running running animate in the debugger. **OS Error cannot find file.........** while building your .exe Start Liberty from the folder you installed it from to begin creating your .exe **Problem Creating File..............** while building your .exe Don't create your .exe in Liberty's program folder, create it elsewhere. **File System Access Denied..........** Either the file is already open, perhaps you forgot to close it, or it is in use by another program program or you don't have Windows permission permission to access it. Network paths need special special handling or mapped to a drive: **Error Opening File.................** The file is being written to by another program or, you’re on Vista! join the User club club and get your permissions sorted out. You You may need to be an Administrator to to gain permission to access the file. **The file is literally invisible.........** Vista again, get permission. **System Primitive Failed..................** You are out of memory; check what your loops are doing you may be creating a very very large number or a very (large) small number. number. **Invalid branch label [xyz].........** If it does exist you called it inside a sub that doesn't know where it is, an event perhaps. perhaps. **Index (nnn) is outside collection bounds ...........** An index is a pointer to a position in an array. Indexes are used in array variables, in in record pointers and by the system in bmps. bmps. Most often you will have asked for an an array item that does not exist. So check what value is in array(index)array(index), array(index,index) or seek(index)seek(index). **Argument must be a collection......** This is often associated with sending Liberty the wrong set of arguments in a command command string. sending "refresh" to graphicbox graphicbox for example or using $ values where where numeric values are expected. Animate should stop on the offending l ine, doubleline, double check the help file for the command and examine the values in the variables. **Collection is empty.................** Liberty expected some arguments but didn't get them, Print "!" to a textbox for example, example, Liberty expects arguments after after the !command. Animate should stop on on the offending line, double check the help file for the command. **IsEmpty.............................** Liberty found itself without the information it needed. This This is most often program flow. Search Search for missing ends, end sub, end if, next. Practice indenting your code so that code blocks are easily visible. Make sure code does not run through to code blocks you you didn't expect it to reach. Ensure Ensure Waits are placed where required. Other Other reasons for this error are missing arguments or missing data, file access denial or or Liberty finding Null info where where it expected something. This This is sometimes the hardest to debug because program flow errors turn up anywhere but but where the error was made. Use Use animate but don't assume the line shown is the cause. Find Find the error.log and see what fragments of code are mentioned mentioned in it. Start Start manual debugging, use step through a line at a time and make sure you are going where where you expected. Code in notices notices or use the run to break option. Heyoption in the debugger. Hey debugging is part of the fun.