Future Library Tutorial for beginners by Creactive (Creactive20@hotmail.com) http://www.cvrec.cjb.net ----------------------------------------------------------------------- Copyright © 1999-2000, Future Software. Visit our homepage at http://www.qb45.com. ----------------------------------------------------------------------- Feel free to distribute this tutorial(unchanged please). ----------------------------------------------------------------------- What is the Future Library ? It's a library that offers many advantages like SVGA graphics and mouse support...and much more. About this tutorial : I suppose you already know some qbasic commands. The 'for beginners' does not mean that you are new to programming in qbasic, but that you don't know what the Future Library is!! This tutorial does not explain all of the Future Library commands, it will only teach you all you need to know to replace PRINT,LOCATE, INPUT,CLS,SCREEN in SVGA mode and how to start the FUTURE LIBRARY, the use of the mouse will also be explained(right and left click...). Some text '' is from the HTML manual of the Future Library v3.5! IF you want to know more, I recommend you to read the help html that comes with the Library... IF you find some errors report them please(my email is in the title of this tutorial, or go to my site and click on contact to have the actual email). Overview : ---------- 1. Starting 2. SCREEN 3. CLS 4. PRINT,LOCATE and the use of RGB 5. INPUT 6. MOUSE 1. Starting : ------------- Download the Future Library. Where ? Here : http://www.qb45.com Put it into your Qbasic folder. You should have a folder called Futurel35 with many subfolders. Don't forget to have a look at the example bas files.(in the examples folder) Now you will have to start Qbasic using the library: qb.exe /L future45.qlb /ah The line above will do that for you. There are two ways to do it : First way: Just open notepad and copy&paste it into a new/empty text. Go to 'File'(alt + F) and select 'Save As...'(A). Filename : FLstart or whatever you want but the extension has to be '*.bat'. Save as type : All files (*.*) So with FLstart it will save as FLstart.bat In the case you don't know what a 'bat' is, you just created a BATchfile, which will start Qbasic with the Future Library for you if you click/run it. Second way: Go to DOS prompt and type in the line : qb.exe /L future45.qlb /ah and press enter. Now use it, when you are inside Qbasic add this line to an empty bas: REM $INCLUDE: 'future.bi' or '$INCLUDE: 'future.bi' This will add the Future Library features to your program. In the next Chapters we will see how to replace some usual commands when using the Future Library. 2. SCREEN --------- Wonder how to use SCREEN with the FL ? 'The function Future.ModeList is used to see which screen modes the video card supports (i.e. Modeinfo$ = Future.ModeList(IndexNumber%). The Indexnumber% indicates where in the mode list to look for a mode. The position of a specific mode in the list can differ from card to card, so you should always search through the whole list until you find the mode you are looking for. If the function returns a null string you have reached the end of the mode list. Also, before any screen mode is set, your should check to see if your video card supports VESA at all, the function IsVESA will return -1 if VESA is supported by the video card.' For example : ReSetScreen Set640x480 16 Will use 640*480 pixels with 16bit (ReSetScreen = Screen 0) Set(x)x(y) (Bitnumber) Supported resolutions : Set320x200 (B) Set320x240 (B) Set320x400 (B) Set320x480 (B) Set400x300 (B) Set512x384 (B) Set640x350 (B) Set640x400 (B) Set640x480 (B) Set720x480 (B) Set720x576 (B) Set800x600 (B) Set1024x768 (B) Set1152x864 (B) Set1280x960 (B) Set1280x1024 (B) Set1600x1200 (B) Set1920x1080 (B) Set1920x1200 (B) Set1920x1440 (B) Set2048x1536 (B) (B) is standing for bit number. 'Bitnumber' is the amount of bits the mode should use to represent a color. The bit number the library supports are 8, 15, 16 and 32 bits.' 3. CLS ------ CLS is a very useful command. But if you use the FutureLibrary I would recommend you use: Future.FILLBOX 0, 0, x, y, 0 For example : Future.FILLBOX 0, 0, 640, 480, 0 The last number is the color (0 = black) Why Fillbox ?!? Because ReSetScreen will cancel your SCREEN/SET(x)*(y) (B) we have seen in Chapter two. And you will have to do it like that (for example) : ReSetScreen Set640x480 16 'You have to add this line (for example) after ReSetScreen Your screen will flicker a lot and this method is slow. Because ReSetScreen is SCREEN 0 !(you have to reset the SCREEN after ReSetScreen) If you use Fillbox like I demonstrated above it will work much faster and your screen will not flicker. Finally : 'Before exiting you program it is a good idea to call 'ResetScreen', if you don't you will stay in the selected mode after the program stops. This happens because the library don't know when you want to exit the program, so it can't change back to text mode automatically. By calling 'ResetScreen' the screen is set into text mode also known as SCREEN 0. You must call 'ResetScreen' for this to work, do not call SCREEN 0 directly.' 4. PRINT,LOCATE and the use of RGB ---------------------------------- Here comes the interesting part of this tutorial. LOCATE does not exist in SVGA mode! 'You can use 'Future.PRINT' to print text in any of the supported screen modes (i.e. Future.PRINT X, Y, "Hello World", F, B) The last two parameters is the foreground and background color to use. If the color is set to -1 it will be transparent (no color will be used). ' PRINT has a locate: 'The first two parameters are a X,Y offset in pixels, from the upper left corner, from where the text is to be printed on the screen' Let us convert LOCATE : LOCATE 1,3: PRINT "HELLO" 'What's RGB 'R stands for the amout of red color intensity 'G stands for the amout of green color intensity 'B stands for the amout of blue color intensity 'You can create any existing color if you change this values from 0 to 255. Col# = RGB2Color(255, 255, 255) Future.PRINT 3 * 8, 1 * 16, "Hello", INT(Col#), -1 or you can use the RGB directly inside the Future.PRINT : Future.PRINT 3 * 8, 1 * 16, "Hello", RGB2Color(255, 255, 255) , -1 * 8 and * 16 if the caracters have 8 pixels width and 16 pixels height. 'If you want to change the font use : Future.LoadFONT "fontname.fnt" After setting a mode you can change the font size by calling 'Setfont'. i.e. Setfont(x) where x is 0 for 8x8 font size, 1 for 8x16 font size and 2 for 8x14 font size. You can also install your own font types by using Future.LoadFONT. It will load a font file previously saved by the Font Editor. When the file is loaded the font is saved in memory and it immediately overrides the SetFont function, only by calling SetFont can the fonts be reset to the default system font type.' 5. INPUT -------- INPUT is not available because it uses graphics and it is not working if you use SVGA. To replace INPUT create a GOSUB: inputmenu: imy = imy + 1 DO ki$ = INKEY$ ki$ = LCASE$(ki$) IF ki$ = CHR$(27) THEN an$ = "": EXIT DO IF ki$ = CHR$(13) THEN Future.PRINT imx * 8, imy * 16, an$ + " OK", 500, 0: SLEEP 1: EXIT DO IF ki$ <> "" AND ki$ <> CHR$(8) AND ki$ <> CHR$(27) AND ki$ <> CHR$(13) THEN an$ = an$ + ki$ Future.PRINT imx * 8, imy * 16, an$, INT(Col#), 0 END IF IF ki$ = CHR$(8) THEN lenan% = LEN(an$) IF lenan% < 1 THEN lenan% = 1 an$ = LEFT$(an$, (lenan% - 1)) Future.PRINT imx * 8, imy * 16, an$ + " ", INT(Col#), 0 lenan% = 0 END IF LOOP RETURN To use this menu use: 'inputmenu additional code imx = the position you want, it is like LOCATE imy = the position you want, it is like LOCATE Future.PRINT imx * 8, imy * 16, "What is your name: ", INT(Col#), 0 GOSUB inputmenu IF an$ <> "" THEN name$ = an$ an$ = "" Text$ = " " imy = imy - 1 Future.PRINT imx * 8, imy * 16, Text$, INT(Col#), 0 imy = imy + 1 Future.PRINT imx * 8, imy * 16, Text$, INT(Col#), 0 imx = 0 imy = 0 'finish If you have a background use -1 : Future.PRINT ..., -1 That is my version of INPUT for the FutureLibrary... You can do your own version, I guess there are better ways to do it! 5. MOUSE -------- This chapter is about the usual mouse commands. Future.MouseOn 'turn on svga mouse Future.MouseOff 'turn off svga mouse Future.UpdateMouse 'updates the cursor graphics : 'Using a mouse in a svga mode is supported, but it is a polling mouse. That means for the mouse to move on screen you have to call 'Future.UpdateMouse' continuously' mousex = Future.MouseX 'Get mouse x position mousey = Future.MouseY 'Get mouse y position Here comes the interesting part : IF ((Future.MouseB AND 2) = 2) = -1 THEN do that... 'if rightclick then ... IF ((Future.MouseB AND 1) = 1) = -1 THEN do that... 'if leftclick then ... ---------------------------------------------------------------------- Erm that's all, I suppose you can do a lot using those commands! Read the help file that comes with the library for the other stuff... This was for all you programmers. Have fun! Creactive (And don't forget to visit : www.cvrec.cjb.net) :P