© 10-Oct-2000 Cameron Arnott All Rights Reserved |
In this issue: |
Attachments: |
Proposed For Future Issues:
|
Starting Liberty BASIC by clicking on your program | Back to the Top | |||||
If you are like me and try out lots of different Basic programming languages, then you'll find that you can't remember which *.BAS file goes with which basic. Don't worry there is a light at the end of the tunnel. In some "Basic"'s (I can't say all because I don't know for sure) you don't have to have the file extension as .BAS. For example I use Extensions you could try with other BASICSs
You get the idea?
Under Windows 3.x you do the following (Sorry no screen shots)Now that you have that set up, don't forget to save your files as "*.LB2" "*.LB1" etc. Since LB2 beta2 now uses a default requester of "*.bas", when you load up Liberty BASIC manually then go to "Open" it won't show any of your files. The fix for this is simply to go to the text box that is displaying "*.BAS" and change it to "*.LB2" or the extension you've decided to use. Hopefully, Carl will be changing LB2 so that you can set your own default extension in the preferences. Don't forget that every time you update LB2, you'll have to edit the file associations to link to the new executable. You can expand on this to automaticly get Liberty BASIC to run your program when you click on it. When you have a finished product that your not going to edit anymore, you can change the extension to something else, so long as it isn't already in use. Or under Windows 95/98, you can add a second option to the same association by doing the following: Open a Window that contains a view on your system (any drive will do), select the "View" menu, then select "Folder" options and then click on the tab "File types". You should something like this:
Windows 3.x users, I think you'll have to change the extension and then add " -r -m" to the end of the command line for Liberty BASIC. |
Adding a Popup Menu To a Menu Item DEVELOPED BY BRENT THORN |
Back to the Top | ||||||||||||||||
We can add a list of recent files to the open source LB Editor. First, we'll create an array to hold the three most recently opened file names:
Whenever a file is opened, it will be added to the top of the recent files list, which is held in the array. The [open] routine begins with a filedialog. If the user does not choose a file, the routine is aborted. If the user does choose a file to open, we GOSUB [recent.files] to add this new file name to the list.
The list is easily managed in an array. We first move the filename that was in the second position to the third postion. This bumps the file name that WAS in the third position off the list. Then we move the filename that was in the first position into the second position. Last, we place the file name that was just chosen by the user into the first position:
In this way, we always have a current list of the most recently opened files. To access them, we need a RECENT FILES menu:
We'll need to place routines into the branch labels for the three files, so that the proper file is opened and loaded when the user clicks the menu item. We'll first check if a file name exists in the list, and if not, we'll abort the loading. Note that the array contains empty strings until members have been added with the [recent.files] gosub routine. If a file name has been added to the list, we go to the file loading routine, and that file will be displayed in the Open Source Editor.
This is really all we need to do to include a list of recently opened files, but it would look more professional to append this list as a cascading popup menu to an existing menu item, as Brent Thorn has shown us. First, we add an item to the File submenu to hold this Recent Files menu popup:
The branch label given for execution of this menu item is the input loop. The designated branch label will never actually be used, because we will add the Recent Files popup menu here. Now, add a GOSUB to remove the top-level Recent submenu and add its menu items to the File --> Recent menu item.
To work with menus, submenus and menu items, we need to obtain the handles. First, we need a handle to the menu bar itself and we get it by passing the window's handle (in this case it is "h") to the GetMenu call and retrieving the menu bar handle, which Brent calls hMenu1:
Once we have the menu bar handle, we use it to retrieve the handles to the submenus we want to modify. A submenu appears as a word on the menu bar, and a submenu is the first parameter in the LB MENU statement. In the following example, "∓mp;Help" is the submenu name, while "∓mp;Insructions" and "∓mp;About" are menu ITEMS:
To get the handle of a submenu, we need the menu bar handle and the position of the desired submenu. Positions are numbered beginning at 0, so the first submenu (for us, the FILE submenu) is at position 0. Our RECENT submenu was placed third on the menu bar, so it is in position 2.
Now that we have the handles of the two submenus, we can make some changes. We modify a menu with the USER function, ModifyMenu. It requires the handle of the submenu that will be modified, and the position of the menu item within the submenu that will be changed. In our FILE submenu, the RECENT menu item is the 8th item, and so it is in position 7. The third parameter needed by the ModifyMenu function is a numeric value that represents instructions to the function that tell it just HOW we want to modify the menu item. The values for each of the instructions are added together, and the resulting single value tells windows just which instructions are being issued. The instructions we will give include telling the function that we are specifying the menu item to modify by its position, not by its handle. (Had we wanted to use the menu item's handle, we would have needed to retrieve it with yet another api call.) Another part of the instructions tells the function that we want to add a popup menu to a menu item, and another one tells the function that we are giving a name (string) to the menu item. The value for the POSITION instruction is 1024. The value for the POPUP instruction is 16. The value for the STRING instruction is 0. We can set the flags in either of these ways:
OR, we can do the math ourselves:
Windows has predefined constants for these values, which are recognized by Liberty BASIC when an underscore is placed in front of the value name. MF_BYPOSITION becomes _MF_BYPOSITION in LB syntax. To "add" constant values together, use the bitwise "OR" operator:
Any of the previous three examples will properly set the instruction flag for the ModifyMenu function. After the File submenu handle, the position of the menu item to modify, and the instruction flag, we place the handle of the popup menu to append to the RECENT menu item. Windows knows to add this popup, because we gave it the MF_POPUP instruction. The last parameter is the text string that will be contained on the menu item. This can be the same as the original string name of the menu item, or it can be completely different.
We are now good to go. When the FILE submenu is activated, we see that there is an arrow next to the RECENT menu item, indicating a cascading popup menu. Moving the mouse to this item activates the popup menu, and we can click on "File 1", "File 2", or "File 3" to reload a previously opened file. There is one last task to perform. Since we have appended the RECENT submenu to an item in the FILE submenu, we no longer need to have it show on the menu bar. We call RemoveMenu to remove the RECENT submenu. This removes the submenu from the bar, but does not destroy it. It remains in memory, to be accessed through the FILE submenu, RECENT menu item.
Any time a change is made to the menu bar, it must be redrawn to reflect the change:
|
OpenSource Editor Updated With Popup Menu B>Submitted by Alyce | Back to the Top |
Here we have the Opensource Editor updated with the new Popup menu's Open Source Editor V1.5 |
Sprites in Liberty BASIC V2 Beta 2 | Back to the Top |
Yipee!!!! Carl Gundel has included some sprite commands in Liberty BASIC 2 beta 2 to access Sprite02.dll written by Alyce. Until now we've had to access the dll using the CallDLL command
(which by the way you still can). The inclusion of these commands will definitely make using sprites in our programming a lot easier. Included in the distribution of Liberty BASIC
2 beta 2 is a Sprite help file and demo's on how to use the new commands. I was going to write an article explaining how to use these new commands but Alyce has done a brilliant job (much
better than I ever could). There is also an update for the help file on - October 2, 2000 -- Liberty BASIC 2 updated sprite tutorial!!! - .
News Flash: I just saw a message in the mailing list that Alyce has just fixed a bug in the sprite scrollong routines of her dll, the updated sprite03.dll can be found on Alyces web site. |