Category : BASIC Source Code
Archive   : FUELGA.ZIP
Filename : MONITOR.BAS

 
Output of file : MONITOR.BAS contained in archive : FUELGA.ZIP
DECLARE FUNCTION DoMonitor% (Noww%, Top%, Mon%)
'============================================================================
' Multiple Fuel Gauges with Cancel Button
' Aidan Coyne Jan 1993
' Compuserve ID : 100014,2700
'============================================================================
'
' To use MONITOR in your programs :
' 1. Make a call to SetUpMonitor() with required parameters
' 2. Continually make calls to DoMonitor() with the following parameters :
' Noww% : Current Position, Top% : Maximum Position,
' Mon% : Which Gauge to Update
' 3. When finished, make another call to SetUpMonitor with a row% value of 0
' This will cause the form to unload.
'
' Note : You must know in advance the maximum value for the fuel gauge.
' e.g. if reading records from a file, maximum value would be the number
' of records to read. Call could be made to DoMonitor after each read or
' after several reads.
'
' You are free to use this code in your programs without obligation!
''============================================================================
'
'$FORM frmMonitor
CONST FALSE = 0, TRUE = NOT FALSE

SUB CancelMonitor ()
SHARED Cancelled% 'Shared with DoMonitor
' Called From frmMonitor.cmdCancel_Click()
' Simple set Cancelled% variable to be acted upon next time DoMonitor gets called

Cancelled% = TRUE

END SUB

FUNCTION DoMonitor% (Noww%, Top%, Mon%)
SHARED MonGraph$, Cancelled%
' Updates FUEL GAUGE monitor on screen
' Returns TRUE normally, FALSE if cancel button is pressed and confirmed
' Noww% - Current value
' top% - Max Value
' Mon% - Which monitor to update (1..3)

DoMonitor% = TRUE ' Assume cancel hasn't been pressed
ThisGraph$ = MonGraph$
IF Top% = 0 THEN EXIT FUNCTION ' Get out if not reasonable
IF Noww% > Top% THEN EXIT FUNCTION ' values

here! = (100 / Top%) * Noww% ' Work out what size string
here% = (here! / 10) * 4 ' to show in monitor label
IF Noww% = Top% THEN here% = 42: BEEP
grafik$ = STRING$(here%, CHR$(219)) ' Using chr$(219)( Û )
MID$(ThisGraph$, 1) = grafik$
frmMonitor.lblMonitor(Mon%).Caption = ThisGraph$ ' Now set the caption with the
' correct length string
IF Cancelled% THEN DoMonitor% = FALSE ' If cancel button pressed,
' then return FALSE

END FUNCTION

SUB SetUpMonitor (Row%, Col%, NumMons%, Title$(), CancelButton%)
' Row% & Col% determine where gauge goes on screen
' Row%=0 : Unloads gauge
' NumMons% : Number of gauges on the form (1..3)
' Title$() : Title Text for each gauge (Title$(0) is form caption)
' CancelButton% : Puts Cancel Button On Form if TRUE

SHARED MonGraph$, Cancelled% 'Shared with DoMonitor%()

IF Row% = 0 THEN
UNLOAD frmMonitor
EXIT SUB
END IF

MonGraph$ = " ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ "
Cancelled% = FALSE
LOAD frmMonitor ' Initialise Form
frmMonitor.Top = Row% ' Set its coordinates
frmMonitor.Left = Col%
frmMonitor.Height = (NumMons% * 5) + 2 ' Set its height, width
frmMonitor.Caption = Title$(0) ' and caption

IF CancelButton% THEN ' If cancel button required,
frmMonitor.Width = 57 ' increase form width
ELSE ' otherwise disable cancel
frmMonitor.Width = 47 ' button
frmMonitor.cmdCancel.Enabled = FALSE
END IF

frmMonitor.SHOW
FOR i% = 1 TO NumMons%
frmMonitor.frMonitor(i%).Visible = TRUE ' Show each fuel gauge and
frmMonitor.lblMonitor(i%).Caption = MonGraph$ ' set each ones label
frmMonitor.lblMonTitle(i%).Caption = Title$(i%) ' and title
NEXT

END SUB



  3 Responses to “Category : BASIC Source Code
Archive   : FUELGA.ZIP
Filename : MONITOR.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/