Category : Dbase (Clipper, FoxBase, etc) Languages Source Code
Archive   : NN0505.ZIP
Filename : EXAMPLE.PRG
Output of file : EXAMPLE.PRG contained in archive : NN0505.ZIP
This Example Demonstrates Pseudo-Objects
<< Danny Sukdeo (C) 1991 for Danny's Solveware >>
*********************************************************************/
#include "DsClass.ch"
LOCAL FuelBar1 := {}, FuelBar2 := {}, nPercentage := 0
CLASS: NewFuelGauge
INSTANCE VAR: Top := 20
INSTANCE VAR: Left := 10
INSTANCE VAR: Title := ""
INSTANCE VAR: ColorBar := "W/N"
INSTANCE VAR: ColorWnd := "N/W"
INSTANCE VAR: SaveBuf := ""
METHOD: CreateFuelGauge()
METHOD: UpdateFuelGauge(nPercent)
METHOD: CloseFuelGauge()
ENDCLASS: NewFuelGauge
CREATE OBJECT FuelBar1 FROM NewFuelGauge
CREATE OBJECT FuelBar2 FROM NewFuelGauge
SEND FuelBar1:Top := 18
SEND FuelBar1:Left := 10
SEND FuelBar1:Title := "FuelGauge Number 1"
SEND FuelBar1:CreateFuelGauge()
SEND FuelBar2:Top := 8
SEND FuelBar2:Left := 20
SEND FuelBar2:Title := "FuelGauge Number 2"
SEND FuelBar2:CreateFuelGauge()
// Multiple fuelgauges
DO WHILE nPercentage <= 100
SEND FuelBar1:UpdateFuelGauge(nPercentage)
SEND FuelBar2:UpdateFuelGauge(nPercentage)
nPercentage += 5
ENDDO
WAIT
SEND FuelBar1:CloseFuelGauge()
WAIT
SEND FuelBar2:CloseFuelGauge()
WAIT
QUIT
//-------------------------------
// CreateFuelGauge() -> NIL
//-------------------------------
FUNCTION CreateFuelGauge
LOCAL cOldColor, nTop, nLeft, nBottom, nRight, cTitle
// Save current color
cOldColor := SETCOLOR()
// Get Top and Left position from class
SEND ActiveObject():Top TO nTop
SEND ActiveObject():Left TO nLeft
nBottom := nTop + 4
nRight := nLeft + 53
// Save underlying region
SEND ActiveObject():SaveBuf := ;
SAVESCREEN(nTop,nLeft,nBottom,nRight)
// Set color of window
SETCOLOR(FSend(ActiveObject():ColorWnd))
// Draw box
@ nTop,nLeft CLEAR TO nBottom,nRight
@ nTop,nLeft TO nBottom,nRight
// Show title
cTitle := FSend(ActiveObject():Title)
@ nTop,nLeft+(((nRight-nLeft+1)-LEN(cTitle))/2) SAY cTitle
// Show percentage (start is zero)
@ nTop+1,nLeft+25 SAY TRANSFORM(0,"999%")
// Show bar indicator
@ nTop+3,nLeft+2 SAY "" + SPACE(11) + "-" + ;
SPACE(12)+ "-" + SPACE(11) +"-" + SPACE(11) +""
// Set color of bar
SETCOLOR(FSend(ActiveObject():ColorBar))
// Show empty bar
@ nTop+2,nLeft+2 SAY REPL(CHR(177),50)
// Restore saved color
SETCOLOR(cOldColor)
RETURN(NIL)
//--------------------------
// UpdateFuelGauge( nPercentage ) -> NIL
//--------------------------
FUNCTION UpdateFuelGauge( nPercentage )
LOCAL cOldColor, nTop, nLeft
// Save current color
cOldColor := SETCOLOR()
// Gget Top and Left position from class
SEND ActiveObject():Top TO nTop
SEND ActiveObject():Left TO nLeft
// Set color of window
SETCOLOR(FSend(ActiveObject():ColorWnd))
// Show percentage
@ nTop + 1,nLeft + 25 SAY ;
TRANSFORM(nPercentage,"999%")
// Set color of bar
SETCOLOR(FSend(ActiveObject():ColorBar))
// Show percentage bar
@ nTop+2,nLeft+2 SAY REPL(CHR(176),nPercentage/2)
// Restore saved color
SETCOLOR(cOldColor)
RETURN(NIL)
//--------------------------
// CloseFuelGauge() -> NIL
//--------------------------
FUNCTION CloseFuelGauge
LOCAL nTop, nLeft
// Get Top and Left position from class
SEND ActiveObject():Top TO nTop
SEND ActiveObject():Left TO nLeft
// Restore saved underground
RESTSCREEN(nTop,nLeft,nTop + 4,nLeft + 53,FSend(ActiveObject():SaveBuf))
RETURN(NIL)
// EOF: Example.prg
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
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/