==================================================================== Set screen colors using the mouse ==================================================================== Product: R:BASE Version: 4.5 Plus! or Higher ==================================================================== Area: Programming Catalog: Programming in R:BASE ==================================================================== Two new ISTAT keywords -- MOUSECOL and MOUSEROW -- allow you to find the exact location of the last mouse click. For example, try this simple program. CLS FILLIN vmclick=0 USING ' ' AT 1,80 SET VAR vmrow = (ISTAT('MOUSEROW')) SET VAR vmcol = (ISTAT('MOUSECOL')) When the screen clears, point the mouse at the bottom right hand corner of the screen and click either mouse button once. Then type SHOW VAR. The value of vmrow is 25, which is the number of the row where the mouse was clicked. The value of vmcol is 80, the column number. Using the "=0" option on the FILLIN variable restricts the user to one keystroke, or one mouse click. Note that the mouse click did not need to be at the FILLIN prompt for the FILLIN command to execute in response to the mouseclick. Here's what the variables look like. Note that the FILLIN variable, vmclick, contains the string [MOUSEBUTTON1]. In addition to trapping the location of the mouse click (or cursor) using the ISTAT function, the FILLIN command returns keywords indicating which mouse button was used. Variable = Value Type ------------------ ------------------------------ ------ #DATE = 12/15/93 DATE #TIME = 12:54:12.090 TIME #PI = 3.14159265358979 DOUBLE SQLCODE = 0 INTEGER vmclick = [MouseButton1] TEXT vmrow = 25 INTEGER vmcol = 80 INTEGER These functions return the value of the last mouseclick regardless of when that mouse click took place. It is important to also check the FILLIN variable, vmclick, to verify that the mouse was used and not the keyboard. The ISTAT parameters return the value of the last mouse click regardless of when it was executed. Being able to return a mouse click location opens innumerable possibilities for your application programming. Here is a simple command file that lets users select screen foreground and background colors using the mouse. The color settings can even be saved to the RBASE.CFG file. Much of the program is made up of WRITE commands to create the screen display. The location of the mouse click is used with IF statements to determine program action. The color settings are saved to the RBASE.CFG file by simply writing a new SET COLOR command to the end of the file. The last SET command executed from the RBASE.CFG file is the one that remains in force. The order of the commands in the file is not fixed. Any setting can be added to the file using this procedure. -- COLORSET.CMD -- Set screen colors using the mouse SET MESSAGES OFF SET ERROR MESSAGES OFF SET BELL OFF CLEAR ALL VAR SET VAR vcolorback TEXT = (CVAL('color backgrnd')) SET VAR vcolorfore TEXT = (CVAL('color foregrnd')) CLS LABEL beghere WRITE 'ÉÍÍÍÍÍÍÍÍÍÍ Foreground ColorÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍ Background Color+ or ÍÍÍ»' AT 19,3 WRITE 'º º º' AT 20,3 WRITE 'ÉÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍ + ÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍ»' AT 21,1 WRITE 'º Save Settings to Configuration File º Restore Default + Color Set º EXIT º ' AT 22,1 WRITE 'ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ' AT 23,1 -- foreground colors WRITE 'ÛÛÛÛÛ' AT 20,5 LIGHT BLUE ON RED WRITE 'ÛÛÛÛÛ' AT 20,10 LIGHT MAGENTA ON RED WRITE 'ÛÛÛÛÛ' AT 20,15 LIGHT RED ON RED WRITE 'ÛÛÛÛÛ' AT 20,20 YELLOW ON RED WRITE 'ÛÛÛÛÛ' AT 20,25 WHITE ON RED WRITE 'ÛÛÛÛÛ' AT 20,30 BLACK ON RED WRITE 'ÛÛÛÛÛ' AT 20,35 BLUE ON RED WRITE 'ÛÛÛÛÛ' AT 20,40 CYAN ON RED WRITE 'ÛÛÛÛÛ' AT 20,45 MAGENTA ON RED -- background colors WRITE 'ÛÛÛÛÛ' AT 20,62 BLACK ON RED WRITE 'ÛÛÛÛÛ' AT 20,57 BLUE ON RED WRITE 'ÛÛÛÛÛ' AT 20,67 CYAN ON RED LABEL mclick CLS FROM 24 TO 25 GRAY WRITE 'Background: Foreground: ' AT 24,1 BLACK ON GRAY WRITE 'Choose color using mouse, then click on the + screen above menu to set.' AT 25,1 BLACK ON GRAY WRITE .vcolorback AT 24,13 WRITE .vcolorfore AT 24,35 FILLIN vmclick=0 USING '' AT 1,80 IF vmclick NOT CONTAINS 'mouse' THEN PAUSE 2 USING 'You must use the mouse to pick a color' + AT CENTER, CENTER DEFAULT GOTO mclick ENDIF -- find the location of the mouse click SET VAR vmousecol = (ISTAT('mousecol')) SET VAR vmouserow = (ISTAT('mouserow')) IF vmouserow < 19 THEN SET COLOR &vcolorfore ON &vcolorback GOTO beghere ENDIF IF vmouserow = 22 AND vmousecol >= 68 THEN GOTO theend ENDIF IF vmouserow = 22 AND vmousecol BETWEEN 40 AND 68 THEN SET COLOR WHITE ON BLUE SET VAR vcolorback TEXT = (CVAL('color backgrnd')) SET VAR vcolorfore TEXT = (CVAL('color foregrnd')) GOTO beghere ENDIF IF vmouserow = 22 AND vmousecol < 40 THEN GOTO save ENDIF IF vmouserow = 20 THEN IF vmousecol BETWEEN 5 AND 9 THEN SET VAR vcolorfore = 'LIGHT BLUE' ENDIF IF vmousecol BETWEEN 10 AND 14 THEN SET VAR vcolorfore = 'LIGHT MAGENTA' ENDIF IF vmousecol BETWEEN 15 AND 19 THEN SET VAR vcolorfore = 'LIGHT RED' ENDIF IF vmousecol BETWEEN 20 AND 24 THEN SET VAR vcolorfore = 'YELLOW' ENDIF IF vmousecol BETWEEN 25 AND 29 THEN SET VAR vcolorfore = 'WHITE' ENDIF IF vmousecol BETWEEN 30 AND 34 THEN SET VAR vcolorfore = 'BLACK' ENDIF IF vmousecol BETWEEN 35 AND 39 THEN SET VAR vcolorfore = 'BLUE' ENDIF IF vmousecol BETWEEN 40 AND 44 THEN SET VAR vcolorfore = 'CYAN' ENDIF IF vmousecol BETWEEN 45 AND 49 THEN SET VAR vcolorfore = 'MAGENTA' ENDIF IF vmousecol BETWEEN 57 AND 61 THEN SET VAR vcolorback = 'BLUE' ENDIF IF vmousecol BETWEEN 62 AND 66 THEN SET VAR vcolorback = 'BLACK' ENDIF IF vmousecol BETWEEN 67 AND 71 THEN SET VAR vcolorback = 'CYAN' ENDIF ENDIF WRITE .vcolorback AT 24,13 WRITE .vcolorfore AT 24,35 GOTO beghere LABEL save -- Create strings to be put into RBASE.CFG SET VAR vcolr = ('COLOR' & .vcolorfore & 'ON' & .vcolorback) OUTPUT c:\rbfiles\rbase.cfg append WRITE ';' WRITE .vcolr OUTPUT SCREEN LABEL theend CLS CLEAR ALL VAR SET MESSAGES ON SET ERROR MESSAGES ON RETURN R:BASE Exchange Technical Journal ================================= This technical information comes from Microrim's award winning technical journal, the R:BASE Exchange. The R:BASE Exchange provides R:BASE users with usage tips, programming techniques and solutions to common problems - information that can help you get even more out of R:BASE. Available on a yearly subscription basis, or free with Premium Support. For more information, call 1-800-628-6990.