Category : BASIC Source Code
Archive   : QKWIN.ZIP
Filename : BUTTON.BAS

 
Output of file : BUTTON.BAS contained in archive : QKWIN.ZIP
'****************************************************************************
' BUTTON.BAS - Demo of how to use WBUTTONSET and WBUTTONGET .
'****************************************************************************
'
' WBUTTONSET has the following parameters
' WBUTTONSET(id,button#,kb,f-style,f-attr,nf-style,nf-attr,x,y,button$)
' id = current opened window id
' button# = a button number from 1 to 32
' kb = kb value for direct button selection (enter 0 to inhibit)
' f-style = box style for focused button (currently not used, fill with 1)
' f-attr = attribute for focused button
' nf-style = box style for button [1-8] (same as window styles)
' nf-attr = attribute for button when it is not focused
' x,y = starting position of button relative to start of window (0,0)
' button$ = string to place inside button (size of button depends on string len)
'
' WBUTTONGET has the following parameters
' WBUTTONGET(focus,start,num_buttons,result)
' focus = the button to focus when entering WBUTTONGET
' start = starting button number to scan
' num_butt = number of buttons to scan
' result = returns 0 if no action, otherwise a selected button
' If result=0 then you must loop to WBUTTONGET to keep active scan.

REM $DYNAMIC
DEFINT A-Z 'Make all variables integers by default.
DIM SHARED a%(2000) 'Dimension an integer array for our window.
CALL QWINIT(4) 'Need to call this command before using any QW commands.
CLS 'Clear the screen.

'(1) First we have to open a window to use. ------------------------------
id = 3 'All references for a window through id #.
wincolor = &H74 'Setup color for window.
'Used hex values so it's easier to see foreground
'and background. &H74 = Red on White.
CALL WOPEN(20, 8, 58, 18, 2, &H74, "Window TITLE", a%(), id)

CALL WPRINT(id, "~ Use Arrow keys to switch focus,~ press Return to Select.")

'(2) Next we need to define the buttons inside the window. ----------------
CALL WBUTTONSET(id, 1, 15104, 1, &H79, 2, &H71, 5, 5, "OK")
CALL WBUTTONSET(id, 2, 15360, 1, &H79, 2, &H71, 13, 5, "Cancel")
CALL WBUTTONSET(id, 3, 15616, 1, &H79, 2, &H71, 25, 5, "Save")
LOCATE 21, 1

'(3) Now we can sit in a loop till user makes a selection.
focus = 2: 'Input focus.
'Hightlight this button when entering WBUTTONGET.
'focus cannot be 0. Must be in range 1-3 in this example.
DO
CALL WBUTTONGET(focus, 1, 3, result)
IF (result = 0) AND (focus = 0) THEN
PRINT "You've exited without selection."
END
END IF
IF focus < 1 THEN
focus = 3
ELSEIF focus > 3 THEN
focus = 1
END IF
'WBUTTONGET returns 0 on a continual basis if no action on a button.
LOOP WHILE result = 0
PRINT "You've selected button"; result;
END







  3 Responses to “Category : BASIC Source Code
Archive   : QKWIN.ZIP
Filename : BUTTON.BAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/