From G.H. Wells: geoBASIC bugs and workarounds: 1) The most important bug concerns the use of the UPDATE command. NEVER USE IT! If you ever UPDATE a geoBASIC program, it gets corrupted in such a way that later on, the end of your program will disappear. "The Smee" has discovered that RUNning a program should be done. His advice is to always RUN a program before QUITing or CLOSEing and never use UPDATE. 2) The BITMAP command does not work after a disk command but you can overcome this problem by re-opening your geoBASIC program before using BITMAP. The following geoBASIC sample illustrates how: 10 CREATE "junk" 20 SYSINFO 14, name$ 30 OPEN name$ 40 BITMAP "pic",10,10 Assuming that "pic" is a disk-loadable bitmap, take out lines 20 and 30 to see the problem. 3) Don't close and re-open a VLIR file you are working on. This problem was just recently discovered and a fix had not been found. It may be similar to the BITMAP problem. 4) GeoBASIC is incompatible with some auto-exec files such as Blackout which will make the screen go black in edit mode whenever you move the mouse. This can be fixed, however, by removing Blackout from memory before running geoBASIC. Email bo@prismnet.com for a program called "AntiBLACKOUT" to accomplish this purpose. 5) If you are running geoBASIC on the 40 column screen of GEOS 128, do not have any desk accessories on your disk when you make your program into an application or when you are running it after making it an application. Desk accessories work fine under GEOS 64 but they screw up the loading of stand-alone applications under GEOS 128. 6) Always RUN your program just before you make it into an application. 7) Never POKE or LOAD anything into the background screen memory. The only safe place to store machine code is in the foreground screen memory which extends from 40960 to 48959. It is usually easy to design your screens with a little blank area in them in which you can set both colors to white so the machine code will not show up. If you are not a machine code programmer then you will not have to worry about this. 8) WRITE puts a CHR$(0) at the end of every item which it puts into a file, plus another CHR$(0) at the end of each record. This listing shows how to "bury" those zeroes in a geoWrite file, so that they won't interfere with the text. They're made a part of four-character font, style "escape sequences'" that say, "plain text." Note: Line 60 "works around" a bug in the HEADER statement. And, line 70 adds a field which isn't even touched by HEADER! Those lines show you where to go when you want to customize CREATE/SAVE's fileHeader. 10 rem subject: hiding write's chr$(0) 20 rem this shows how to bury write's chr$(0) terminator in an escape sequence 30 rem demo code makes a geowrite 1.1 file. 40 z$=chr$(0):nc$=chr$(23)+chr$(9):ns$=nc$+z$:rem sets plain bsw9 font 50 rl$=chr$(223)+chr$(1):rl$=z$+z$+rl$+rl$+rl$+rl$+rl$+rl$+rl$+rl$+rl$+ns$ 60 header 7, "Write Image v1.1",1: poke 28452,49:poke 28453,46:poke28454,49 70 for p = 1 to 9:poke 28478+p, asc(mid$("geoWrite ",p)): next 80 create "list": for p = 0 to 125: append p: next 90 for p=0 to 2: ptrec p: restore: write rl$ 100 for w = 1 to 16: read d$: write " " +d$+ns$," "+d$+ns$: next: write nc$: next 110 write "": ptrec 0: close 120 data "name-1", "name-2", "name-3", "name-4", "name-5", "name-6", "name-7" 130 data "name-8", "name-9", "name-10", "name-11", "name-12", "name-13", "name-14" 140 data "name-15", "name-16" It's important that there aren't any typographical errors in your program file! Be sure to correct the two string literal constants (in lines 60 & 70)! They must be in lower case, with only certain letters in capitals. 9) DELETE _may_ cause the same effects as UPDATE does. Do not use DELETE from Direct mode unless you need to delete a lot of multiple lines. To delete a line it is best to type the line number the line is on and hit return. 10) When using the FONT command, you may have noticed that by Typing in FONT "BSW",9 doesn't automatically select the BSW font which is resident. This is not only annoying but wastes time. Use CALL 49483 which will call up the BSW resident font instantly. 11) When you call up a DBSTRN dialog box, and it has TEXT which you have programmed into it, you may have noticed that the Text prints in bold. To Defeat that, type in as follows: DBSTRN CHR$(27)+"Enter Input",IN$ 12) If you have used the variable functions within DIALOG (using the Editor to design the DB) You should have noticed that the last character gets chopped off into limbo. To avoid this create a permanent variable such as SP$=" ". There should be a space between the quotes. When creating your dialog box, and you want the variable, such as B$ to print out in the dialog box, enter it as follows: B$+SP$ The space that gets to go to limbo now is SP$. Here are bugs and misprints from the geoBASIC manual: Page 13) The sample application has been corrupted by the UPDATE command (strike the last sentence on page 13) and you cannot edit it although you can RUN and LIST it. Page 17) Don't ever UPDATE. Always RUN a program (even if it doesn't work) before QUITing or CLOSEing. Page 18, 3 lines from the top) Change F7 to F5 Page 19, RESIZE) The heap is how much memory is left over for variables after the size is set for the code of your program. If you get an "out of memory" error, resize the code to 2 or 3. You will have to do this every time you load your program to edit and run it but don't worry, if you forget, you'll just get the "out of memory" error to remind you. GeoBASIC only allows up to 7k for variables, so you have to be very frugal. There is an advantage to resizing the code to the largest possible value just before you finally make your program into a stand-alone application since it will run much faster on a real disk (as opposed to a RAM disk or shadowed disk). Page 21, three lines from bottom) The most negative integer value allowed is -32767 which is really a bug because it makes the double-byte logic functions almost useless. Page 23, end of last full paragraph) Don't leave the trailing quotes off of string constants, even if it sometimes works. Page 26, four lines up from bottom) Integer arrays take four (not two) bytes per element although only two are used. (This is no doubt a bug although it causes no more problem than just wasting precious variable memory space.) Page 29, near top) NOT 0 evaluates to -1 (instead of +1) and NOT 1 evaluates to -2 (instead of 0). The logic functions work on all 16 bits individually unless an input or intermediate value is -32768. You can get -32768 as a result (NOT 32768 correctly returns -32768) and it should be legal to PRINT NOT NOT A for any value for which you can PRINT NOT A but it won't work for A=32768. This means you must be very careful when testing programs where you really do want to do logic functions on all 16 bits. Either break you values into two 8-bit values or guarantee that the 16th bit can never be set all by itself. Page 32, last sentence) Pay special attention to the statement that geoBASIC is the opposite of CBM BASIC when comparing strings. In your mind, always interchange "<" and ">" when used with strings or you will waste a lot of time debugging any program that uses them. (At least this "bug" was documented). Page 39 and 104, APPEND) In the example of APPEND 2, the pointer will be at the new record which is 3. (The old 3 and above have all been moved up one.) The admission of a bug that prevents APPENDing to record 126 is in error. GEOS VLIR files can have only 127 records which are admitted to, it isn't a bug at all but a documentation error? Actually, this "bug" is mentioned many times in the manual but I'll just mention it just once here.) Page 41, CALL) You can also PEEK the returned values of the A,X,Y, and status registers at locations 650 through 653 respectively. Unfortunately you cannot directly CALL any GEOS routines that pass parameters in the zero-page pseudo registers. Page 42, list of CHR$) CHR$(26) turns on outline printing and CHR$(27) turns off all effects. Page 48, DELETE) This command can also be used inside the editor to delete program lines following the same syntax as for LIST on page 66. Typing DELETE all by itself erases your entire program. Page 53, FIND) I don't think this editor command is documented anywhere in the manual but it is extremely useful. It searches for every occurrence of a text string in your program or just within a range of lines. I especially like it to detect re-used variable names by having it find the first three characters of a new variable name. If it finds another variable starting with the same three characters, then I need a different name. The syntax is FIND "string",10,20 where the start and stop line numbers are optional. Page 66, bottom) Hitting the F5 key toggles the listing, don't hold it down. Page 70, MOUSE) This command requires two more parameters and has the same syntax as PROMPT on page 81. Both commands do not take effect until the mainloop is entered. Page 76, PATTERN) The patterns are the same as those displayed in geoPaint. To erase an area use 0. For a solid fill use 1. Page 77, POINT) This command can turn off as well as turn on individual screen pixels as determined by the previous setting of SETCOL. Use 0 to turn pixels off and 1 to turn them on. Page 82, PRSCREEN) If the expression is 1, the screen is printed double size, not rotated. Use MAINLOOP instead of RETURN when done with this command. Page 87, RND) This function is hardly random, use with caution. Try this simple program which should place dots randomly on the screen: 10 CLS 20 SETCOL 1 30 POINT RND(319), RND(199) 40 GOTO 30 Page 88 & 89, SETCOL) Add a 4th use for the POINT command as described earlier. Page 90, last paragraph) The first expression for voice must evaluate from 1 to 3 (not 0 to 3). For the second and third expressions, interchange the words "high" and "low". Page 95, near bottom) Parameter #13 determines how the geoBASIC program was "RUN" or called. If it was double-clicked on as a stand-alone application, the value is 0. If it was double-clicked on prior to being converted to an application, the value is 1. If geoBASIC itself was run and then the program was selected from the dialog box, the value is 2. Page 96, TAB) The expression must be between 0 and 319. There is a tab at every pixel location, not every 40. Page 97, TESTPT) Change to CHKPT. Additional commands and programming tips 1) The FIND command is not documented in GeoBASIC but is very useful. Its syntax is as follows: FIND This must be entered from direct mode, and will result in a Syntax error if done within execution mode. 2) The ' can also be used in place of REM. This will save you a few key strokes. The ' will be replaced by REM after you hit return. 3) The POP command is not documented within the GeoBASIC manual because it contained a bug which was later fixed with a patch made by William Coleman. Pop now removed the last two current pointers for UNTIL, LOOP, & RETURN. This can be useful if you plan it right. 4) To detect whether sprites have collided or not, it is best to use the Commodore Kernal Sprite collision detect. But we need a way to swap the GEOS Kernal in and out to Peek the Commodore Kernal. Use the following: POKE 1,53: REM This Swaps GEOS Kernal out and Commodore Kernal in. POKE 1,48: REM This Swaps GEOS Kernal back in. 5) If you want to create temporary data files, but do not want to clutter up your disk and do not want to do Disk cleaning later, use a header that creates a TEMPORARY data file as follows: HEADER 13, "Temporary", 1 When you re-enter the deskTop, it will automatically be erased from your disk, regardless. This is good if your about to run out of variable space, or any other data which you do not need at the moment. This will conserve some space. 6) On some printers PRNTER will allow you to select between your printers DRAFT or NLQ modes. The Manual is correct in stating that a 0 will route output to screen while 1 will route it to printer. Any number greater than one will also route text to the printer, but in NLQ mode. 7) If you are running a program which does not require MOUSE input, shut off the mouse pointer. It will increase the speed of your program. To shut it off type MOUSE0,0,0. You can use MOUSEX and MOUSEY to store that mouse pointer position for later. 8) The UPDATE option isn't totally useless. If you make a program you do not want anyone to alter or modify, use the update command after you have made your program source into an application. Remember you can still view the source code of a program by double-clicking on geoBASIC, not the Application. Then select the geoBASIC Application and PUNCH open. Then select UPDATE a bunch of times. Your program will still work normally, but lines added to the Program will disappear once you exit. 9) geoBASIC Application Chaining: 10 CLS 20 HEADER 6,"",1 : REM look for applications 30 DBFILE L$ 35 IF L$="" THEN END 40 S=LEN(L$) 50 FOR I = 1 TO S 60 X + ASC(MID$(L$,I,1)) 70 POKE45055+I,X: REM Stores application name in screen memory. 80 NEXT I 90 SYSINFO 3,CD: REM CD is Current Drive 100 CALL 49840,0,0,CD: REM This is SetDevice 110 CALL 49825: REM This is OpenDisk 120 DPOKE14,45056: REM Flag R6. Name pointer. 130 POKE 2,0: REM Flag R0L. 140 CALL 49672: REM This is GetFile. There are side effects though! If you use this, you can only load another GB Self Running Applications!! Anything else will cause a lock up! Also you must Exit to Basic! To do so your Exiting program must not end with END. Use this instead: 10 DPOKE 12,0: REM flag R5 20 DPOKE 16,2051: REM flag R7 30 POKE 2048,0 40 DPOKE 2049,0 50 CALL 49729,S 60 REM Call ToBasic Now look at line 50. The variable S must not have any set value! Leave it Undefined! When you exit to basic all you have to do is hit RESTORE and you will be deposited back to DESKTOP. 10) Creating SEQ files in geoBASIC: Although CREATE does not work on SEQ files you can still create a new SEQ file or overwrite an existing one using the SAVE command. You have to take a totally different approach than the simple way to do it with VLIR files. Here's the technique for creating or overwriting a Text Scrap: First POKE the new Scrap into part of the background screen, say from 29000 to 29999. Then execute these commands: HEADER 4, "Text Scrap", 0 SAVE "Text Scrap", 29000, 1000 Note the two spaces between Text and Scrap. You can read a SEQ file one byte at a time using the HEADER, OPEN, RDBYTE, and CLOSE commands. You can also LOAD it into memory but there is no way to prevent a long file from overwriting more memory than you want so I prefer reading it one byte at a time. Or you could read the first few bytes to see how big it is and then CLOSE and LOAD it if it is not too big.